summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-07-24 19:43:39 -0700
committerLance Stout <lancestout@gmail.com>2012-07-24 19:43:39 -0700
commit9d8de7fc15afc39a666d2ac16b62a068dfc55112 (patch)
tree869ab78459c1fd72d6dde60f094bd9438c9ee0a3 /sleekxmpp
parent70883086b7b5c290f220357ba920db504b926008 (diff)
downloadslixmpp-9d8de7fc15afc39a666d2ac16b62a068dfc55112.tar.gz
slixmpp-9d8de7fc15afc39a666d2ac16b62a068dfc55112.tar.bz2
slixmpp-9d8de7fc15afc39a666d2ac16b62a068dfc55112.tar.xz
slixmpp-9d8de7fc15afc39a666d2ac16b62a068dfc55112.zip
Fix publish vcard avatars, and PEP avatar metadata.
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/plugins/xep_0084/avatar.py16
-rw-r--r--sleekxmpp/plugins/xep_0084/stanza.py2
-rw-r--r--sleekxmpp/plugins/xep_0153/vcard_avatar.py3
3 files changed, 13 insertions, 8 deletions
diff --git a/sleekxmpp/plugins/xep_0084/avatar.py b/sleekxmpp/plugins/xep_0084/avatar.py
index bbac330a..03711871 100644
--- a/sleekxmpp/plugins/xep_0084/avatar.py
+++ b/sleekxmpp/plugins/xep_0084/avatar.py
@@ -41,6 +41,9 @@ class XEP_0084(BasePlugin):
def session_bind(self, jid):
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,
callback=None, timeout=None):
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
@@ -54,8 +57,7 @@ class XEP_0084(BasePlugin):
payload = Data()
payload['value'] = data
return self.xmpp['xep_0163'].publish(payload,
- node=Data.namespace,
- id=hashlib.sha1(data).hexdigest(),
+ id=self.generate_id(data),
ifrom=ifrom,
block=block,
callback=callback,
@@ -72,12 +74,12 @@ class XEP_0084(BasePlugin):
height=info.get('height', ''),
width=info.get('width', ''),
url=info.get('url', ''))
- for pointer in pointers:
- metadata.add_pointer(pointer)
- return self.xmpp['xep_0163'].publish(payload,
- node=Data.namespace,
- id=hashlib.sha1(data).hexdigest(),
+ if pointers is not None:
+ for pointer in pointers:
+ metadata.add_pointer(pointer)
+
+ return self.xmpp['xep_0163'].publish(metadata,
ifrom=ifrom,
block=block,
callback=callback,
diff --git a/sleekxmpp/plugins/xep_0084/stanza.py b/sleekxmpp/plugins/xep_0084/stanza.py
index 1b204471..e9133998 100644
--- a/sleekxmpp/plugins/xep_0084/stanza.py
+++ b/sleekxmpp/plugins/xep_0084/stanza.py
@@ -43,7 +43,7 @@ class MetaData(ElementBase):
info = Info()
info.values = {'id': id,
'type': itype,
- 'bytes': ibytes,
+ 'bytes': '%s' % ibytes,
'height': height,
'width': width,
'url': url}
diff --git a/sleekxmpp/plugins/xep_0153/vcard_avatar.py b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
index 6b70e33e..bec792cb 100644
--- a/sleekxmpp/plugins/xep_0153/vcard_avatar.py
+++ b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
@@ -75,6 +75,9 @@ class XEP_0153(BasePlugin):
return stanza
def _reset_hash(self, jid=None):
+ if jid is None:
+ jid = self.xmpp.boundjid
+
own_jid = (jid.bare == self.xmpp.boundjid.bare)
if self.xmpp.is_component:
own_jid = (jid.domain == self.xmpp.boundjid.domain)