From 189140e1f92b9502d64fadcc1b0b0252bec68573 Mon Sep 17 00:00:00 2001 From: Sharon Kennedy Date: Wed, 27 May 2020 22:24:14 -0400 Subject: [PATCH] use room membership for chat invitations instead of community membership to fix presence bug --- src/bot.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/bot.js b/src/bot.js index efe4f8c..82c9046 100644 --- a/src/bot.js +++ b/src/bot.js @@ -109,11 +109,10 @@ class OcrccBot { let chatOffline = true; try { - const data = await this.client.getGroupUsers(this.config.FACILITATOR_GROUP_ID) - const members = data.chunk + const roomMembers = await this.client.getJoinedRoomMembers(this.config.FACILITATOR_ROOM_ID) + const members = Object.keys(roomMembers["joined"]); - members.forEach(member => { - const memberId = member.user_id; + members.forEach(memberId => { const user = this.client.getUser(memberId); if ( user && @@ -142,18 +141,17 @@ class OcrccBot { this.localStorage.removeItem(`${roomId}-waiting`) try { - const groupUsers = await this.client.getGroupUsers(this.config.FACILITATOR_GROUP_ID) - const roomMembers = await this.client.getJoinedRoomMembers(roomId) + const facilitatorsRoomMembers = await this.client.getJoinedRoomMembers(this.config.FACILITATOR_ROOM_ID) + const supportRoomMembers = await this.client.getJoinedRoomMembers(roomId) - const roomMemberIds = Object.keys(roomMembers["joined"]); - const groupMemberIds = groupUsers["chunk"] + const roomMembersIds = Object.keys(supportRoomMembers["joined"]); + const facilitatorsIds = Object.keys(facilitatorsRoomMembers["joined"]); - if (!roomMemberIds || !groupMemberIds) return; + if (!roomMembersIds || !facilitatorsIds) return; - const facilitatorsIds = groupMemberIds.map(f => f.user_id); facilitatorsIds.forEach(f => { - if (!roomMemberIds.includes(f)) { + if (!roomMembersIds.includes(f)) { this.kickUserFromRoom(roomId, f); } });