Demote puppet users created by Matrix Bridges
How I fixed accidentally assigned power levels for puppet users controlled by a Matrix Bridge. I am currently a member of the AG Administration in the Hackerspace Bremen. We manage our own federated Matrix homeserver as part of the services we offer for our members. That service is relatively new, and we use mautrix-discord with double puppeting to bridge a few legacy rooms from Discord to corresponding Matrix rooms, so users that have not yet moved to Matrix are not left out. Messages written by these users in Discord are visible in Matrix rooms using puppet users automatically created by the bridge. Due to some carelessness on my part I accidentally gave one of the puppet users a power level of 100 in a bridged room. In Matrix, once another user has the same power level as you, you reach a ‘stalemate’ state in which it becomes impossible to demote that user to a lower power level again. Only the user itself is able to lower their own power level. While that had no immediate negative consequences for puppet users, which can (probably?) not do much with that power level anyway, it bugged me and I looked for ways to fix my mistake. Fortunately, Tulir was very helpful in It is possible to craft the required After installing the package, open an Verify that the client works correctly by attempting to find the rooms currently joined by the puppet user: Ensure those look correct. To change power levels in a room, a complete Filter out the event describing the current power levels: Modify the event and set the power level of the puppet user to 0: Finally, send the event back to the server: If everything worked correctly, the puppet user should be demoted back to power level 0.#discord:maunium.net
by pointing out that the bridge uses the Matrix Application Service API and the access token (as_token
) used by the bridge can be used to send events on behalf of all puppet users managed by the bridge.curl
calls by hand, but I decided to give mautrix-python (also by Tulir) a try. Below are the commands that finally worked.asyncio
shell (python -m asyncio
) and run these commands to create a ClientAPI
object. Adapt the values as necessary:>>>
>>> =
>>> =
>>> = # Taken from the bridges registration.yaml
>>> =
>>> await
m.room.power_levels
event must be sent to the room. It is easiest to get the current event and just change its current content.>>> =
>>> = await
>>>
22
>>> =
>>> = 0
>>>
>>> await