Merge branch 'fix-power-levels-dm-room' into 'master'
Grants admin rights when creating dm room See merge request Neutrinet/matrix-alertbot!14
This commit is contained in:
commit
949ace768a
2 changed files with 33 additions and 2 deletions
|
@ -236,7 +236,7 @@ class MatrixClientPool:
|
|||
) -> None:
|
||||
async with self._lock:
|
||||
if matrix_client is self.matrix_client:
|
||||
unactive_accounts = self.unactive_user_ids()
|
||||
unactive_user_ids = self.unactive_user_ids()
|
||||
|
||||
self.dm_rooms = await self.find_existing_dm_rooms(
|
||||
account=account, matrix_client=matrix_client, config=config
|
||||
|
@ -262,13 +262,16 @@ class MatrixClientPool:
|
|||
logger.info(
|
||||
f"Bot {account.id} | Creating direct room with user {user_id}"
|
||||
)
|
||||
invitations = unactive_accounts + [user_id]
|
||||
invitations = unactive_user_ids + [user_id]
|
||||
room_user_ids = invitations + [account.id]
|
||||
power_levels = {"users": dict.fromkeys(room_user_ids, 100)}
|
||||
create_room_response = await matrix_client.room_create(
|
||||
visibility=RoomVisibility.private,
|
||||
name=room_title,
|
||||
invite=invitations,
|
||||
is_direct=True,
|
||||
preset=RoomPreset.private_chat,
|
||||
power_level_override=power_levels,
|
||||
)
|
||||
if isinstance(create_room_response, RoomCreateError):
|
||||
error = create_room_response.message
|
||||
|
|
|
@ -476,6 +476,13 @@ class MatrixClientPoolTestCase(unittest.IsolatedAsyncioTestCase):
|
|||
invite=["@other_user:chat.example.com", "@fake_dm_user:example.com"],
|
||||
is_direct=True,
|
||||
preset=RoomPreset.private_chat,
|
||||
power_level_override={
|
||||
"users": {
|
||||
"@fake_user:matrix.example.com": 100,
|
||||
"@other_user:chat.example.com": 100,
|
||||
"@fake_dm_user:example.com": 100,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertDictEqual(
|
||||
{
|
||||
|
@ -528,6 +535,13 @@ class MatrixClientPoolTestCase(unittest.IsolatedAsyncioTestCase):
|
|||
invite=["@other_user:chat.example.com", "@fake_dm_user:example.com"],
|
||||
is_direct=True,
|
||||
preset=RoomPreset.private_chat,
|
||||
power_level_override={
|
||||
"users": {
|
||||
"@fake_user:matrix.example.com": 100,
|
||||
"@other_user:chat.example.com": 100,
|
||||
"@fake_dm_user:example.com": 100,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertDictEqual(
|
||||
{
|
||||
|
@ -581,6 +595,13 @@ class MatrixClientPoolTestCase(unittest.IsolatedAsyncioTestCase):
|
|||
invite=["@other_user:chat.example.com", "@fake_dm_user:example.com"],
|
||||
is_direct=True,
|
||||
preset=RoomPreset.private_chat,
|
||||
power_level_override={
|
||||
"users": {
|
||||
"@fake_user:matrix.example.com": 100,
|
||||
"@other_user:chat.example.com": 100,
|
||||
"@fake_dm_user:example.com": 100,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertDictEqual(
|
||||
{
|
||||
|
@ -631,6 +652,13 @@ class MatrixClientPoolTestCase(unittest.IsolatedAsyncioTestCase):
|
|||
invite=["@other_user:chat.example.com", "@fake_dm_user:example.com"],
|
||||
is_direct=True,
|
||||
preset=RoomPreset.private_chat,
|
||||
power_level_override={
|
||||
"users": {
|
||||
"@fake_user:matrix.example.com": 100,
|
||||
"@other_user:chat.example.com": 100,
|
||||
"@fake_dm_user:example.com": 100,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertDictEqual(
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue