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


Commits:
bc14c535 by wurstsalat at 2023-03-09T18:59:28+00:00
fix: Don't fail if contact name for MUC message is None

Fixes #11417

- - - - -


2 changed files:

- gajim/common/storage/archive.py
- gajim/gtk/control.py


Changes:

=====================================
gajim/common/storage/archive.py
=====================================
@@ -100,7 +100,7 @@ class JidsTableRow(NamedTuple):
 
 
 class ConversationRow(NamedTuple):
-    contact_name: str
+    contact_name: str | None
     time: float
     kind: int
     show: int


=====================================
gajim/gtk/control.py
=====================================
@@ -730,6 +730,10 @@ def add_messages(self, messages: list[ConversationRow]):
                 contact_name = self.contact.name
             elif msg.kind == KindConstant.GC_MSG:
                 kind = 'incoming'
+                if contact_name is None:
+                    # Fall back to MUC name if contact name is None
+                    # (may be the case for service messages from the MUC)
+                    contact_name = self.contact.name
             elif msg.kind in (
                     KindConstant.SINGLE_MSG_SENT, KindConstant.CHAT_MSG_SENT):
                 kind = 'outgoing'
@@ -738,6 +742,8 @@ def add_messages(self, messages: list[ConversationRow]):
                 log.warning('kind attribute could not be processed'
                             'while adding message')
 
+            assert contact_name is not None
+
             if msg.additional_data is not None:
                 retracted_by = msg.additional_data.get_value('retracted', 'by')
                 if retracted_by is not None:



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/bc14c535134510e0bd382314188b0b9ca52239ec
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to