mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Merge pull request #1381 from vai-projetos/consistently-messageId
refactor(messageId): update all remaining usages to v2 format consist…
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
import { GroupMetadata, GroupParticipant, ParticipantAction, SocketConfig, WAMessageKey, WAMessageStubType } from '../Types'
|
import { GroupMetadata, GroupParticipant, ParticipantAction, SocketConfig, WAMessageKey, WAMessageStubType } from '../Types'
|
||||||
import { generateMessageID, generateMessageIDV2, unixTimestampSeconds } from '../Utils'
|
import { generateMessageIDV2, unixTimestampSeconds } from '../Utils'
|
||||||
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, jidEncode, jidNormalizedUser } from '../WABinary'
|
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, jidEncode, jidNormalizedUser } from '../WABinary'
|
||||||
import { makeChatsSocket } from './chats'
|
import { makeChatsSocket } from './chats'
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
|||||||
...sock,
|
...sock,
|
||||||
groupMetadata,
|
groupMetadata,
|
||||||
groupCreate: async(subject: string, participants: string[]) => {
|
groupCreate: async(subject: string, participants: string[]) => {
|
||||||
const key = generateMessageID()
|
const key = generateMessageIDV2()
|
||||||
const result = await groupQuery(
|
const result = await groupQuery(
|
||||||
'@g.us',
|
'@g.us',
|
||||||
'set',
|
'set',
|
||||||
@@ -207,7 +207,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
|||||||
{
|
{
|
||||||
tag: 'description',
|
tag: 'description',
|
||||||
attrs: {
|
attrs: {
|
||||||
...(description ? { id: generateMessageID() } : { delete: 'true' }),
|
...(description ? { id: generateMessageIDV2() } : { delete: 'true' }),
|
||||||
...(prev ? { prev } : {})
|
...(prev ? { prev } : {})
|
||||||
},
|
},
|
||||||
content: description ? [
|
content: description ? [
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { DEFAULT_ORIGIN, MEDIA_HKDF_KEY_MAPPING, MEDIA_PATH_MAP } from '../Defau
|
|||||||
import { BaileysEventMap, DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, MessageType, SocketConfig, WAGenericMediaMessage, WAMediaPayloadURL, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types'
|
import { BaileysEventMap, DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, MessageType, SocketConfig, WAGenericMediaMessage, WAMediaPayloadURL, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types'
|
||||||
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildBuffer, jidNormalizedUser } from '../WABinary'
|
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildBuffer, jidNormalizedUser } from '../WABinary'
|
||||||
import { aesDecryptGCM, aesEncryptGCM, hkdf } from './crypto'
|
import { aesDecryptGCM, aesEncryptGCM, hkdf } from './crypto'
|
||||||
import { generateMessageID } from './generics'
|
import { generateMessageIDV2 } from './generics'
|
||||||
import { ILogger } from './logger'
|
import { ILogger } from './logger'
|
||||||
|
|
||||||
const getTmpFilesDirectory = () => tmpdir()
|
const getTmpFilesDirectory = () => tmpdir()
|
||||||
@@ -305,7 +305,7 @@ export async function generateThumbnail(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mediaType === 'video') {
|
} else if(mediaType === 'video') {
|
||||||
const imgFilename = join(getTmpFilesDirectory(), generateMessageID() + '.jpg')
|
const imgFilename = join(getTmpFilesDirectory(), generateMessageIDV2() + '.jpg')
|
||||||
try {
|
try {
|
||||||
await extractVideoThumb(file, imgFilename, '00:00:00', { width: 32, height: 32 })
|
await extractVideoThumb(file, imgFilename, '00:00:00', { width: 32, height: 32 })
|
||||||
const buff = await fs.readFile(imgFilename)
|
const buff = await fs.readFile(imgFilename)
|
||||||
@@ -353,7 +353,7 @@ export const encryptedStream = async(
|
|||||||
if(type === 'file') {
|
if(type === 'file') {
|
||||||
bodyPath = (media as WAMediaPayloadURL).url.toString()
|
bodyPath = (media as WAMediaPayloadURL).url.toString()
|
||||||
} else if(saveOriginalFileIfRequired) {
|
} else if(saveOriginalFileIfRequired) {
|
||||||
bodyPath = join(getTmpFilesDirectory(), mediaType + generateMessageID())
|
bodyPath = join(getTmpFilesDirectory(), mediaType + generateMessageIDV2())
|
||||||
writeStream = createWriteStream(bodyPath)
|
writeStream = createWriteStream(bodyPath)
|
||||||
didSaveToTmpPath = true
|
didSaveToTmpPath = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {
|
|||||||
} from '../Types'
|
} from '../Types'
|
||||||
import { isJidGroup, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary'
|
import { isJidGroup, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary'
|
||||||
import { sha256 } from './crypto'
|
import { sha256 } from './crypto'
|
||||||
import { generateMessageID, getKeyAuthor, unixTimestampSeconds } from './generics'
|
import { generateMessageIDV2, getKeyAuthor, unixTimestampSeconds } from './generics'
|
||||||
import { ILogger } from './logger'
|
import { ILogger } from './logger'
|
||||||
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, getAudioWaveform, MediaDownloadOptions } from './messages-media'
|
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, getAudioWaveform, MediaDownloadOptions } from './messages-media'
|
||||||
|
|
||||||
@@ -606,7 +606,7 @@ export const generateWAMessageFromContent = (
|
|||||||
key: {
|
key: {
|
||||||
remoteJid: jid,
|
remoteJid: jid,
|
||||||
fromMe: true,
|
fromMe: true,
|
||||||
id: options?.messageId || generateMessageID(),
|
id: options?.messageId || generateMessageIDV2(),
|
||||||
},
|
},
|
||||||
message: message,
|
message: message,
|
||||||
messageTimestamp: timestamp,
|
messageTimestamp: timestamp,
|
||||||
|
|||||||
Reference in New Issue
Block a user