Philipp Hörist pushed to branch master at gajim / gajim
Commits:
2006a3ef by Philipp Hörist at 2025-03-10T19:29:47+01:00
refactor: MAM: Improve error handling
Add removal by id because the JID is not in all error conditions available
- - - - -
2 changed files:
- gajim/common/modules/mam.py
- pyproject.toml
Changes:
=====================================
gajim/common/modules/mam.py
=====================================
@@ -102,9 +102,15 @@ def _reset_state(self) -> None:
self._mam_query_ids.clear()
self._catch_up_finished.clear()
- def _remove_query_id(self, jid: JID) -> None:
+ def _remove_query_by_jid(self, jid: JID) -> None:
self._mam_query_ids.pop(jid, None)
+ def _remove_query_by_id(self, queryid: str) -> None:
+ for jid, _queryid in list(self._mam_query_ids.items()):
+ if _queryid == queryid:
+ del self._mam_query_ids[jid]
+ return
+
def is_catch_up_finished(self, jid: JID) -> bool:
return jid in self._catch_up_finished
@@ -212,11 +218,8 @@ def _mam_message_received(self,
self._log.warning(stanza)
raise nbxmpp.NodeProcessed
+ assert properties.remote_jid is not None
stanza_id = properties.mam.id
- if stanza_id is None:
- self._log.warning('Unable to determine stanza id')
- self._log.warning(stanza)
- raise nbxmpp.NodeProcessed
if app.storage.archive.check_if_stanza_id_exists(
self._account,
@@ -426,7 +429,7 @@ def _execute_query(self,
after=mam_id,
start=start_date)
- self._remove_query_id(result.jid)
+ self._remove_query_by_jid(result.jid)
raise_if_error(result)
@@ -447,7 +450,7 @@ def _execute_query(self,
after=result.rsm.last,
start=start_date)
- self._remove_query_id(result.jid)
+ self._remove_query_by_jid(result.jid)
raise_if_error(result)
@@ -489,11 +492,11 @@ def _on_interval_result(self, task: Task) -> None:
try:
result = task.finish()
- except (StanzaError, MalformedStanzaError) as error:
- self._remove_query_id(error.jid)
+ except (StanzaError, MalformedStanzaError):
+ self._remove_query_by_id(queryid)
return
- self._remove_query_id(result.jid)
+ self._remove_query_by_jid(result.jid)
if start_date:
timestamp = start_date
=====================================
pyproject.toml
=====================================
@@ -122,7 +122,6 @@ exclude = [
"gajim/common/modules/httpupload.py",
"gajim/common/modules/ibb.py",
"gajim/common/modules/jingle.py",
- "gajim/common/modules/mam.py",
"gajim/common/modules/message.py",
"gajim/common/modules/muc.py",
"gajim/common/modules/omemo.py",
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/2006a3efe197158bf104460a6a8842292b9aaa2c
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/2006a3efe197158bf104460a6a8842292b9aaa2c
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]