chore: add media update logging

This commit is contained in:
Adhiraj Singh
2022-06-01 15:35:36 +05:30
parent 2b12defe6b
commit 82e2ec79d3

View File

@@ -1,4 +1,5 @@
import { Boom } from '@hapi/boom'
import NodeCache from 'node-cache'
import { proto } from '../../WAProto'
import { WA_DEFAULT_EPHEMERAL } from '../Defaults'
@@ -484,8 +485,14 @@ export const makeMessagesSocket = (config: SocketConfig) => {
} else {
try {
const media = decryptMediaRetryData(result.media!, mediaKey, result.key.id)
if(media.result !== proto.MediaRetryNotification.MediaRetryNotificationResultType.SUCCESS) {
throw new Boom(`Media re-upload failed by device (${media.result})`, { data: media })
}
content.directPath = media.directPath
content.url = getUrlFromDirectPath(content.directPath!)
logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful')
} catch(err) {
error = err
}