Handle presence without from attr correctly

Fixes #9472
This commit is contained in:
Philipp Hörist 2018-12-03 15:40:43 +01:00
parent f8047c63fe
commit bbc038ec46
3 changed files with 16 additions and 6 deletions

View File

@ -42,6 +42,15 @@ class Caps:
self._create_suitable_client_caps = caps_cache.create_suitable_client_caps self._create_suitable_client_caps = caps_cache.create_suitable_client_caps
def _presence_received(self, _con, stanza): def _presence_received(self, _con, stanza):
if stanza.getType() in ('unavailable', 'error'):
return
from_ = stanza.getFrom()
if from_ is None:
# Presence from ourself
return
full_jid = str(from_)
hash_method = node = caps_hash = None hash_method = node = caps_hash = None
caps = stanza.getTag('c', namespace=nbxmpp.NS_CAPS) caps = stanza.getTag('c', namespace=nbxmpp.NS_CAPS)
@ -50,8 +59,6 @@ class Caps:
node = caps['node'] node = caps['node']
caps_hash = caps['ver'] caps_hash = caps['ver']
from_ = stanza.getFrom()
full_jid = str(from_)
show = parse_show(stanza) show = parse_show(stanza)
type_ = parse_type(stanza) type_ = parse_type(stanza)

View File

@ -74,8 +74,8 @@ class Chatstate:
return return
full_jid = stanza.getFrom() full_jid = stanza.getFrom()
if full_jid is None or self._con.get_own_jid().bareMatch(full_jid):
if self._con.get_own_jid().bareMatch(full_jid): # Presence from ourself
return return
contact = app.contacts.get_gc_contact( contact = app.contacts.get_gc_contact(

View File

@ -51,12 +51,15 @@ class VCardAvatars:
app.config.set_per('accounts', self._account, 'avatar_sha', '') app.config.set_per('accounts', self._account, 'avatar_sha', '')
def _presence_received(self, _con, stanza): def _presence_received(self, _con, stanza):
update = stanza.getTag('x', namespace=nbxmpp.NS_VCARD_UPDATE) if stanza.getType() in ('unavailable', 'error'):
if update is None:
return return
jid = stanza.getFrom() jid = stanza.getFrom()
update = stanza.getTag('x', namespace=nbxmpp.NS_VCARD_UPDATE)
if update is None:
return
avatar_sha = update.getTagData('photo') avatar_sha = update.getTagData('photo')
if avatar_sha is None: if avatar_sha is None:
log.info('%s is not ready to promote an avatar', jid) log.info('%s is not ready to promote an avatar', jid)