feat: extra metadata on groupMetadata (#1374)

This commit is contained in:
Nurutomo
2025-06-10 18:25:08 +07:00
committed by GitHub
parent bd53572e37
commit 99bbafeae5
2 changed files with 17 additions and 0 deletions

View File

@@ -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']
}
}),