Skip to content

Commit a92013a

Browse files
committed
Implement RoomInviter on client platform.
1 parent 1f4798e commit a92013a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Client/BotSDKBaseClient.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,25 @@ export class BotSDKBaseClient
169169
return await resolveRoomReferenceSafe(this.client, roomReference);
170170
}
171171

172+
public async inviteUser(
173+
room: MatrixRoomID | StringRoomID,
174+
userID: StringUserID,
175+
reason?: string
176+
): Promise<ActionResult<void>> {
177+
const roomID = room instanceof MatrixRoomID ? room.toRoomIDOrAlias() : room;
178+
return await this.client
179+
.doRequest(
180+
'POST',
181+
`/_matrix/client/v3/rooms/${encodeURIComponent(roomID)}/invite`,
182+
null,
183+
{
184+
user_id: userID,
185+
...(reason ? { reason } : {}),
186+
}
187+
)
188+
.then((_) => Ok(undefined), resultifyBotSDKRequestError);
189+
}
190+
172191
public async joinRoom(
173192
room: MatrixRoomReference | StringRoomID | StringRoomAlias,
174193
rawOptions?: { alwaysCallJoin?: boolean }

src/Client/BotSDKClientPlatform.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
RoomCreator,
99
RoomEventRedacter,
1010
RoomEventRelationsGetter,
11+
RoomInviter,
1112
RoomJoiner,
1213
RoomKicker,
1314
RoomMessageSender,
@@ -36,6 +37,9 @@ export class BotSDKClientPlatform implements ClientPlatform {
3637
toRoomCreator(): RoomCreator {
3738
return this.allClient;
3839
}
40+
toRoomInviter(): RoomInviter {
41+
return this.allClient;
42+
}
3943
toRoomJoiner(): RoomJoiner {
4044
return this.allClient;
4145
}

0 commit comments

Comments
 (0)