feat: DELETE /api/v3/chats/:roomId/users and DELETE /api/v3/chats/:roomId/users/:uid

This commit is contained in:
Julian Lam
2021-12-22 09:58:52 -05:00
parent 6294beea0b
commit fe17c94c35
9 changed files with 121 additions and 19 deletions

View File

@@ -101,3 +101,15 @@ chatsAPI.invite = async (caller, data) => {
delete data.uids;
return chatsAPI.users(caller, data);
};
chatsAPI.kick = async (caller, data) => {
const uidsExist = await user.exists(data.uids);
if (!uidsExist.every(Boolean)) {
throw new Error('[[error:no-user]]');
}
await messaging.removeUsersFromRoom(caller.uid, data.uids, data.roomId);
delete data.uids;
return chatsAPI.users(caller, data);
};