Philipp Hörist pushed to branch master at gajim / gajim
Commits:
54c10fd2 by lovetox at 2022-07-25T18:32:48+02:00
refactor: Make sure we create valid contacts
- - - - -
c25510a8 by lovetox at 2022-07-25T18:39:44+02:00
fix: ChatControl: Don’t assume messages always have a resource
Fixes: #11042
- - - - -
2 changed files:
- gajim/common/modules/contacts.py
- gajim/gtk/controls/chat.py
Changes:
=====================================
gajim/common/modules/contacts.py
=====================================
@@ -282,6 +282,11 @@ def supports_video(self) -> bool:
return False
def add_resource(self, resource: str) -> ResourceContact:
+ assert resource is not None
+ # Check if resource is not None because not the whole
+ # codebase is type checked and it creates hard to track
+ # problems if we create a ResourceContact without resource
+
jid = self._jid.new_with(resource=resource)
assert isinstance(self._log, LogAdapter)
contact = ResourceContact(self._log, jid, self._account)
@@ -562,6 +567,11 @@ def is_groupchat(self) -> bool:
return True
def add_resource(self, resource: str) -> GroupchatParticipant:
+ assert resource is not None
+ # Check if resource is not None because not the whole
+ # codebase is type checked and it creates hard to track
+ # problems if we create a GroupchatParticipant without resource
+
jid = self._jid.new_with(resource=resource)
assert isinstance(self._log, LogAdapter)
contact = GroupchatParticipant(self._log, jid, self._account)
=====================================
gajim/gtk/controls/chat.py
=====================================
@@ -376,8 +376,12 @@ def _on_message_received(self, event:
events.MessageReceived) -> None:
if event.properties.is_sent_carbon:
kind = 'outgoing'
- resource_contact = self.contact.get_resource(event.resource)
- self.xml.phone_image.set_visible(resource_contact.is_phone)
+ visible = False
+ if event.resource is not None:
+ resource_contact = self.contact.get_resource(event.resource)
+ visible = resource_contact.is_phone
+
+ self.xml.phone_image.set_visible(visible)
self.add_message(event.msgtxt,
kind,
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/37c5aefc2f66f8add380c8c2a8816aad173831be...c25510a8328c78ed54c37d49ad368da4a4dd76c1
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/37c5aefc2f66f8add380c8c2a8816aad173831be...c25510a8328c78ed54c37d49ad368da4a4dd76c1
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