feat: eventMessage sending / call link creation (#1677)

This commit is contained in:
vini
2025-09-07 08:08:18 -03:00
committed by GitHub
parent 4d4339dae6
commit 084761dc31
5 changed files with 76 additions and 1 deletions
+23
View File
@@ -633,6 +633,28 @@ export const makeChatsSocket = (config: SocketConfig) => {
return child?.attrs?.url
}
const createCallLink = async (type: 'audio' | 'video', event?: { startTime: number }, timeoutMs?: number) => {
const result = await query(
{
tag: 'call',
attrs: {
id: generateMessageTag(),
to: '@call'
},
content: [
{
tag: 'link_create',
attrs: { media: type },
content: event ? [{ tag: 'event', attrs: { start_time: String(event.startTime) } }] : undefined
}
]
},
timeoutMs
)
const child = getBinaryNodeChild(result, 'link_create')
return child?.attrs?.token
}
const sendPresenceUpdate = async (type: WAPresence, toJid?: string) => {
const me = authState.creds.me!
if (type === 'available' || type === 'unavailable') {
@@ -1139,6 +1161,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
return {
...sock,
createCallLink,
getBotListV2,
processingMutex,
fetchPrivacySettings,
+13
View File
@@ -655,6 +655,10 @@ export const makeMessagesSocket = (config: SocketConfig) => {
return 'poll'
}
if (message.eventMessage) {
return 'event'
}
return 'text'
}
@@ -817,12 +821,14 @@ export const makeMessagesSocket = (config: SocketConfig) => {
}),
//TODO: CACHE
getProfilePicUrl: sock.profilePictureUrl,
getCallLink: sock.createCallLink,
upload: waUploadToServer,
mediaCache: config.mediaCache,
options: config.options,
messageId: generateMessageIDV2(sock.user?.id),
...options
})
const isEventMsg = 'event' in content && !!content.event
const isDeleteMsg = 'delete' in content && !!content.delete
const isEditMsg = 'edit' in content && !!content.edit
const isPinMsg = 'pin' in content && !!content.pin
@@ -848,6 +854,13 @@ export const makeMessagesSocket = (config: SocketConfig) => {
polltype: 'creation'
}
} as BinaryNode)
} else if (isEventMsg) {
additionalNodes.push({
tag: 'meta',
attrs: {
event_type: 'creation'
}
} as BinaryNode)
}
if ('cachedGroupMetadata' in options) {