Skip to content

Commit

Permalink
Add default relaybot config option (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
maltee1 authored Aug 23, 2022
1 parent b4ecedf commit 56c96d4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions mautrix_signal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def do_update(self, helper: ConfigUpdateHelper) -> None:

copy("bridge.relay.enabled")
copy_dict("bridge.relay.message_formats")
copy("bridge.relay.relaybot")
copy("bridge.bridge_matrix_leave")
copy("bridge.location_format")

Expand Down
4 changes: 4 additions & 0 deletions mautrix_signal/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ bridge:
m.audio: '$sender_displayname sent an audio file'
m.video: '$sender_displayname sent a video'
m.location: '$sender_displayname sent a location'
# Specify a dedicated relay account. Must be a regular matrix account logged into this bridge
# and double puppeting working to auto-accept invites. When this user is invited to a room
# it will automatically be set as the relay user. May be overridden with `set-relay` or `unset-relay`
relaybot: '@relaybot:example.com'

# Format for generting URLs from location messages for sending to Signal
# Google Maps: 'https://www.google.com/maps/place/{lat},{long}'
Expand Down
13 changes: 13 additions & 0 deletions mautrix_signal/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,19 @@ async def handle_matrix_invite(self, invited_by: u.User, user: u.User | p.Puppet
)
except RPCError as e:
raise RejectMatrixInvite(str(e)) from e
if user.mxid == self.config["bridge.relay.relaybot"] != "@relaybot:example.com":
if not self.config["bridge.relay.enabled"]:
await self.main_intent.send_notice(
self.mxid, "Relay mode is not enabled in this instance of the bridge."
)
else:
await self.set_relay_user(user)
await self.main_intent.send_notice(
self.mxid,
"Messages from non-logged-in users in this room will now be bridged "
"through the relaybot's Signal account.",
)

power_levels = await self.main_intent.get_power_levels(self.mxid)
invitee_pl = power_levels.get_user_level(user.mxid)
if invitee_pl >= 50:
Expand Down

0 comments on commit 56c96d4

Please sign in to comment.