mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
share, receive, request, all you want
This commit is contained in:
@@ -660,6 +660,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
signalRepository,
|
signalRepository,
|
||||||
logger,
|
logger,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(msg.message?.protocolMessage?.type === proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
|
||||||
|
if(node.attrs.sender_pn) {
|
||||||
|
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(shouldIgnoreJid(msg.key.remoteJid!)) {
|
if(shouldIgnoreJid(msg.key.remoteJid!)) {
|
||||||
logger.debug({ key: msg.key }, 'ignored message')
|
logger.debug({ key: msg.key }, 'ignored message')
|
||||||
await sendMessageAck(node)
|
await sendMessageAck(node)
|
||||||
|
|||||||
@@ -304,6 +304,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
message: proto.IMessage,
|
message: proto.IMessage,
|
||||||
{ messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: MessageRelayOptions
|
{ messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: MessageRelayOptions
|
||||||
) => {
|
) => {
|
||||||
|
const meId = authState.creds.me!.id
|
||||||
|
|
||||||
let shouldIncludeDeviceIdentity = false
|
let shouldIncludeDeviceIdentity = false
|
||||||
|
|
||||||
const { user, server } = jidDecode(jid)!
|
const { user, server } = jidDecode(jid)!
|
||||||
@@ -311,7 +313,6 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
const isGroup = server === 'g.us'
|
const isGroup = server === 'g.us'
|
||||||
const isStatus = jid === statusJid
|
const isStatus = jid === statusJid
|
||||||
const isLid = server === 'lid'
|
const isLid = server === 'lid'
|
||||||
const meId = authState.creds.me!.id
|
|
||||||
|
|
||||||
msgId = msgId || generateMessageID()
|
msgId = msgId || generateMessageID()
|
||||||
useUserDevicesCache = useUserDevicesCache !== false
|
useUserDevicesCache = useUserDevicesCache !== false
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export type BaileysEventMap = {
|
|||||||
'chats.upsert': Chat[]
|
'chats.upsert': Chat[]
|
||||||
/** update the given chats */
|
/** update the given chats */
|
||||||
'chats.update': ChatUpdate[]
|
'chats.update': ChatUpdate[]
|
||||||
|
'chats.phoneNumberShare': {lid: string, jid: string}
|
||||||
/** delete chats with given ID */
|
/** delete chats with given ID */
|
||||||
'chats.delete': string[]
|
'chats.delete': string[]
|
||||||
/** presence of contact in a chat updated */
|
/** presence of contact in a chat updated */
|
||||||
@@ -54,6 +55,7 @@ export type BaileysEventMap = {
|
|||||||
|
|
||||||
'blocklist.set': { blocklist: string[] }
|
'blocklist.set': { blocklist: string[] }
|
||||||
'blocklist.update': { blocklist: string[], type: 'add' | 'remove' }
|
'blocklist.update': { blocklist: string[], type: 'add' | 'remove' }
|
||||||
|
|
||||||
/** Receive an update on a call, including when the call was received, rejected, accepted */
|
/** Receive an update on a call, including when the call was received, rejected, accepted */
|
||||||
'call': WACallEvent[]
|
'call': WACallEvent[]
|
||||||
'labels.edit': Label
|
'labels.edit': Label
|
||||||
|
|||||||
@@ -96,6 +96,14 @@ export type PollMessageOptions = {
|
|||||||
messageSecret?: Uint8Array
|
messageSecret?: Uint8Array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SharePhoneNumber = {
|
||||||
|
sharePhoneNumber: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
type RequestPhoneNumber = {
|
||||||
|
requestPhoneNumber: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING
|
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING
|
||||||
export type AnyMediaMessageContent = (
|
export type AnyMediaMessageContent = (
|
||||||
({
|
({
|
||||||
@@ -169,7 +177,7 @@ export type AnyRegularMessageContent = (
|
|||||||
businessOwnerJid?: string
|
businessOwnerJid?: string
|
||||||
body?: string
|
body?: string
|
||||||
footer?: string
|
footer?: string
|
||||||
}
|
} | SharePhoneNumber | RequestPhoneNumber
|
||||||
) & ViewOnce
|
) & ViewOnce
|
||||||
|
|
||||||
export type AnyMessageContent = AnyRegularMessageContent | {
|
export type AnyMessageContent = AnyRegularMessageContent | {
|
||||||
|
|||||||
@@ -449,6 +449,12 @@ export const generateWAMessageContent = async(
|
|||||||
selectableOptionsCount: message.poll.selectableCount,
|
selectableOptionsCount: message.poll.selectableCount,
|
||||||
options: message.poll.values.map(optionName => ({ optionName })),
|
options: message.poll.values.map(optionName => ({ optionName })),
|
||||||
}
|
}
|
||||||
|
} else if('sharePhoneNumber' in message) {
|
||||||
|
m.protocolMessage = {
|
||||||
|
type: proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER
|
||||||
|
}
|
||||||
|
} else if('requestPhoneNumber' in message) {
|
||||||
|
m.requestPhoneNumberMessage = {}
|
||||||
} else {
|
} else {
|
||||||
m = await prepareWAMessageMedia(
|
m = await prepareWAMessageMedia(
|
||||||
message,
|
message,
|
||||||
|
|||||||
Reference in New Issue
Block a user