telegram icon indicating copy to clipboard operation
telegram copied to clipboard

mautrix.errors.request.MForbidden: You don't have permission to remove ops level equal to your own

Open maltee1 opened this issue 3 years ago • 2 comments

Creating a telegram chat when both the bridge bot and myself have power level 100 gives the following error:

  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/bridge/commands/handler.py", line 489, in handle
    await self._run_handler(handler, evt)
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix_telegram/commands/handler.py", line 192, in _run_handler
    return await handler(evt)
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/bridge/commands/handler.py", line 338, in __call__
    return await self._handler(evt)
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix_telegram/commands/portal/create_chat.py", line 80, in create
    await portal.create_telegram_chat(evt.sender, invites=invites, supergroup=supergroup)
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix_telegram/portal.py", line 551, in create_telegram_chat
    await self.main_intent.set_power_levels(self.mxid, levels)
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 274, in set_power_levels
    response = await self.send_state_event(
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 135, in wrapper
    return await __method(*args, **kwargs)
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 393, in send_state_event
    return await super().send_state_event(room_id, event_type, content, state_key, **kwargs)
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/client/store_updater.py", line 143, in send_state_event
    event_id = await super().send_state_event(
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/client/api/events.py", line 357, in send_state_event
    resp = await self.api.request(
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/api.py", line 376, in request
    return await self._send(method, full_url, req_content, query_params, headers or {})
  File "/opt/mautrix-telegram/lib/python3.9/site-packages/mautrix/api.py", line 255, in _send
    raise make_request_error(
mautrix.errors.request.MForbidden: You don't have permission to remove ops level equal to your own

Most likely that's the bridge bot sending a request to reduce my power level. The function set_power_levels should not actually change any user levels but only set permissions if I'm not mistaken. There might be an issue with the power levels being fetched by get_power_levels, but that's just a guess so far. This is probably a mautrix-python bug because I've seen something similar in mautrix-signal, but the error message is from mautrix-telegram, so I'm filing it here.

maltee1 avatar Jun 13 '22 20:06 maltee1

You don't have permission to remove ops level equal to your own

This is an error message generated by Synapse. It occurs if you try to modify a power level in a room of a user that has the same power level as you.

Indeed, the Telegram bridge bot attempts to set others to the room to power level 0. I've worked around this bug by:

  1. Inviting the Telegram bridge bot to the Matrix room I want to bridge.
  2. Set the Telegram bridge's power level to 100.
  3. Demote myself to 75.
  4. Run !tg bridge.

Portaling the room then completes successfully.

anoadragon453 avatar Jun 14 '22 15:06 anoadragon453

Yeah, I missed the bit where it assigns 0 to levels.users. I included a fix in https://github.com/mautrix/telegram/pull/802 . We might actually want to print a warning for that, but I think that the bridge should not modify matrix power levels at all when chats are created from matrix. Instead, power levels should be bridged to telegram. A power level of 100 is not ideal because the bridge bot has no authority over such a user, but I think it's reasonable to be wanting to have that power level, particularly in a plumbed room, where Telegram is only one of several remote networks. Making matrix behave like Telegram simplifies several things, but it goes wrong once different bridges are competing for conflicting settings. And it hinders the experience on matrix, which is what we actually want to use.

maltee1 avatar Jun 14 '22 20:06 maltee1

Fixed in #802

maltee1 avatar Aug 31 '22 05:08 maltee1