Philipp Hörist pushed to branch master at gajim / gajim
Commits: 159219cf by lovetox at 2022-05-03T00:07:07+02:00 fix: Handle multiple stanza-id elements
- - - - -
6 changed files:
- gajim/common/modules/mam.py - gajim/common/modules/message.py - gajim/gajim.py - gajim/gtk/chat_list.py - gajim/gtk/controls/groupchat.py - setup.cfg
Changes:
===================================== gajim/common/modules/mam.py ===================================== @@ -128,6 +128,12 @@ def _get_unique_id(self, properties): # A message we received return properties.mam.id, None
+ @staticmethod + def _get_stanza_id(properties, archive_jid): + for stanza_id in properties.stanza_ids: + if stanza_id.by == archive_jid: + return stanza_id + def _set_message_archive_info(self, _con, _stanza, properties): if (properties.is_mam_message or properties.is_pubsub or @@ -155,10 +161,11 @@ def _set_message_archive_info(self, _con, _stanza, properties): archive_jid = self._con.get_own_jid().bare timestamp = None
- if properties.stanza_id is None: + if not properties.stanza_ids: return
- if not archive_jid == properties.stanza_id.by: + stanza_id = self._get_stanza_id(properties, archive_jid) + if stanza_id is None: return
if not self.is_catch_up_finished(archive_jid): @@ -166,7 +173,7 @@ def _set_message_archive_info(self, _con, _stanza, properties):
app.storage.archive.set_archive_infos( archive_jid, - last_mam_id=properties.stanza_id.id, + last_mam_id=stanza_id.id, last_muc_timestamp=timestamp)
def _mam_message_received(self, _con, stanza, properties):
===================================== gajim/common/modules/message.py ===================================== @@ -292,7 +292,7 @@ def _get_unique_id(self, properties): # Deduplicate self message with message-id return None, properties.id
- if properties.stanza_id is None: + if not properties.stanza_ids: return None, None
if properties.type.is_groupchat: @@ -309,8 +309,10 @@ def _get_unique_id(self, properties):
archive = self._con.get_own_jid()
- if archive.bare_match(properties.stanza_id.by): - return properties.stanza_id.id, None + for stanza_id in properties.stanza_ids: + if archive.bare_match(stanza_id.by): + return stanza_id.id, None + # stanza-id not added by the archive, ignore it. return None, None
===================================== gajim/gajim.py ===================================== @@ -30,7 +30,7 @@ from gajim.common import i18n
-_MIN_NBXMPP_VER = '3.0.0-dev2' +_MIN_NBXMPP_VER = '3.0.0.dev3' _MIN_GTK_VER = '3.22.27' _MIN_CAIRO_VER = '1.16.0' _MIN_PYGOBJECT_VER = '3.32.0'
===================================== gajim/gtk/chat_list.py ===================================== @@ -397,13 +397,9 @@ def _on_message_received(self, event: MessageEventT) -> None: row.set_nick(nick) if event.name == 'mam-message-received': row.set_timestamp(event.properties.mam.timestamp) - row.set_stanza_id(event.stanza_id) else: row.set_timestamp(event.properties.timestamp) - stanza_id = None - if event.properties.stanza_id: - stanza_id = event.properties.stanza_id.id - row.set_stanza_id(stanza_id) + row.set_stanza_id(event.stanza_id) row.set_message_id(event.unique_id) row.set_message_text( event.msgtxt,
===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -612,15 +612,13 @@ def _on_gc_message_received(self, event: events.GcMessageReceived) -> None: else: if event.properties.muc_nickname == self.contact.nickname: self.last_sent_txt = event.msgtxt - stanza_id = None - if event.properties.stanza_id: - stanza_id = event.properties.stanza_id.id + self.add_message(event.msgtxt, contact=event.properties.muc_nickname, tim=event.properties.timestamp, displaymarking=event.displaymarking, message_id=event.properties.id, - stanza_id=stanza_id, + stanza_id=event.stanza_id, additional_data=event.additional_data) event.needs_highlight = helpers.message_needs_highlight( event.msgtxt,
===================================== setup.cfg ===================================== @@ -22,7 +22,7 @@ test_suite = test install_requires = css-parser keyring - nbxmpp>=2.99.0 + nbxmpp>=3.0.0.dev3 packaging precis-i18n>=1.0.0 pyOpenSSL>=16.2
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/159219cfdf72538316b25416b79b8c70c...