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


Commits:
001650d8 by Philipp Hörist at 2023-06-26T17:59:03+02:00
imprv: Moderation: Handle unknown moderator JID

- - - - -


5 changed files:

- gajim/common/helpers.py
- gajim/common/modules/mam.py
- gajim/gtk/chat_list.py
- gajim/gtk/chat_list_row.py
- gajim/gtk/control.py


Changes:

=====================================
gajim/common/helpers.py
=====================================
@@ -687,14 +687,13 @@ def get_subscription_request_msg(account: str | None = 
None) -> str:
     return Template(message).safe_substitute({'name': app.nicks[account]})
 
 
-def get_retraction_text(account: str,
-                        moderator_jid: str,
+def get_retraction_text(by: str | None,
                         reason: str | None) -> str:
 
-    client = app.get_client(account)
-    contact = client.get_module('Contacts').get_contact(
-        moderator_jid, groupchat=True)
-    text = _('This message has been retracted by %s.') % contact.name
+    by_text = ''
+    if by is not None:
+        by_text = (' by %s') % by
+    text = _('This message has been moderated%s.') % by_text
     if reason is not None:
         text += ' ' + _('Reason: %s') % reason
     return text


=====================================
gajim/common/modules/mam.py
=====================================
@@ -279,7 +279,6 @@ def _mam_message_received(self,
                 'retracted', 'reason', properties.moderation.reason)
 
             msgtxt = get_retraction_text(
-                self._account,
                 properties.moderation.moderator_jid,
                 properties.moderation.reason)
 


=====================================
gajim/gtk/chat_list.py
=====================================
@@ -637,7 +637,6 @@ def _on_message_moderated(self, event: 
events.MessageModerated) -> None:
 
         if event.moderation.stanza_id == row.stanza_id:
             text = get_retraction_text(
-                event.account,
                 event.moderation.moderator_jid,
                 event.moderation.reason)
             row.set_message_text(text)


=====================================
gajim/gtk/chat_list_row.py
=====================================
@@ -164,7 +164,7 @@ def _display_last_conversation_line(self) -> None:
                     reason = line.additional_data.get_value(
                         'retracted', 'reason')
                     message_text = get_retraction_text(
-                        self.account, retracted_by, reason)
+                        retracted_by, reason)
 
             me_nickname = None
             if line.kind in (KindConstant.CHAT_MSG_SENT,


=====================================
gajim/gtk/control.py
=====================================
@@ -453,7 +453,6 @@ def _on_message_moderated(self, event: 
events.MessageModerated) -> None:
             return
 
         text = get_retraction_text(
-            self.contact.account,
             event.moderation.moderator_jid,
             event.moderation.reason)
         self._scrolled_view.show_message_retraction(
@@ -663,8 +662,7 @@ def _add_messages(self, messages: list[ConversationRow]):
                 if retracted_by is not None:
                     reason = msg.additional_data.get_value(
                         'retracted', 'reason')
-                    message_text = get_retraction_text(
-                        self.contact.account, retracted_by, reason)
+                    message_text = get_retraction_text(retracted_by, reason)
 
             self._scrolled_view.add_message(
                 message_text,



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/001650d8701cd9fe1e5b52b6c290ac4f9b2a03dd

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