quick frontends (chat): handle attachments in Message
This commit is contained in:
parent
576c319d6e
commit
8812915d4e
1 changed files with 12 additions and 2 deletions
|
|
@ -85,6 +85,9 @@ class Message:
|
|||
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 @@ class Message:
|
|||
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 @@ class Message:
|
|||
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 @@ class QuickChat(quick_widgets.QuickWidget):
|
|||
)
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue