Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2023-11-07 12:44:53 +0300
committerPhilipp Hörist <philipp@hoerist.com>2023-11-07 12:44:53 +0300
commite59dd99d32d40123cf8f07e549a44546d975da80 (patch)
tree056cca4b232af2176b9c7f6be8ce1818acf4a209
parent9983452dc3bfd9c8af7d81a9fef5297772d9c343 (diff)
refactor: Presence: Create contact as late as possible
-rw-r--r--gajim/common/modules/presence.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/gajim/common/modules/presence.py b/gajim/common/modules/presence.py
index 28a3a607a..c02836acd 100644
--- a/gajim/common/modules/presence.py
+++ b/gajim/common/modules/presence.py
@@ -91,21 +91,31 @@ class Presence(BaseModule):
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 @@ class Presence(BaseModule):
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'