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


Commits:
e59dd99d by Philipp Hörist at 2023-11-07T10:44:53+01:00
refactor: Presence: Create contact as late as possible

- - - - -


1 changed file:

- gajim/common/modules/presence.py


Changes:

=====================================
gajim/common/modules/presence.py
=====================================
@@ -91,21 +91,31 @@ def _presence_received(self,
                            properties: PresenceProperties
                            ) -> None:
 
+        self._log.info('Received from %s', properties.jid)
+
         if properties.from_muc:
             # MUC occupant presences are already handled in MUC module
             return
 
-        contact = self._con.get_module('Contacts').get_contact(properties.jid)
-        if contact.is_groupchat:
+        muc = self._con.get_module('MUC').get_muc_data(properties.jid)
+        if muc is not None:
             # Presence from the MUC itself, used for MUC avatar
             # handled in VCardAvatars module
             return
 
-        self._log.info('Received from %s', properties.jid)
+        jid = properties.jid.bare
+        roster_item = self._con.get_module('Roster').get_item(jid)
+
+        if roster_item is None and not properties.is_self_bare:
+            # Handle only presence from roster contacts
+            self._log.warning('Unknown presence received')
+            self._log.warning(stanza)
+            return
 
         presence_data = PresenceData.from_presence(properties)
         self._presence_store[properties.jid] = presence_data
 
+        contact = self._con.get_module('Contacts').get_contact(properties.jid)
         contact.update_presence(presence_data)
 
         if properties.is_self_presence:
@@ -113,14 +123,6 @@ def _presence_received(self,
                                             show=properties.show.value))
             return
 
-        jid = properties.jid.bare
-        roster_item = self._con.get_module('Roster').get_item(jid)
-        if not properties.is_self_bare and roster_item is None:
-            # Handle only presence from roster contacts
-            self._log.warning('Unknown presence received')
-            self._log.warning(stanza)
-            return
-
         show = properties.show.value
         if properties.type.is_unavailable:
             show = 'offline'



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/e59dd99d32d40123cf8f07e549a44546d975da80
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to