summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0153/vcard_avatar.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-01-24 02:44:27 -0800
committerLance Stout <lancestout@gmail.com>2013-01-24 02:44:27 -0800
commit751628401ebc23fd8919c99758db2878817c0056 (patch)
tree912470ad51da56e97ee919ea5f62591744fa3097 /sleekxmpp/plugins/xep_0153/vcard_avatar.py
parent403b1802ecb9d40799b00073bd15baf0d0fd8349 (diff)
downloadslixmpp-751628401ebc23fd8919c99758db2878817c0056.tar.gz
slixmpp-751628401ebc23fd8919c99758db2878817c0056.tar.bz2
slixmpp-751628401ebc23fd8919c99758db2878817c0056.tar.xz
slixmpp-751628401ebc23fd8919c99758db2878817c0056.zip
Fixes for vCard avatar hash calculations and MUC considerations.
Diffstat (limited to 'sleekxmpp/plugins/xep_0153/vcard_avatar.py')
-rw-r--r--sleekxmpp/plugins/xep_0153/vcard_avatar.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/sleekxmpp/plugins/xep_0153/vcard_avatar.py b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
index 874897cb..271ac995 100644
--- a/sleekxmpp/plugins/xep_0153/vcard_avatar.py
+++ b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
@@ -10,12 +10,9 @@ import hashlib
import logging
import threading
-from sleekxmpp import JID
from sleekxmpp.stanza import Presence
from sleekxmpp.exceptions import XMPPError
from sleekxmpp.xmlstream import register_stanza_plugin
-from sleekxmpp.xmlstream.matcher import StanzaPath
-from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.plugins.base import BasePlugin
from sleekxmpp.plugins.xep_0153 import stanza, VCardTempUpdate
@@ -86,11 +83,10 @@ class XEP_0153(BasePlugin):
else:
new_hash = hashlib.sha1(data).hexdigest()
self.api['set_hash'](self.xmpp.boundjid, args=new_hash)
+ self._allow_advertising.set()
except XMPPError:
log.debug('Could not retrieve vCard for %s' % self.xmpp.boundjid.bare)
- self._allow_advertising.set()
-
def _end(self, event):
self._allow_advertising.clear()
@@ -128,6 +124,11 @@ class XEP_0153(BasePlugin):
log.debug('Could not retrieve vCard for %s' % jid)
def _recv_presence(self, pres):
+ if pres['muc']['affiliation']:
+ # Don't process vCard avatars for MUC occupants
+ # since they all share the same bare JID.
+ return
+
if not pres.match('presence/vcard_temp_update'):
self.api['set_hash'](pres['from'], args=None)
return
@@ -135,7 +136,7 @@ class XEP_0153(BasePlugin):
data = pres['vcard_temp_update']['photo']
if data is None:
return
- elif data == '' or data != self.api['get_hash'](pres['to']):
+ elif data == '' or data != self.api['get_hash'](pres['from']):
ifrom = pres['to'] if self.xmpp.is_component else None
self.api['reset_hash'](pres['from'], ifrom=ifrom)
self.xmpp.event('vcard_avatar_update', pres)