From 4aaf7b6a482c455751f79484063b634877ca052a Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sun, 26 Sep 2021 23:15:57 +0530 Subject: [PATCH] fix group metadata fetch --- src/Socket/groups.ts | 8 ++++---- src/Socket/messages-recv.ts | 4 ++-- src/Types/GroupMetadata.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Socket/groups.ts b/src/Socket/groups.ts index 40eb113..f157684 100644 --- a/src/Socket/groups.ts +++ b/src/Socket/groups.ts @@ -12,16 +12,16 @@ const extractGroupMetadata = (result: BinaryNode) => { desc = getBinaryNodeChild(descChild, 'body')?.content as string descId = descChild.attrs.id } - + const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us') const metadata: GroupMetadata = { - id: jidEncode(jidDecode(group.attrs.id).user, 'g.us'), + id: groupId, subject: group.attrs.subject, creation: +group.attrs.creation, owner: group.attrs.creator, desc, descId, - restrict: !!getBinaryNodeChild(result, 'locked') ? 'true' : 'false', - announce: !!getBinaryNodeChild(result, 'announcement') ? 'true' : 'false', + restrict: !!getBinaryNodeChild(result, 'locked'), + announce: !!getBinaryNodeChild(result, 'announcement'), participants: getBinaryNodeChildren(group, 'participant').map( ({ attrs }) => { return { diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index a0c490f..d95e21e 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -155,11 +155,11 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { emitParticipantsUpdate('add') break case WAMessageStubType.GROUP_CHANGE_ANNOUNCE: - const announce = message.messageStubParameters[0] === 'on' ? 'true' : 'false' + const announce = message.messageStubParameters[0] === 'on' emitGroupUpdate({ announce }) break case WAMessageStubType.GROUP_CHANGE_RESTRICT: - const restrict = message.messageStubParameters[0] === 'on' ? 'true' : 'false' + const restrict = message.messageStubParameters[0] === 'on' emitGroupUpdate({ restrict }) break case WAMessageStubType.GROUP_CHANGE_SUBJECT: diff --git a/src/Types/GroupMetadata.ts b/src/Types/GroupMetadata.ts index 13b2442..baa5b96 100644 --- a/src/Types/GroupMetadata.ts +++ b/src/Types/GroupMetadata.ts @@ -13,9 +13,9 @@ export interface GroupMetadata { descOwner?: string descId?: string /** is set when the group only allows admins to change group settings */ - restrict?: 'true' | 'false' + restrict?: boolean /** is set when the group only allows admins to write messages */ - announce?: 'true' | 'false' + announce?: boolean // Baileys modified array participants: GroupParticipant[] ephemeralDuration?: number