mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix group metadata fetch
This commit is contained in:
@@ -12,16 +12,16 @@ const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
desc = getBinaryNodeChild(descChild, 'body')?.content as string
|
desc = getBinaryNodeChild(descChild, 'body')?.content as string
|
||||||
descId = descChild.attrs.id
|
descId = descChild.attrs.id
|
||||||
}
|
}
|
||||||
|
const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us')
|
||||||
const metadata: GroupMetadata = {
|
const metadata: GroupMetadata = {
|
||||||
id: jidEncode(jidDecode(group.attrs.id).user, 'g.us'),
|
id: groupId,
|
||||||
subject: group.attrs.subject,
|
subject: group.attrs.subject,
|
||||||
creation: +group.attrs.creation,
|
creation: +group.attrs.creation,
|
||||||
owner: group.attrs.creator,
|
owner: group.attrs.creator,
|
||||||
desc,
|
desc,
|
||||||
descId,
|
descId,
|
||||||
restrict: !!getBinaryNodeChild(result, 'locked') ? 'true' : 'false',
|
restrict: !!getBinaryNodeChild(result, 'locked'),
|
||||||
announce: !!getBinaryNodeChild(result, 'announcement') ? 'true' : 'false',
|
announce: !!getBinaryNodeChild(result, 'announcement'),
|
||||||
participants: getBinaryNodeChildren(group, 'participant').map(
|
participants: getBinaryNodeChildren(group, 'participant').map(
|
||||||
({ attrs }) => {
|
({ attrs }) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -155,11 +155,11 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
emitParticipantsUpdate('add')
|
emitParticipantsUpdate('add')
|
||||||
break
|
break
|
||||||
case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
||||||
const announce = message.messageStubParameters[0] === 'on' ? 'true' : 'false'
|
const announce = message.messageStubParameters[0] === 'on'
|
||||||
emitGroupUpdate({ announce })
|
emitGroupUpdate({ announce })
|
||||||
break
|
break
|
||||||
case WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
case WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
||||||
const restrict = message.messageStubParameters[0] === 'on' ? 'true' : 'false'
|
const restrict = message.messageStubParameters[0] === 'on'
|
||||||
emitGroupUpdate({ restrict })
|
emitGroupUpdate({ restrict })
|
||||||
break
|
break
|
||||||
case WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
case WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ export interface GroupMetadata {
|
|||||||
descOwner?: string
|
descOwner?: string
|
||||||
descId?: string
|
descId?: 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 */
|
||||||
restrict?: 'true' | 'false'
|
restrict?: boolean
|
||||||
/** is set when the group only allows admins to write messages */
|
/** is set when the group only allows admins to write messages */
|
||||||
announce?: 'true' | 'false'
|
announce?: boolean
|
||||||
// Baileys modified array
|
// Baileys modified array
|
||||||
participants: GroupParticipant[]
|
participants: GroupParticipant[]
|
||||||
ephemeralDuration?: number
|
ephemeralDuration?: number
|
||||||
|
|||||||
Reference in New Issue
Block a user