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:
@@ -44,11 +44,11 @@ export const jidDecode = (jid: string | undefined): FullJid | undefined => {
|
||||
/** is the jid a user */
|
||||
export const areJidsSameUser = (jid1: string | undefined, jid2: string | undefined) =>
|
||||
jidDecode(jid1)?.user === jidDecode(jid2)?.user
|
||||
/** is the jid Meta IA */
|
||||
export const isJidMetaIa = (jid: string | undefined) => jid?.endsWith('@bot')
|
||||
/** is the jid a user */
|
||||
export const isJidUser = (jid: string | undefined) => jid?.endsWith('@s.whatsapp.net')
|
||||
/** is the jid a group */
|
||||
/** is the jid Meta AI */
|
||||
export const isJidMetaAI = (jid: string | undefined) => jid?.endsWith('@bot')
|
||||
/** is the jid a PN user */
|
||||
export const isPnUser = (jid: string | undefined) => jid?.endsWith('@s.whatsapp.net')
|
||||
/** is the jid a LID */
|
||||
export const isLidUser = (jid: string | undefined) => jid?.endsWith('@lid')
|
||||
/** is the jid a broadcast */
|
||||
export const isJidBroadcast = (jid: string | undefined) => jid?.endsWith('@broadcast')
|
||||
@@ -72,3 +72,10 @@ export const jidNormalizedUser = (jid: string | undefined) => {
|
||||
const { user, server } = result
|
||||
return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : (server as JidServer))
|
||||
}
|
||||
|
||||
export const transferDevice = (fromJid: string, toJid: string) => {
|
||||
const fromDecoded = jidDecode(fromJid)
|
||||
const deviceId = fromDecoded?.device || 0
|
||||
const { server, user } = jidDecode(toJid)!
|
||||
return jidEncode(user, server, deviceId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user