Skip to content

Commit 3a57847

Browse files
committed
Support admin join API
Signed-off-by: Gary Kim <[email protected]>
1 parent 6174c38 commit 3a57847

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/SynapseAdminApis.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,14 @@ export class SynapseAdminApis {
479479
public async makeRoomAdmin(roomId: string, userId?: string): Promise<void> {
480480
return this.client.doRequest("POST", `/_synapse/admin/v1/rooms/${encodeURIComponent(roomId)}/make_room_admin`, {}, { user_id: userId });
481481
}
482+
483+
/**
484+
* Joins a local user account to a room.
485+
* @param roomId The room to make the user join.
486+
* @param UserId The user to join into the room.
487+
* @returns Resolves when complete.
488+
*/
489+
public async joinUserToRoom(roomId: string, userId: string): Promise<void> {
490+
return this.client.doRequest("POST", `/_synapse/admin/v1/join/${encodeURIComponent(roomId)}`, {}, { user_id: userId });
491+
}
482492
}

test/SynapseAdminApisTest.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,5 +531,22 @@ describe('SynapseAdminApis', () => {
531531
await Promise.all([client.makeRoomAdmin(roomId, userId), http.flushAllExpected()]);
532532
});
533533
});
534+
535+
describe('addUserToRoom', () => {
536+
it('should call the right endpoint', async () => {
537+
const { client, http, hsUrl } = createTestSynapseAdminClient();
538+
539+
const roomId = "!room:example.org";
540+
const userId = "@alice:example.org";
541+
542+
http.when("POST", "/_synapse/admin/v1/join").respond(200, (path, content, req) => {
543+
expect(content).toMatchObject({ user_id: userId });
544+
expect(path).toEqual(`${hsUrl}/_synapse/admin/v1/join/${encodeURIComponent(roomId)}`);
545+
return {};
546+
});
547+
548+
await Promise.all([client.joinUserToRoom(roomId, userId), http.flushAllExpected()]);
549+
});
550+
});
534551
});
535552
});

0 commit comments

Comments
 (0)