Philipp Hörist pushed to branch master at gajim / gajim
Commits:
fb8999a3 by Philipp Hörist at 2026-06-07T01:00:07+02:00
fix: GroupChat: Allow sending PMs as visitor
Fixes #12296
- - - - -
a3ec62be by Philipp Hörist at 2026-06-07T01:00:14+02:00
fix: GroupChat: Correctly show error when PM cannot be sent
Make a lookup in the database to improve finding the corresponding error message
Fixes #12196
- - - - -
3 changed files:
- gajim/common/modules/message.py
- gajim/common/storage/archive/storage.py
- gajim/gtk/util/misc.py
Changes:
=====================================
gajim/common/modules/message.py
=====================================
@@ -316,6 +316,21 @@ def _message_error_received(
timestamp = get_message_timestamp(properties)
assert properties.error is not None
+ assert properties.jid is not None
+
+ # Some servers do not include the original payload in the error
+ # This makes it hard to detect MUC PMs. Try to find the corresponding
+ # message in the database to narrow it down.
+ remotes = [properties.jid]
+ if not properties.jid.is_bare:
+ remotes.append(properties.jid.new_as_bare())
+
+ message = app.storage.archive.get_message_from_error_id(
+ self._account, remotes, message_id
+ )
+
+ if message is not None:
+ remote_jid = message.remote.jid
error_data = mod.MessageError(
account_=self._account,
=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -191,6 +191,16 @@ def _get_jid_pk(self, session: Session, jid: JID) -> int:
self._jid_pks[jid] = pk
return pk
+ def _get_existing_jid_pks(self, jids: Iterable[JID]) -> list[int]:
+ fk_remote_pks: list[int] = []
+ for jid in jids:
+ pk = self._jid_pks.get(jid)
+ if pk is None:
+ continue
+
+ fk_remote_pks.append(pk)
+ return fk_remote_pks
+
def _set_foreign_keys(self, session: Session, row: Any) -> None:
fk_account_pk = None
account = getattr(row, "account_", None)
@@ -428,6 +438,33 @@ def _get_message_with_pk(
return session.scalar(stmt)
+ @with_session
+ @timeit
+ def get_message_from_error_id(
+ self,
+ session: Session,
+ account: str,
+ jids: Iterable[JID],
+ id_: str,
+ ) -> Message | None:
+
+ fk_account_pk = self._get_account_pk(session, account)
+ fk_remote_pks = self._get_existing_jid_pks(jids)
+ if not fk_remote_pks:
+ return None
+
+ stmt = select(Message).where(
+ Message.id == id_,
+ Message.fk_remote_pk.in_(fk_remote_pks),
+ Message.fk_account_pk == fk_account_pk,
+ )
+
+ results = session.scalars(stmt).all()
+ self._log.info(
+ "Found %s corresponding message(s) for error with id %s",
len(results), id_
+ )
+ return results[0] if results else None
+
@with_session
@timeit
def get_message_with_id(
=====================================
gajim/gtk/util/misc.py
=====================================
@@ -295,16 +295,7 @@ def allow_send_message(has_text: bool, contact:
types.ChatContactT) -> bool:
if not contact.is_available:
return False
- groupchat_contact = contact.room
- joined = groupchat_contact.is_joined
-
- is_visitor = False
- if joined:
- self_contact = groupchat_contact.get_self()
- assert self_contact
- is_visitor = self_contact.role.is_visitor
-
- return bool(has_text and joined and not is_visitor)
+ return bool(has_text and contact.room.is_joined)
# BareContact
online = app.account_is_connected(contact.account)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5e9d3cc59f851798f04526bd69545ab098d7d0df...a3ec62be916c5529e4fbfda9c90908f2e0549d23
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5e9d3cc59f851798f04526bd69545ab098d7d0df...a3ec62be916c5529e4fbfda9c90908f2e0549d23
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]