Эх сурвалжийг харах

Bridge leaving groups from Matrix to Signal (#245)

Malte E 3 жил өмнө
parent
commit
3cf270962d

+ 3 - 0
mausignald/signald.py

@@ -340,6 +340,9 @@ class SignaldClient(SignaldRPCClient):
         resp = await self.request_v1("join_group", account=username, uri=uri)
         return JoinGroupResponse.deserialize(resp)
 
+    async def leave_group(self, username: str, group_id: GroupID) -> None:
+        await self.request_v1("leave_group", account=username, groupID=group_id)
+
     async def update_group(
         self,
         username: str,

+ 1 - 0
mautrix_signal/config.py

@@ -104,6 +104,7 @@ class Config(BaseBridgeConfig):
 
         copy("bridge.relay.enabled")
         copy_dict("bridge.relay.message_formats")
+        copy("bridge.bridge_matrix_leave")
 
     def _get_permissions(self, key: str) -> Permissions:
         level = self["bridge.permissions"].get(key, "")

+ 2 - 0
mautrix_signal/example-config.yaml

@@ -194,6 +194,8 @@ bridge:
     resend_bridge_info: false
     # Interval at which to resync contacts (in seconds).
     periodic_sync: 0
+    # Should leaving the room on Matrix make the user leave on Signal?
+    bridge_matrix_leave: true
 
     # Provisioning API part of the web server for automated portal creation and fetching information.
     # Used by things like mautrix-manager (https://github.com/tulir/mautrix-manager).

+ 2 - 0
mautrix_signal/portal.py

@@ -720,6 +720,8 @@ class Portal(DBPortal, BasePortal):
                 await self.cleanup_and_delete()
         else:
             self.log.debug(f"{user.mxid} left portal to {self.chat_id}")
+            if self.config["bridge.bridge_matrix_leave"]:
+                await self.signal.leave_group(user.username, self.chat_id)
             # TODO cleanup if empty
 
     async def handle_matrix_name(self, user: u.User, name: str) -> None: