comparison sat/core/xmpp.py @ 3196:adf1aeaa0d37

core (constants): renamed `MESS_KEY_MEDIA_TYPE` to `MESS_KEY_ATTACHMENTS_MEDIA_TYPE`
author Goffi <goffi@goffi.org>
date Sat, 29 Feb 2020 16:55:22 +0100
parents e8ce30798d15
children f4a28767ec35
comparison
equal deleted inserted replaced
3195:29d72336a40d 3196:adf1aeaa0d37
1135 for attachment in data['extra'].get(C.MESS_KEY_ATTACHMENTS, []): 1135 for attachment in data['extra'].get(C.MESS_KEY_ATTACHMENTS, []):
1136 if "name" not in attachment: 1136 if "name" not in attachment:
1137 name = (Path(unquote(urlparse(attachment['url']).path)).name 1137 name = (Path(unquote(urlparse(attachment['url']).path)).name
1138 or C.FILE_DEFAULT_NAME) 1138 or C.FILE_DEFAULT_NAME)
1139 attachment["name"] = name 1139 attachment["name"] = name
1140 if C.MESS_KEY_MEDIA_TYPE not in attachment: 1140 if C.MESS_KEY_ATTACHMENTS_MEDIA_TYPE not in attachment:
1141 media_type = mimetypes.guess_type(attachment['name'], strict=False)[0] 1141 media_type = mimetypes.guess_type(attachment['name'], strict=False)[0]
1142 if media_type: 1142 if media_type:
1143 attachment[C.MESS_KEY_MEDIA_TYPE] = media_type 1143 attachment[C.MESS_KEY_ATTACHMENTS_MEDIA_TYPE] = media_type
1144 return data 1144 return data
1145 1145
1146 def skipEmptyMessage(self, data): 1146 def skipEmptyMessage(self, data):
1147 if not data["message"] and not data["extra"] and not data["subject"]: 1147 if not data["message"] and not data["extra"] and not data["subject"]:
1148 raise failure.Failure(exceptions.CancelError("Cancelled empty message")) 1148 raise failure.Failure(exceptions.CancelError("Cancelled empty message"))