mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Clear tmp media files + regen yarn lock
This commit is contained in:
@@ -39,7 +39,7 @@ export async function sendAndRetrieveMessage(conn: WAConnection, content, type:
|
||||
const chat = conn.chats.get(recipientJid)
|
||||
|
||||
assert.ok (chat.messages.get(GET_MESSAGE_ID(message.key)))
|
||||
assert.ok (chat.t >= (unixTimestampSeconds()-5) )
|
||||
assert.ok (chat.t >= (unixTimestampSeconds()-5), `expected: ${chat.t} > ${(unixTimestampSeconds()-5)}`)
|
||||
return message
|
||||
}
|
||||
export const WAConnectionTest = (name: string, func: (conn: WAConnection) => void) => (
|
||||
|
||||
@@ -72,7 +72,7 @@ WAConnectionTest('Messages', conn => {
|
||||
assert.ok (message.message.audioMessage.seconds > 0)
|
||||
await conn.downloadAndSaveMediaMessage(message,'./Media/received_aud')
|
||||
})
|
||||
it('should send an audio as a voice note', async () => {
|
||||
it('should send a voice note', async () => {
|
||||
const content = await fs.readFile('./Media/sonata.mp3')
|
||||
const message = await sendAndRetrieveMessage(conn, content, MessageType.audio, { mimetype: Mimetype.mp4Audio, ptt: true })
|
||||
|
||||
|
||||
@@ -155,7 +155,8 @@ export class WAConnection extends Base {
|
||||
bodyPath,
|
||||
fileEncSha256,
|
||||
fileSha256,
|
||||
fileLength
|
||||
fileLength,
|
||||
didSaveToTmpPath
|
||||
} = await encryptedStream(media, mediaType, requiresOriginalForSomeProcessing)
|
||||
// url safe Base64 encode the SHA256 hash of the body
|
||||
const fileEncSha256B64 = encodeURIComponent(
|
||||
@@ -204,6 +205,14 @@ export class WAConnection extends Base {
|
||||
}
|
||||
}
|
||||
if (!mediaUrl) throw new Error('Media upload failed on all hosts')
|
||||
// remove tmp files
|
||||
await Promise.all(
|
||||
[
|
||||
fs.unlink(encBodyPath),
|
||||
didSaveToTmpPath && bodyPath && fs.unlink(bodyPath)
|
||||
]
|
||||
.filter(Boolean)
|
||||
)
|
||||
|
||||
const message = {
|
||||
[mediaType]: MessageTypeProto[mediaType].fromObject(
|
||||
|
||||
@@ -382,7 +382,8 @@ export const encryptedStream = async(media: WAMediaUpload, mediaType: MessageTyp
|
||||
mac,
|
||||
fileEncSha256,
|
||||
fileSha256,
|
||||
fileLength
|
||||
fileLength,
|
||||
didSaveToTmpPath: type !== 'file'
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user