Skip to content

Commit 211562f

Browse files
authored
Merge pull request #101 from maltee1/unban_reasons
allow providing reasons with unbans
2 parents 2241324 + ee8305a commit 211562f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

mautrix/client/api/rooms.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ async def ban_user(
581581
Method.POST, Path.v3.rooms[room_id].ban, {"user_id": user_id, "reason": reason}
582582
)
583583

584-
async def unban_user(self, room_id: RoomID, user_id: UserID) -> None:
584+
async def unban_user(self, room_id: RoomID, user_id: UserID, reason: str = "") -> None:
585585
"""
586586
Unban a user from the room. This allows them to be invited to the room, and join if they
587587
would otherwise be allowed to join according to its join rules. The caller must have the
@@ -592,8 +592,12 @@ async def unban_user(self, room_id: RoomID, user_id: UserID) -> None:
592592
Args:
593593
room_id: The ID of the room from which the user should be unbanned.
594594
user_id: The fully qualified user ID of the user being banned.
595+
reason: The reason the user has been unbanned. This will be supplied as the ``reason`` on
596+
the target's updated `m.room.member`_ event.
595597
"""
596-
await self.api.request(Method.POST, Path.v3.rooms[room_id].unban, {"user_id": user_id})
598+
await self.api.request(
599+
Method.POST, Path.v3.rooms[room_id].unban, {"user_id": user_id, "reason": reason}
600+
)
597601

598602
# endregion
599603

mautrix/client/store_updater.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ async def ban_user(
110110
if not extra_content and self.state_store:
111111
await self.state_store.set_membership(room_id, user_id, Membership.BAN)
112112

113-
async def unban_user(self, room_id: RoomID, user_id: UserID) -> None:
114-
await super().unban_user(room_id, user_id)
113+
async def unban_user(self, room_id: RoomID, user_id: UserID, reason: str = "") -> None:
114+
await super().unban_user(room_id, user_id, reason=reason)
115115
if self.state_store:
116116
await self.state_store.set_membership(room_id, user_id, Membership.LEAVE)
117117

0 commit comments

Comments
 (0)