summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-01-16 22:32:40 -0800
committerLance Stout <lancestout@gmail.com>2013-01-16 22:32:40 -0800
commit518eee05c224b00cf4622038290f5fb0c0d4e95b (patch)
tree4c92216e8c3431921b732dbbe0f685bdf3cca6e8 /sleekxmpp/plugins
parent6bac4741f6ca7d73c43ae0fcb138b07e71ed1352 (diff)
downloadslixmpp-518eee05c224b00cf4622038290f5fb0c0d4e95b.tar.gz
slixmpp-518eee05c224b00cf4622038290f5fb0c0d4e95b.tar.bz2
slixmpp-518eee05c224b00cf4622038290f5fb0c0d4e95b.tar.xz
slixmpp-518eee05c224b00cf4622038290f5fb0c0d4e95b.zip
Set vCard avatar hash on startup.
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r--sleekxmpp/plugins/xep_0054/vcard_temp.py2
-rw-r--r--sleekxmpp/plugins/xep_0153/vcard_avatar.py12
2 files changed, 12 insertions, 2 deletions
diff --git a/sleekxmpp/plugins/xep_0054/vcard_temp.py b/sleekxmpp/plugins/xep_0054/vcard_temp.py
index 09acd454..97da8c7c 100644
--- a/sleekxmpp/plugins/xep_0054/vcard_temp.py
+++ b/sleekxmpp/plugins/xep_0054/vcard_temp.py
@@ -8,7 +8,7 @@
import logging
-from sleekxmpp import Iq
+from sleekxmpp import JID, Iq
from sleekxmpp.exceptions import XMPPError
from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.xmlstream.handler import Callback
diff --git a/sleekxmpp/plugins/xep_0153/vcard_avatar.py b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
index c74713e5..03106247 100644
--- a/sleekxmpp/plugins/xep_0153/vcard_avatar.py
+++ b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
@@ -78,7 +78,17 @@ class XEP_0153(BasePlugin):
self.xmpp.roster[jid].send_last_presence()
def _start(self, event):
- vcard = self.xmpp['xep_0054'].get_vcard()
+ try:
+ vcard = self.xmpp['xep_0054'].get_vcard()
+ data = vcard['vcard_temp']['PHOTO']['BINVAL']
+ if not data:
+ new_hash = ''
+ else:
+ new_hash = hashlib.sha1(data).hexdigest()
+ self.api['set_hash'](self.xmpp.boundjid, args=new_hash)
+ except XMPPError:
+ log.debug('Could not retrieve vCard for %s' % jid)
+
self._allow_advertising.set()
def _end(self, event):