diff sat/plugins/plugin_sec_aesgcm.py @ 4023:78b5f356900c

component AP gateway: handle attachments
author Goffi <goffi@goffi.org>
date Thu, 23 Mar 2023 15:42:21 +0100
parents 0ff265725489
children 524856bd7b19
line wrap: on
line diff
--- a/sat/plugins/plugin_sec_aesgcm.py	Thu Mar 23 15:39:48 2023 +0100
+++ b/sat/plugins/plugin_sec_aesgcm.py	Thu Mar 23 15:42:21 2023 +0100
@@ -156,7 +156,7 @@
         # TODO: this is to be removed when a better mechanism is available with OMEMO (now
         #   possible with the 0.4 version of OMEMO, it's possible to encrypt other stanza
         #   elements than body).
-        attachments = data["extra"][C.MESS_KEY_ATTACHMENTS]
+        attachments = data["extra"][C.KEY_ATTACHMENTS]
         if not data['message'] or data['message'] == {'': ''}:
             extra_attachments = attachments[1:]
             del attachments[1:]
@@ -165,7 +165,7 @@
             # we have a message, we must send first attachment separately
             extra_attachments = attachments[:]
             attachments.clear()
-            del data["extra"][C.MESS_KEY_ATTACHMENTS]
+            del data["extra"][C.KEY_ATTACHMENTS]
 
         body_elt = data["xml"].body
         if body_elt is None:
@@ -181,7 +181,7 @@
                 message={'': ''},
                 subject=data['subject'],
                 mess_type=data['type'],
-                extra={C.MESS_KEY_ATTACHMENTS: [attachment]},
+                extra={C.KEY_ATTACHMENTS: [attachment]},
             )
 
         if ((not data['extra']
@@ -299,7 +299,7 @@
                 else:
                     data['message'][lang] = message
                 mess_encrypted = client.encryption.isEncrypted(data)
-                attachments = data['extra'].setdefault(C.MESS_KEY_ATTACHMENTS, [])
+                attachments = data['extra'].setdefault(C.KEY_ATTACHMENTS, [])
                 for link in links:
                     path = parse.urlparse(link).path
                     attachment = {
@@ -307,7 +307,7 @@
                     }
                     media_type = mimetypes.guess_type(path, strict=False)[0]
                     if media_type is not None:
-                        attachment[C.MESS_KEY_ATTACHMENTS_MEDIA_TYPE] = media_type
+                        attachment[C.KEY_ATTACHMENTS_MEDIA_TYPE] = media_type
 
                     if mess_encrypted:
                         # we don't add the encrypted flag if the message itself is not