Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/SynapseAdminApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,14 @@ export class SynapseAdminApis {
public async makeRoomAdmin(roomId: string, userId?: string): Promise<void> {
return this.client.doRequest("POST", `/_synapse/admin/v1/rooms/${encodeURIComponent(roomId)}/make_room_admin`, {}, { user_id: userId });
}

/**
* Joins a local user account to a room.
* @param roomId The room to make the user join.
* @param UserId The user to join into the room.
* @returns Resolves when complete.
*/
public async joinUserToRoom(roomId: string, userId: string): Promise<void> {
return this.client.doRequest("POST", `/_synapse/admin/v1/join/${encodeURIComponent(roomId)}`, {}, { user_id: userId });
}
}
17 changes: 17 additions & 0 deletions test/SynapseAdminApisTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,22 @@ describe('SynapseAdminApis', () => {
await Promise.all([client.makeRoomAdmin(roomId, userId), http.flushAllExpected()]);
});
});

describe('joinUserToRoom', () => {
it('should call the right endpoint', async () => {
const { client, http, hsUrl } = createTestSynapseAdminClient();

const roomId = "!room:example.org";
const userId = "@alice:example.org";

http.when("POST", "/_synapse/admin/v1/join").respond(200, (path, content, req) => {
expect(content).toMatchObject({ user_id: userId });
expect(path).toEqual(`${hsUrl}/_synapse/admin/v1/join/${encodeURIComponent(roomId)}`);
return {};
});

await Promise.all([client.joinUserToRoom(roomId, userId), http.flushAllExpected()]);
});
});
});
});