Skip to content

Commit

Permalink
changes as per tulir
Browse files Browse the repository at this point in the history
  • Loading branch information
maltee1 committed May 12, 2022
1 parent 1f72a0a commit 85ab763
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions mautrix_signal/commands/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,13 @@ async def create(evt: CommandEvent) -> EventID:
receiver="",
avatar_url=avatar_url,
)

if levels.get_user_level(evt.az.bot_mxid) < 51:
bot_pl = levels.get_user_level(evt.az.bot_mxid)
if bot_pl < 51 or bot_pl < levels.events[EventType.ROOM_POWER_LEVELS]:
await evt.reply(
"Warning: The bot does not have privileges to demote moderators on Matrix. "
"Demotions from ADMINISTRATOR to DEFAULT will not be bridged unless you give "
f"redaction permissions to [{evt.az.bot_mxid}](https://matrix.to/#/{evt.az.bot_mxid})"
"Warning: The bot does not have sufficient privileges to change power levels on Matrix. "
"Power level changes will not be bridged properly unless you give power level 51 or higher"
f"to [{evt.az.bot_mxid}](https://matrix.to/#/{evt.az.bot_mxid}) and ensure it has sufficient"
"power level to change power levels"
)
if levels.state_default < 50 and (
levels.events[EventType.ROOM_NAME] >= 50
Expand All @@ -331,12 +332,8 @@ async def create(evt: CommandEvent) -> EventID:
"set to the same level or lower than state_default"
)

try:
await portal.create_signal_group(evt.sender, levels)
except ValueError as e:
await portal.delete()
return await evt.reply(e.args[0])
return await evt.reply(f"Signal chat created. ID: {portal.chat_id}")
await portal.create_signal_group(evt.sender, levels)
await evt.reply(f"Signal chat created. ID: {portal.chat_id}")


async def get_initial_state(
Expand Down
4 changes: 2 additions & 2 deletions mautrix_signal/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,8 @@ async def create_signal_group(
signal_chat = await self.signal.create_group(
source.username, title=self.name, members=invitee_addresses, avatar_path=avatar_path
)
await self._postinit()
await self.insert()
if avatar_path and self.config["signal.remove_file_after_handling"]:
try:
os.remove(avatar_path)
Expand Down Expand Up @@ -1295,8 +1297,6 @@ async def create_signal_group(
link=None,
),
)
await self._postinit()
await self.insert()
await self.update_bridge_info()

# endregion
Expand Down

0 comments on commit 85ab763

Please sign in to comment.