Set vCard avatar hash on startup.
This commit is contained in:
parent
6bac4741f6
commit
518eee05c2
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from sleekxmpp import Iq
|
from sleekxmpp import JID, Iq
|
||||||
from sleekxmpp.exceptions import XMPPError
|
from sleekxmpp.exceptions import XMPPError
|
||||||
from sleekxmpp.xmlstream import register_stanza_plugin
|
from sleekxmpp.xmlstream import register_stanza_plugin
|
||||||
from sleekxmpp.xmlstream.handler import Callback
|
from sleekxmpp.xmlstream.handler import Callback
|
||||||
|
@ -78,7 +78,17 @@ class XEP_0153(BasePlugin):
|
|||||||
self.xmpp.roster[jid].send_last_presence()
|
self.xmpp.roster[jid].send_last_presence()
|
||||||
|
|
||||||
def _start(self, event):
|
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()
|
self._allow_advertising.set()
|
||||||
|
|
||||||
def _end(self, event):
|
def _end(self, event):
|
||||||
|
Loading…
Reference in New Issue
Block a user