Fixes media upload to channels (#5697)

Ensures correct media upload to channels by using the mimetype from mediaInfo, rather than the file, when creating OpaqueData.

Also, it replaces the call to the function getRandomFilehash with the value of the function to retrieve the correct token.

Co-authored-by: Noel Carcases <noel.david.carcases.gomez@ibm.com>
Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com>
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
This commit is contained in:
noelcarcasesLYN 2026-01-30 02:55:30 +01:00 • committed by GitHub
commit b03680a70c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -452,7 +452,7 @@ exports.LoadUtils = () => {
window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, forceMediaHd, sendToChannel, sendToStatus }) => { window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, forceMediaHd, sendToChannel, sendToStatus }) => {
const file = window.WWebJS.mediaInfoToFile(mediaInfo); const file = window.WWebJS.mediaInfoToFile(mediaInfo);
const opaqueData = await window.Store.OpaqueData.createFromData(file, file.type); const opaqueData = await window.Store.OpaqueData.createFromData(file, mediaInfo.mimetype);
const mediaParams = { const mediaParams = {
asSticker: forceSticker, asSticker: forceSticker,
asGif: forceGif, asGif: forceGif,
@ -506,7 +506,7 @@ exports.LoadUtils = () => {
mimetype: mediaData.mimetype, mimetype: mediaData.mimetype,
mediaObject, mediaObject,
mediaType, mediaType,
...(sendToChannel ? { calculateToken: window.Store.SendChannelMessage.getRandomFilehash() } : {}) ...(sendToChannel ? { calculateToken: window.Store.SendChannelMessage.getRandomFilehash } : {})
}; };
const uploadedMedia = !sendToChannel const uploadedMedia = !sendToChannel