From b22f1baca5fb2cc664b80937d64ccfce670155d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 11 Jan 2019 20:45:11 +0100 Subject: [PATCH] Propagate presences further Other modules like avatars and entity caps come after the base presence handlers --- gajim/common/modules/caps.py | 2 +- gajim/common/modules/muc.py | 16 +++++++--------- gajim/common/modules/presence.py | 12 +++++++----- gajim/common/modules/vcard_avatars.py | 3 +++ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gajim/common/modules/caps.py b/gajim/common/modules/caps.py index 8ecd75b73..f8bb544c7 100644 --- a/gajim/common/modules/caps.py +++ b/gajim/common/modules/caps.py @@ -38,7 +38,7 @@ class Caps: StanzaHandler(name='presence', callback=self._entity_caps, ns=nbxmpp.NS_CAPS, - priority=45), + priority=51), ] self._capscache = caps_cache.capscache diff --git a/gajim/common/modules/muc.py b/gajim/common/modules/muc.py index 9cf1ea273..8bee793be 100644 --- a/gajim/common/modules/muc.py +++ b/gajim/common/modules/muc.py @@ -163,7 +163,7 @@ class MUC: def _on_muc_presence(self, _con, _stanza, properties): if properties.type == PresenceType.ERROR: self._raise_muc_event('muc-presence-error', properties) - raise nbxmpp.NodeProcessed + return def _on_muc_user_presence(self, _con, _stanza, properties): if properties.type == PresenceType.ERROR: @@ -175,7 +175,7 @@ class MUC: contact.presence = PresenceType.UNAVAILABLE log.info('MUC destroyed: %s', properties.jid.getBare()) self._raise_muc_event('muc-destroyed', properties) - raise nbxmpp.NodeProcessed + return contact = app.contacts.get_gc_contact(self._account, properties.jid.getBare(), @@ -189,7 +189,7 @@ class MUC: properties.jid, properties.muc_user.nick) self._raise_muc_event('muc-nickname-changed', properties) - raise nbxmpp.NodeProcessed + return if contact is None and properties.type.is_available: self._add_new_muc_contact(properties) @@ -199,16 +199,16 @@ class MUC: else: log.info('User joined: %s', properties.jid) self._raise_muc_event('muc-user-joined', properties) - raise nbxmpp.NodeProcessed + return if properties.is_muc_self_presence and properties.is_kicked: self._raise_muc_event('muc-self-kicked', properties) - raise nbxmpp.NodeProcessed + return if properties.is_muc_self_presence and properties.type.is_unavailable: # Its not a kick, so this is the reflection of our own # unavailable presence, because we left the MUC - raise nbxmpp.NodeProcessed + return if properties.type.is_unavailable: for _event in app.events.get_events(self._account, @@ -237,7 +237,7 @@ class MUC: app.contacts.remove_gc_contact(self._account, contact) log.info('User %s left', properties.jid) self._raise_muc_event('muc-user-left', properties) - raise nbxmpp.NodeProcessed + return if contact.affiliation != properties.affiliation: contact.affiliation = properties.affiliation @@ -263,8 +263,6 @@ class MUC: properties.show) self._raise_muc_event('muc-user-status-show-changed', properties) - raise nbxmpp.NodeProcessed - def _raise_muc_event(self, event_name, properties): app.nec.push_incoming_event( NetworkEvent(event_name, diff --git a/gajim/common/modules/presence.py b/gajim/common/modules/presence.py index b38256839..7d8176444 100644 --- a/gajim/common/modules/presence.py +++ b/gajim/common/modules/presence.py @@ -65,25 +65,29 @@ class Presence: self.jids_for_auto_auth = [] def _presence_received(self, _con, stanza, properties): + if properties.from_muc: + # Already handled in MUC module + return + log.info('Received from %s', properties.jid) if properties.type == PresenceType.ERROR: log.info('Error: %s %s', properties.jid, properties.error) - raise nbxmpp.NodeProcessed + return if self._account == 'Local': app.nec.push_incoming_event( NetworkEvent('raw-pres-received', conn=self._con, stanza=stanza)) - raise nbxmpp.NodeProcessed + return if properties.is_self_presence: app.nec.push_incoming_event( NetworkEvent('our-show', conn=self._con, show=properties.show.value)) - raise nbxmpp.NodeProcessed + return contacts = app.contacts.get_jid_list(self._account) if properties.jid.getBare() not in contacts and not properties.is_self_bare: @@ -133,8 +137,6 @@ class Presence: app.nec.push_incoming_event(event_) - raise nbxmpp.NodeProcessed - def _update_contact(self, event, properties): # Note: A similar method also exists in connection_zeroconf jid = properties.jid.getBare() diff --git a/gajim/common/modules/vcard_avatars.py b/gajim/common/modules/vcard_avatars.py index 2d30657cb..747c3c108 100644 --- a/gajim/common/modules/vcard_avatars.py +++ b/gajim/common/modules/vcard_avatars.py @@ -56,6 +56,9 @@ class VCardAvatars: app.config.set_per('accounts', self._account, 'avatar_sha', '') def _presence_received(self, _con, _stanza, properties): + if not properties.type.is_available: + return + if properties.avatar_state in (AvatarState.IGNORE, AvatarState.NOT_READY): return