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:
@@ -1,10 +1,10 @@
|
||||
export interface Contact {
|
||||
/** ID either in lid or jid format **/
|
||||
/** ID either in lid or jid format (preferred) **/
|
||||
id: string
|
||||
/** ID in Lid (anonymous) format (@lid) **/
|
||||
/** ID in LID format (@lid) **/
|
||||
lid?: string
|
||||
/** ID in Phone Number format (@s.whatsapp.net) **/
|
||||
jid?: string
|
||||
/** ID in PN format (@s.whatsapp.net) **/
|
||||
phoneNumber?: string
|
||||
/** name of the contact, you have saved on your WA */
|
||||
name?: string
|
||||
/** name of the contact, the contact has set on their own on WA */
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ export type BaileysEventMap = {
|
||||
'chats.upsert': Chat[]
|
||||
/** update the given chats */
|
||||
'chats.update': ChatUpdate[]
|
||||
'chats.phoneNumberShare': { lid: string; jid: string }
|
||||
'lid-mapping.update': { lid: string; pn: string }
|
||||
/** delete chats with given ID */
|
||||
'chats.delete': string[]
|
||||
/** presence of contact in a chat updated */
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Contact } from './Contact'
|
||||
import type { WAMessageAddressingMode } from './Message'
|
||||
|
||||
export type GroupParticipant = Contact & {
|
||||
isAdmin?: boolean
|
||||
@@ -14,21 +15,22 @@ export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin
|
||||
|
||||
export interface GroupMetadata {
|
||||
id: string
|
||||
notify?: string
|
||||
/** group uses 'lid' or 'pn' to send messages */
|
||||
addressingMode: 'pn' | 'lid'
|
||||
addressingMode?: WAMessageAddressingMode
|
||||
owner: string | undefined
|
||||
ownerJid?: string | undefined
|
||||
ownerPn?: string | undefined
|
||||
owner_country_code?: string | undefined
|
||||
subject: string
|
||||
/** group subject owner */
|
||||
subjectOwner?: string
|
||||
subjectOwnerJid?: string
|
||||
subjectOwnerPn?: string
|
||||
/** group subject modification date */
|
||||
subjectTime?: number
|
||||
creation?: number
|
||||
desc?: string
|
||||
descOwner?: string
|
||||
descOwnerJid?: string
|
||||
descOwnerPn?: string
|
||||
descId?: string
|
||||
descTime?: number
|
||||
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
||||
|
||||
@@ -14,12 +14,10 @@ export type WAMessageContent = proto.IMessage
|
||||
export type WAContactMessage = proto.Message.IContactMessage
|
||||
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
|
||||
export type WAMessageKey = proto.IMessageKey & {
|
||||
senderLid?: string
|
||||
remoteJidAlt?: string
|
||||
participantAlt?: string
|
||||
server_id?: string
|
||||
senderPn?: string
|
||||
participantLid?: string
|
||||
participantPn?: string
|
||||
isViewOnce?: boolean
|
||||
isViewOnce?: boolean // TODO: remove out of the message key, place in WebMessageInfo
|
||||
}
|
||||
export type WATextMessage = proto.Message.IExtendedTextMessage
|
||||
export type WAContextInfo = proto.IContextInfo
|
||||
@@ -39,6 +37,11 @@ export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL
|
||||
/** Set of message types that are supported by the library */
|
||||
export type MessageType = keyof proto.Message
|
||||
|
||||
export enum WAMessageAddressingMode {
|
||||
PN = 'pn',
|
||||
LID = 'lid'
|
||||
}
|
||||
|
||||
export type MessageWithContextInfo =
|
||||
| 'imageMessage'
|
||||
| 'contactMessage'
|
||||
|
||||
+11
-1
@@ -137,5 +137,15 @@ export type SocketConfig = {
|
||||
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
||||
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>
|
||||
|
||||
makeSignalRepository: (auth: SignalAuthState) => SignalRepository
|
||||
makeSignalRepository: (
|
||||
auth: SignalAuthState,
|
||||
onWhatsAppFunc?: (...jids: string[]) => Promise<
|
||||
| {
|
||||
jid: string
|
||||
exists: boolean
|
||||
lid: string
|
||||
}[]
|
||||
| undefined
|
||||
>
|
||||
) => SignalRepository
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user