فهرست منبع

Add support for sending giphy gifs with custom field

Tulir Asokan 3 سال پیش
والد
کامیت
f5ae68e77b
2فایلهای تغییر یافته به همراه30 افزوده شده و 1 حذف شده
  1. 11 1
      mauigpapi/http/thread.py
  2. 19 0
      mautrix_instagram/portal.py

+ 11 - 1
mauigpapi/http/thread.py

@@ -120,7 +120,17 @@ class ThreadAPI(BaseAndroidAPI):
             response_type=Thread,
         )
 
-    async def approve_thread(self, thread_ids: list[int | str]) -> None:
+    async def approve_thread(self, thread_id: int | str) -> None:
+        await self.std_http_post(
+            f"/api/v1/direct_v2/threads/{thread_id}/approve/",
+            data={
+                "filter": "DEFAULT",
+                "_uuid": self.state.device.uuid,
+            },
+            raw=True,
+        )
+
+    async def approve_threads(self, thread_ids: list[int | str]) -> None:
         await self.std_http_post(
             "/api/v1/direct_v2/threads/approve_multiple/",
             data={

+ 19 - 0
mautrix_instagram/portal.py

@@ -286,6 +286,21 @@ class Portal(DBPortal, BasePortal):
                 confirmed=True,
             )
 
+    async def _handle_matrix_giphy(
+        self,
+        sender: u.User,
+        event_id: EventID,
+        request_id: str,
+        giphy_id: str,
+    ) -> CommandResponse:
+        self.log.trace(f"Broadcasting giphy from {event_id} with request ID {request_id}")
+        return await sender.client.broadcast(
+            self.thread_id,
+            ThreadItemType.ANIMATED_MEDIA,
+            client_context=request_id,
+            id=giphy_id,
+        )
+
     async def _handle_matrix_image(
         self,
         sender: u.User,
@@ -418,6 +433,10 @@ class Portal(DBPortal, BasePortal):
             resp = await sender.mqtt.send_text(
                 self.thread_id, text=text, urls=urls, client_context=request_id, **reply_to
             )
+        elif message.msgtype.is_media and "fi.mau.instagram.giphy_id" in message:
+            resp = await self._handle_matrix_giphy(
+                sender, event_id, request_id, message["fi.mau.instagram.giphy_id"]
+            )
         elif message.msgtype.is_media:
             if message.file and decrypt_attachment:
                 data = await self.main_intent.download_media(message.file.url)