diff --git a/src/Socket/groups.ts b/src/Socket/groups.ts index 2157206..8f2b39c 100644 --- a/src/Socket/groups.ts +++ b/src/Socket/groups.ts @@ -308,8 +308,14 @@ export const extractGroupMetadata = (result: BinaryNode) => { const descChild = getBinaryNodeChild(group, 'description') let desc: string | undefined let descId: string | undefined + let descOwner: string | undefined + let descOwnerJid: string | undefined + let descTime: number | undefined if (descChild) { desc = getBinaryNodeChildString(descChild, 'body') + descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined + descOwnerJid = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined + descTime = +descChild.attrs.t descId = descChild.attrs.id } @@ -321,12 +327,17 @@ export const extractGroupMetadata = (result: BinaryNode) => { addressingMode: group.attrs.addressing_mode as 'pn' | 'lid', subject: group.attrs.subject, subjectOwner: group.attrs.s_o, + subjectOwnerJid: group.attrs.s_o_pn, subjectTime: +group.attrs.s_t, size: getBinaryNodeChildren(group, 'participant').length, creation: +group.attrs.creation, owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined, + ownerJid: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined, desc, descId, + descOwner, + descOwnerJid, + descTime, linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined, restrict: !!getBinaryNodeChild(group, 'locked'), announce: !!getBinaryNodeChild(group, 'announcement'), @@ -337,6 +348,7 @@ export const extractGroupMetadata = (result: BinaryNode) => { participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => { return { id: attrs.jid, + jid: attrs.phone_number ? jidNormalizedUser(attrs.phone_number) : undefined, admin: (attrs.type || null) as GroupParticipant['admin'] } }), diff --git a/src/Types/GroupMetadata.ts b/src/Types/GroupMetadata.ts index 614d99e..14463e9 100644 --- a/src/Types/GroupMetadata.ts +++ b/src/Types/GroupMetadata.ts @@ -4,6 +4,7 @@ export type GroupParticipant = Contact & { isAdmin?: boolean isSuperAdmin?: boolean admin?: 'admin' | 'superadmin' | null + jid?: string | undefined } export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify' @@ -17,15 +18,19 @@ export interface GroupMetadata { /** group uses 'lid' or 'pn' to send messages */ addressingMode: 'pn' | 'lid' owner: string | undefined + ownerJid?: string | undefined subject: string /** group subject owner */ subjectOwner?: string + subjectOwnerJid?: string /** group subject modification date */ subjectTime?: number creation?: number desc?: string descOwner?: string + descOwnerJid?: string descId?: string + descTime?: number /** if this group is part of a community, it returns the jid of the community to which it belongs */ linkedParent?: string /** is set when the group only allows admins to change group settings */