lid, wip: Support LIDs in Baileys (#1747)
* lid-mapping: get missing lid from usync * lid-mapping, jid-utils: change to isPnUser and store multiple mappings * process-message: parse protocolMsg mapping, and store from new msgs * types: lid-mapping event, addressing enum, alt, contact, group types * validate, decode: use lid for identity, better logic * lid: final commit * linting * linting * linting * linting * misc: fix testing and also remove version json * lint: IDE fucking up lint * lid-mapping: fix build error on NPM * message-retry: fix proto import
This commit is contained in:
+11
-10
@@ -1,14 +1,14 @@
|
||||
import { proto } from '../../WAProto/index.js'
|
||||
import type { GroupMetadata, GroupParticipant, ParticipantAction, SocketConfig, WAMessageKey } from '../Types'
|
||||
import { WAMessageStubType } from '../Types'
|
||||
import { WAMessageAddressingMode, WAMessageStubType } from '../Types'
|
||||
import { generateMessageIDV2, unixTimestampSeconds } from '../Utils'
|
||||
import {
|
||||
type BinaryNode,
|
||||
getBinaryNodeChild,
|
||||
getBinaryNodeChildren,
|
||||
getBinaryNodeChildString,
|
||||
isJidUser,
|
||||
isLidUser,
|
||||
isPnUser,
|
||||
jidEncode,
|
||||
jidNormalizedUser
|
||||
} from '../WABinary'
|
||||
@@ -305,12 +305,12 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
||||
let desc: string | undefined
|
||||
let descId: string | undefined
|
||||
let descOwner: string | undefined
|
||||
let descOwnerJid: string | undefined
|
||||
let descOwnerPn: 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
|
||||
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined
|
||||
descTime = +descChild.attrs.t!
|
||||
descId = descChild.attrs.id
|
||||
}
|
||||
@@ -320,20 +320,21 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
||||
const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add'
|
||||
const metadata: GroupMetadata = {
|
||||
id: groupId!,
|
||||
addressingMode: group.attrs.addressing_mode as 'pn' | 'lid',
|
||||
notify: group.attrs.notify,
|
||||
addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
|
||||
subject: group.attrs.subject!,
|
||||
subjectOwner: group.attrs.s_o,
|
||||
subjectOwnerJid: group.attrs.s_o_pn,
|
||||
subjectOwnerPn: group.attrs.s_o_pn,
|
||||
subjectTime: +group.attrs.s_t!,
|
||||
size: group.attrs.size ? +group.attrs.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,
|
||||
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
||||
owner_country_code: group.attrs.creator_country_code,
|
||||
desc,
|
||||
descId,
|
||||
descOwner,
|
||||
descOwnerJid,
|
||||
descOwnerPn,
|
||||
descTime,
|
||||
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
||||
restrict: !!getBinaryNodeChild(group, 'locked'),
|
||||
@@ -345,8 +346,8 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
||||
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
||||
return {
|
||||
id: attrs.jid!,
|
||||
jid: isJidUser(attrs.jid) ? attrs.jid : jidNormalizedUser(attrs.phone_number),
|
||||
lid: isLidUser(attrs.jid) ? attrs.jid : attrs.lid,
|
||||
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phoneNumber) ? attrs.phoneNumber : undefined,
|
||||
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
||||
admin: (attrs.type || null) as GroupParticipant['admin']
|
||||
}
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user