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


Commits:
605f3fa4 by Philipp Hörist at 2025-05-10T14:08:20+02:00
imprv: Delete avatar

- - - - -


3 changed files:

- gajim/common/modules/vcard_avatars.py
- gajim/gtk/avatar.py
- gajim/gtk/main.py


Changes:

=====================================
gajim/common/modules/vcard_avatars.py
=====================================
@@ -60,6 +60,9 @@ def pass_disco(self, info: DiscoInfo) -> None:
     def get_avatar_sha(self, jid: JID) -> str | None:
         return self._muc_avatar_cache.get(jid)
 
+    def invalidate_cache(self, jid: JID) -> None:
+        self._muc_avatar_cache.pop(jid, None)
+
     @as_task
     def _request_vcard(self,
                        contact: types.ChatContactT,
@@ -192,6 +195,10 @@ def _muc_update_received(self, properties: 
PresenceProperties) -> None:
                                                                groupchat=True)
         assert isinstance(contact, GroupchatParticipant)
 
+        if contact.is_blocked:
+            self._log.info("Ignore avatar because contact is blocked: %s", 
contact.jid)
+            return
+
         # Custom ejabberd room config option
         if contact.room.get_disco() is not None:
             # We have no disco when we create a new room, but receive our


=====================================
gajim/gtk/avatar.py
=====================================
@@ -436,6 +436,15 @@ def __init__(self):
     def invalidate_cache(self, jid: JID | str) -> None:
         self._cache.pop(jid, None)
 
+    def remove_avatar(self, contact: types.ChatContactT) -> None:
+        if not contact.avatar_sha:
+            return
+        path = self.get_avatar_path(contact.avatar_sha)
+        if path is None:
+            return
+        path.unlink(missing_ok=True)
+        self._cache.pop(contact.jid, None)
+
     def get_texture(
         self,
         contact: (


=====================================
gajim/gtk/main.py
=====================================
@@ -719,8 +719,13 @@ def _on_confirmation() -> None:
             )
             assert isinstance(contact, GroupchatContact)
             participant = contact.get_occupant(params.occupant_id)
-            if participant is not None:
-                self._chat_page.remove_chat(params.account, participant.jid)
+            if participant is None:
+                return
+
+            self._chat_page.remove_chat(params.account, participant.jid)
+            app.app.avatar_storage.remove_avatar(participant)
+            client.get_module("VCardAvatars").invalidate_cache(participant.jid)
+            participant.update_avatar()
 
         ConfirmationDialog(
             _("Block Participant?"),



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/605f3fa4074070c1f76c5bde138e17536df260e2

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