Mercurial > libervia-backend
diff sat_frontends/quick_frontend/quick_chat.py @ 3176:4b5c77673015
quick frontends (chat): handle attachments in Message
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 18 Feb 2020 18:17:18 +0100 |
parents | 39d7327583e1 |
children | 2556eb576aed |
line wrap: on
line diff
--- 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