# HG changeset patch # User Goffi # Date 1582046238 -3600 # Node ID 4b5c7767301516e7cddaba4c0f44499f7010d0a0 # Parent b9a2dd4d750afc04e2617962ba9ba2f32622f818 quick frontends (chat): handle attachments in Message diff -r b9a2dd4d750a -r 4b5c77673015 sat_frontends/quick_frontend/quick_chat.py --- a/sat_frontends/quick_frontend/quick_chat.py Tue Feb 18 18:17:18 2020 +0100 +++ b/sat_frontends/quick_frontend/quick_chat.py Tue Feb 18 18:17:18 2020 +0100 @@ -85,6 +85,9 @@ nick=self.nick, message=self.main_message) + def __contains__(self, item): + return hasattr(self, item) or item in self.extra + @property def host(self): return self.parent.host @@ -120,7 +123,9 @@ self.selected_lang = lang return mess except StopIteration: - log.error("Can't find message for uid {}".format(self.uid)) + if not self.attachments: + # we may have empty messages if we have attachments + log.error("Can't find message for uid {}".format(self.uid)) return "" @property @@ -200,6 +205,10 @@ for lang, mess in self.message.items(): self.message[lang] = "* " + nick + mess[3:] + @property + def attachments(self): + return self.extra.get(C.MESS_KEY_ATTACHMENTS) + class MessageWidget(object): """Base classe for widgets""" @@ -708,7 +717,8 @@ ) return - if not msg and not subject and type_ != C.MESS_TYPE_INFO: + if ((not msg and not subject and not extra[C.MESS_KEY_ATTACHMENTS] + and type_ != C.MESS_TYPE_INFO)): log.warning("Received an empty message for uid {}".format(uid)) return