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


Commits:
7b95b1e2 by Philipp Hörist at 2026-08-23T17:26:43+02:00
imprv: Make "Forget Groupchat" remove also all metadata

- - - - -


3 changed files:

- gajim/common/storage/archive/storage.py
- gajim/common/storage/events/storage.py
- gajim/gtk/application.py


Changes:

=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -1248,7 +1248,9 @@ def update_pending_message(
 
     @with_session
     @timeit
-    def remove_history_for_jid(self, session: Session, account: str, jid: JID) 
-> None:
+    def remove_history_for_jid(
+        self, session: Session, account: str, jid: JID, forget_groupchat: bool 
= False
+    ) -> None:
         """
         Remove messages and metadata for a specific jid.
         """
@@ -1271,6 +1273,12 @@ def remove_history_for_jid(self, session: Session, 
account: str, jid: JID) -> No
             SecurityLabel,
         ]
 
+        if forget_groupchat:
+            tables += [
+                Occupant,
+                MAMArchiveState,
+            ]
+
         for table in tables:
             stmt = delete(table).where(
                 table.fk_account_pk == fk_account_pk,


=====================================
gajim/common/storage/events/storage.py
=====================================
@@ -12,6 +12,7 @@
 import logging
 
 import sqlalchemy as sa
+from nbxmpp.protocol import JID
 from sqlalchemy.engine import Engine
 from sqlalchemy.orm import Session
 
@@ -126,3 +127,17 @@ def load(
 
         complete = len(event_list) < n_lines
         return event_list, complete
+
+    @with_session
+    def remove_all(
+        self,
+        session: Session,
+        account: str,
+        jid: JID,
+    ) -> None:
+
+        stmt = sa.delete(mod.Event).where(
+            mod.Event.account == account,
+            mod.Event.jid == jid,
+        )
+        session.execute(stmt)


=====================================
gajim/gtk/application.py
=====================================
@@ -848,7 +848,10 @@ def _on_response() -> None:
             client.get_module("MUC").leave(params.jid)
             client.get_module("Bookmarks").remove(params.jid)
 
-            app.storage.archive.remove_history_for_jid(params.account, 
params.jid)
+            app.storage.archive.remove_history_for_jid(
+                params.account, params.jid, forget_groupchat=True
+            )
+            app.storage.events.remove_all(params.account, params.jid)
 
         ConfirmationAlertDialog(
             _("Forget this Group Chat?"),



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/7b95b1e275f35f544d142d52b5992b5160d0e06c
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