ソースを参照

voice messages: bridge Signal voice messages to native Matrix messages

Sumner Evans 3 年 前
コミット
dfa574f75c
1 ファイル変更13 行追加1 行削除
  1. 13 1
      mautrix_signal/portal.py

+ 13 - 1
mautrix_signal/portal.py

@@ -856,10 +856,22 @@ class Portal(DBPortal, BasePortal):
         if attachment.blurhash:
             info["blurhash"] = attachment.blurhash
             info["xyz.amorgan.blurhash"] = attachment.blurhash
-        return MediaMessageEventContent(
+        content = MediaMessageEventContent(
             msgtype=msgtype, info=info, body=attachment.custom_filename
         )
 
+        # Add the additional voice message metadata.
+        if attachment.voice_note:
+            content["org.matrix.msc1767.file"] = {
+                "url": content.url,
+                "name": content.body,
+                **(content.file.serialize() if content.file else {}),
+                **(content.info.serialize() if content.info else {}),
+            }
+            content["org.matrix.msc3245.voice"] = {}
+
+        return content
+
     async def _handle_signal_attachment(
         self, intent: IntentAPI, attachment: Attachment, sticker: bool = False
     ) -> MediaMessageEventContent: