Mercurial > libervia-backend
diff sat/core/xmpp.py @ 4023:78b5f356900c
component AP gateway: handle attachments
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 23 Mar 2023 15:42:21 +0100 |
parents | 412b99c29d83 |
children | 524856bd7b19 |
line wrap: on
line diff
--- a/sat/core/xmpp.py Thu Mar 23 15:39:48 2023 +0100 +++ b/sat/core/xmpp.py Thu Mar 23 15:42:21 2023 +0100 @@ -821,7 +821,7 @@ """Return True if a message contain payload to show in frontends""" return ( mess_data["message"] or mess_data["subject"] - or mess_data["extra"].get(C.MESS_KEY_ATTACHMENTS) + or mess_data["extra"].get(C.KEY_ATTACHMENTS) or mess_data["type"] == C.MESS_TYPE_INFO ) @@ -1361,16 +1361,16 @@ def completeAttachments(self, data): """Complete missing metadata of attachments""" - for attachment in data['extra'].get(C.MESS_KEY_ATTACHMENTS, []): + for attachment in data['extra'].get(C.KEY_ATTACHMENTS, []): if "name" not in attachment and "url" in attachment: name = (Path(unquote(urlparse(attachment['url']).path)).name or C.FILE_DEFAULT_NAME) attachment["name"] = name - if ((C.MESS_KEY_ATTACHMENTS_MEDIA_TYPE not in attachment + if ((C.KEY_ATTACHMENTS_MEDIA_TYPE not in attachment and "name" in attachment)): media_type = mimetypes.guess_type(attachment['name'], strict=False)[0] if media_type: - attachment[C.MESS_KEY_ATTACHMENTS_MEDIA_TYPE] = media_type + attachment[C.KEY_ATTACHMENTS_MEDIA_TYPE] = media_type return data