Skip to content

Commit

Permalink
changes as discussed
Browse files Browse the repository at this point in the history
  • Loading branch information
maltee1 committed May 4, 2022
1 parent c5c0d7a commit b6862c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion mausignald/signald.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ async def create_group(
"title": title,
"members": [addr.serialize() for addr in members],
}
create_params = {k: v for k, v in create_params.items() if v}
create_params = {k: v for k, v in create_params.items() if v is not None}
resp = await self.request_v1("create_group", account=username, **create_params)
if "id" not in resp:
return None
Expand Down
28 changes: 16 additions & 12 deletions mautrix_signal/commands/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ async def create(evt: CommandEvent) -> EventID:
title, about, levels, encrypted, avatar_url = await get_initial_state(
evt.az.intent, evt.room_id
)
# if not title:
# return await evt.reply("Please set a title before creating a Telegram chat.")

portal = po.Portal(
chat_id=GroupID(""),
Expand All @@ -316,7 +314,22 @@ async def create(evt: CommandEvent) -> EventID:
avatar_url=avatar_url,
)

await warn_missing_power(levels, evt)
if levels.get_user_level(evt.az.bot_mxid) < 51:
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})"
)
if levels.state_default < 50 and (
levels.events[EventType.ROOM_NAME] >= 50
or levels.events[EventType.ROOM_AVATAR] >= 50
or levels.events[EventType.ROOM_TOPIC] >= 50
):
await evt.reply(
"Warning: Permissions for changing name, topic and avatar cannot be set separately on Signal."
"name, room and avatar changes will not be bridged properly, unless those permissions are"
"set to the same level or lower than state_default"
)

try:
await portal.create_signal_group(evt.sender, levels)
Expand Down Expand Up @@ -353,12 +366,3 @@ async def get_initial_state(
# Some state event probably has empty content
pass
return title, about, levels, encrypted, avatar_url


async def warn_missing_power(levels: PowerLevelStateEventContent, evt: CommandEvent) -> None:
if levels.get_user_level(evt.az.bot_mxid) < levels.redact:
await evt.reply(
"Warning: The bot does not have privileges to redact messages on Matrix. "
"Message deletions from Signal will not be bridged unless you give "
f"redaction permissions to [{evt.az.bot_mxid}](https://matrix.to/#/{evt.az.bot_mxid})"
)
6 changes: 0 additions & 6 deletions mautrix_signal/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,12 +1254,6 @@ async def create_signal_group(
puppet = await p.Puppet.get_by_mxid(mxid, create=False)
if puppet:
invitee_addresses.append(puppet.address)
if len(invitee_addresses) == 0:
raise ValueError(
"Not enough Signal users to create a chat. "
"Invite more Signal ghost users to the room"
)
return
avatar_path: str | None = None
if self.avatar_url:
avatar_data = await self.az.intent.download_media(self.avatar_url)
Expand Down

0 comments on commit b6862c0

Please sign in to comment.