use room membership for chat invitations instead of community membership to fix presence bug

This commit is contained in:
Sharon Kennedy 2020-05-27 22:24:14 -04:00
parent cb4282999a
commit 189140e1f9

View File

@ -109,11 +109,10 @@ class OcrccBot {
let chatOffline = true; let chatOffline = true;
try { try {
const data = await this.client.getGroupUsers(this.config.FACILITATOR_GROUP_ID) const roomMembers = await this.client.getJoinedRoomMembers(this.config.FACILITATOR_ROOM_ID)
const members = data.chunk const members = Object.keys(roomMembers["joined"]);
members.forEach(member => { members.forEach(memberId => {
const memberId = member.user_id;
const user = this.client.getUser(memberId); const user = this.client.getUser(memberId);
if ( if (
user && user &&
@ -142,18 +141,17 @@ class OcrccBot {
this.localStorage.removeItem(`${roomId}-waiting`) this.localStorage.removeItem(`${roomId}-waiting`)
try { try {
const groupUsers = await this.client.getGroupUsers(this.config.FACILITATOR_GROUP_ID) const facilitatorsRoomMembers = await this.client.getJoinedRoomMembers(this.config.FACILITATOR_ROOM_ID)
const roomMembers = await this.client.getJoinedRoomMembers(roomId) const supportRoomMembers = await this.client.getJoinedRoomMembers(roomId)
const roomMemberIds = Object.keys(roomMembers["joined"]); const roomMembersIds = Object.keys(supportRoomMembers["joined"]);
const groupMemberIds = groupUsers["chunk"] 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 => { facilitatorsIds.forEach(f => {
if (!roomMemberIds.includes(f)) { if (!roomMembersIds.includes(f)) {
this.kickUserFromRoom(roomId, f); this.kickUserFromRoom(roomId, f);
} }
}); });