diff --git a/src/matrixHelper.py b/src/matrixHelper.py index 121d5f1..79bb5a8 100644 --- a/src/matrixHelper.py +++ b/src/matrixHelper.py @@ -20,6 +20,25 @@ class MatrixAdminClient: class MatrixHelper: + + ROOM_POWER_LEVEL_EVENTS = { + "m.room.encryption": 200, + "m.room.avatar": 50, + "m.room.name": 50, + "m.room.canonical_alias": 50, + "m.space.child": 50, + "m.room.history_visibility": 50, + "m.room.power_levels": 50, + "m.room.topic": 50, + "m.room.tombstone": 50, + "m.room.server_acl": 50, + "m.room.pinned_events": 50, + "m.reaction": 0, + "m.room.redaction": 0, + "im.vector.modular.widgets": 50, + "io.element.voice_broadcast_info": 50 + } + def __init__(self, server: str, username, space_id: str, matrix_username: str) -> None: self._client = nio.AsyncClient(server, username) self._loggedIn = False @@ -76,6 +95,8 @@ class MatrixHelper: { "type": "m.room.power_levels", "content": { + "events": MatrixHelper.ROOM_POWER_LEVEL_EVENTS, + "invite": 50, "users": { self._matrix_username: 200, } @@ -140,13 +161,16 @@ class MatrixHelper: if power_level != 100 and power_level != 50 and power_level != 0: return False - users = await self.get_room_power_levels(room) users[user] = power_level if not self._matrix_username in users: users[self._matrix_username] = 200 - - return await self._client.room_put_state(room, "m.room.power_levels", { + result = await self._client.room_put_state(room, "m.room.power_levels", { + "events": MatrixHelper.ROOM_POWER_LEVEL_EVENTS, + "invite": 50, "users": users }) + assert result.event_id is not None + + return True