mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: extra metadata on groupMetadata (#1374)
This commit is contained in:
@@ -308,8 +308,14 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
const descChild = getBinaryNodeChild(group, 'description')
|
const descChild = getBinaryNodeChild(group, 'description')
|
||||||
let desc: string | undefined
|
let desc: string | undefined
|
||||||
let descId: string | undefined
|
let descId: string | undefined
|
||||||
|
let descOwner: string | undefined
|
||||||
|
let descOwnerJid: string | undefined
|
||||||
|
let descTime: number | undefined
|
||||||
if (descChild) {
|
if (descChild) {
|
||||||
desc = getBinaryNodeChildString(descChild, 'body')
|
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
|
descId = descChild.attrs.id
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,12 +327,17 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
addressingMode: group.attrs.addressing_mode as 'pn' | 'lid',
|
addressingMode: group.attrs.addressing_mode as 'pn' | 'lid',
|
||||||
subject: group.attrs.subject,
|
subject: group.attrs.subject,
|
||||||
subjectOwner: group.attrs.s_o,
|
subjectOwner: group.attrs.s_o,
|
||||||
|
subjectOwnerJid: group.attrs.s_o_pn,
|
||||||
subjectTime: +group.attrs.s_t,
|
subjectTime: +group.attrs.s_t,
|
||||||
size: getBinaryNodeChildren(group, 'participant').length,
|
size: getBinaryNodeChildren(group, 'participant').length,
|
||||||
creation: +group.attrs.creation,
|
creation: +group.attrs.creation,
|
||||||
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
||||||
|
ownerJid: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
||||||
desc,
|
desc,
|
||||||
descId,
|
descId,
|
||||||
|
descOwner,
|
||||||
|
descOwnerJid,
|
||||||
|
descTime,
|
||||||
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
||||||
restrict: !!getBinaryNodeChild(group, 'locked'),
|
restrict: !!getBinaryNodeChild(group, 'locked'),
|
||||||
announce: !!getBinaryNodeChild(group, 'announcement'),
|
announce: !!getBinaryNodeChild(group, 'announcement'),
|
||||||
@@ -337,6 +348,7 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
||||||
return {
|
return {
|
||||||
id: attrs.jid,
|
id: attrs.jid,
|
||||||
|
jid: attrs.phone_number ? jidNormalizedUser(attrs.phone_number) : undefined,
|
||||||
admin: (attrs.type || null) as GroupParticipant['admin']
|
admin: (attrs.type || null) as GroupParticipant['admin']
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export type GroupParticipant = Contact & {
|
|||||||
isAdmin?: boolean
|
isAdmin?: boolean
|
||||||
isSuperAdmin?: boolean
|
isSuperAdmin?: boolean
|
||||||
admin?: 'admin' | 'superadmin' | null
|
admin?: 'admin' | 'superadmin' | null
|
||||||
|
jid?: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify'
|
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify'
|
||||||
@@ -17,15 +18,19 @@ export interface GroupMetadata {
|
|||||||
/** group uses 'lid' or 'pn' to send messages */
|
/** group uses 'lid' or 'pn' to send messages */
|
||||||
addressingMode: 'pn' | 'lid'
|
addressingMode: 'pn' | 'lid'
|
||||||
owner: string | undefined
|
owner: string | undefined
|
||||||
|
ownerJid?: string | undefined
|
||||||
subject: string
|
subject: string
|
||||||
/** group subject owner */
|
/** group subject owner */
|
||||||
subjectOwner?: string
|
subjectOwner?: string
|
||||||
|
subjectOwnerJid?: string
|
||||||
/** group subject modification date */
|
/** group subject modification date */
|
||||||
subjectTime?: number
|
subjectTime?: number
|
||||||
creation?: number
|
creation?: number
|
||||||
desc?: string
|
desc?: string
|
||||||
descOwner?: string
|
descOwner?: string
|
||||||
|
descOwnerJid?: string
|
||||||
descId?: string
|
descId?: string
|
||||||
|
descTime?: number
|
||||||
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
||||||
linkedParent?: string
|
linkedParent?: string
|
||||||
/** is set when the group only allows admins to change group settings */
|
/** is set when the group only allows admins to change group settings */
|
||||||
|
|||||||
Reference in New Issue
Block a user