Fix publish vcard avatars, and PEP avatar metadata.
This commit is contained in:
parent
70883086b7
commit
9d8de7fc15
@ -41,6 +41,9 @@ class XEP_0084(BasePlugin):
|
|||||||
def session_bind(self, jid):
|
def session_bind(self, jid):
|
||||||
self.xmpp['xep_0163'].register_pep('avatar_metadata', MetaData)
|
self.xmpp['xep_0163'].register_pep('avatar_metadata', MetaData)
|
||||||
|
|
||||||
|
def generate_id(self, data):
|
||||||
|
return hashlib.sha1(data).hexdigest()
|
||||||
|
|
||||||
def retrieve_avatar(self, jid, id, url=None, ifrom=None, block=True,
|
def retrieve_avatar(self, jid, id, url=None, ifrom=None, block=True,
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None):
|
||||||
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
|
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
|
||||||
@ -54,8 +57,7 @@ class XEP_0084(BasePlugin):
|
|||||||
payload = Data()
|
payload = Data()
|
||||||
payload['value'] = data
|
payload['value'] = data
|
||||||
return self.xmpp['xep_0163'].publish(payload,
|
return self.xmpp['xep_0163'].publish(payload,
|
||||||
node=Data.namespace,
|
id=self.generate_id(data),
|
||||||
id=hashlib.sha1(data).hexdigest(),
|
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
block=block,
|
block=block,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
@ -72,12 +74,12 @@ class XEP_0084(BasePlugin):
|
|||||||
height=info.get('height', ''),
|
height=info.get('height', ''),
|
||||||
width=info.get('width', ''),
|
width=info.get('width', ''),
|
||||||
url=info.get('url', ''))
|
url=info.get('url', ''))
|
||||||
for pointer in pointers:
|
|
||||||
metadata.add_pointer(pointer)
|
|
||||||
|
|
||||||
return self.xmpp['xep_0163'].publish(payload,
|
if pointers is not None:
|
||||||
node=Data.namespace,
|
for pointer in pointers:
|
||||||
id=hashlib.sha1(data).hexdigest(),
|
metadata.add_pointer(pointer)
|
||||||
|
|
||||||
|
return self.xmpp['xep_0163'].publish(metadata,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
block=block,
|
block=block,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
|
@ -43,7 +43,7 @@ class MetaData(ElementBase):
|
|||||||
info = Info()
|
info = Info()
|
||||||
info.values = {'id': id,
|
info.values = {'id': id,
|
||||||
'type': itype,
|
'type': itype,
|
||||||
'bytes': ibytes,
|
'bytes': '%s' % ibytes,
|
||||||
'height': height,
|
'height': height,
|
||||||
'width': width,
|
'width': width,
|
||||||
'url': url}
|
'url': url}
|
||||||
|
@ -75,6 +75,9 @@ class XEP_0153(BasePlugin):
|
|||||||
return stanza
|
return stanza
|
||||||
|
|
||||||
def _reset_hash(self, jid=None):
|
def _reset_hash(self, jid=None):
|
||||||
|
if jid is None:
|
||||||
|
jid = self.xmpp.boundjid
|
||||||
|
|
||||||
own_jid = (jid.bare == self.xmpp.boundjid.bare)
|
own_jid = (jid.bare == self.xmpp.boundjid.bare)
|
||||||
if self.xmpp.is_component:
|
if self.xmpp.is_component:
|
||||||
own_jid = (jid.domain == self.xmpp.boundjid.domain)
|
own_jid = (jid.domain == self.xmpp.boundjid.domain)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user