[Git][gajim/gajim][master] Propagate presences further

Philipp Hörist gitlab at dev.gajim.org
Fri Jan 11 20:45:26 CET 2019


Philipp Hörist pushed to branch master at gajim / gajim


Commits:
b22f1bac by Philipp Hörist at 2019-01-11T19:45:11Z
Propagate presences further

Other modules like avatars and entity caps come after the base presence handlers

- - - - -


4 changed files:

- gajim/common/modules/caps.py
- gajim/common/modules/muc.py
- gajim/common/modules/presence.py
- gajim/common/modules/vcard_avatars.py


Changes:

=====================================
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


=====================================
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,


=====================================
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()


=====================================
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



View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/b22f1baca5fb2cc664b80937d64ccfce670155d6

-- 
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/b22f1baca5fb2cc664b80937d64ccfce670155d6
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20190111/c2e442a3/attachment-0001.html>


More information about the Commits mailing list