From 3a5991ade5eae7b8964015729baf4033f06196ec Mon Sep 17 00:00:00 2001 From: "brobert (aider)" Date: Sun, 23 Mar 2025 23:37:59 +0100 Subject: [PATCH] fix: handle both string and object participant formats in community membership check --- src/utils/communityUtils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/communityUtils.ts b/src/utils/communityUtils.ts index a973a55..249faee 100644 --- a/src/utils/communityUtils.ts +++ b/src/utils/communityUtils.ts @@ -25,9 +25,15 @@ export async function isUserInCommunity(userJid: string, groupJids: Set) // Check if user is in this group's participants const participants = response.data?.participants || []; + console.log('Participants:', participants); + // Check both JID and phone number formats const userPhone = userJid.split('@')[0]; - if (participants.includes(userJid) || participants.some(p => p.startsWith(userPhone))) { + if (participants.some(p => { + // Handle both string and object participant formats + const participantJid = typeof p === 'string' ? p : p?.id; + return participantJid === userJid || participantJid?.startsWith?.(userPhone); + })) { return true; } }