Fix Send Animated Sticker (#3591)
* Fix Send Animated Sitckers * Update Utils.js * Add a condition to ignore channels Add a condition to ignore channels and keep compatibility. * chore: mark channels as done feature --------- Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
parent
b2bb340046
commit
daaa04445f
3 changed files with 33 additions and 3 deletions
|
|
@ -128,9 +128,9 @@ For further details on saving and restoring sessions, explore the provided [Auth
|
||||||
| Set user status message | ✅ |
|
| Set user status message | ✅ |
|
||||||
| React to messages | ✅ |
|
| React to messages | ✅ |
|
||||||
| Create polls | ✅ |
|
| Create polls | ✅ |
|
||||||
|
| Channels | ✅ |
|
||||||
| Vote in polls | 🔜 |
|
| Vote in polls | 🔜 |
|
||||||
| Communities | 🔜 |
|
| Communities | 🔜 |
|
||||||
| Channels | 🔜 |
|
|
||||||
|
|
||||||
Something missing? Make an issue and let us know!
|
Something missing? Make an issue and let us know!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ exports.ExposeStore = () => {
|
||||||
window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
|
window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
|
||||||
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
|
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
|
||||||
window.Store.ChatGetters = window.require('WAWebChatGetters');
|
window.Store.ChatGetters = window.require('WAWebChatGetters');
|
||||||
|
window.Store.UploadUtils = window.require('WAWebUploadManager');
|
||||||
|
|
||||||
window.Store.Settings = {
|
window.Store.Settings = {
|
||||||
...window.require('WAWebUserPrefsGeneral'),
|
...window.require('WAWebUserPrefsGeneral'),
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,9 @@ exports.LoadUtils = () => {
|
||||||
|
|
||||||
let mediaOptions = {};
|
let mediaOptions = {};
|
||||||
if (options.media) {
|
if (options.media) {
|
||||||
mediaOptions = await window.WWebJS.processMediaData(
|
mediaOptions = options.sendMediaAsSticker && !isChannel
|
||||||
options.media, {
|
? await window.WWebJS.processStickerData(options.media)
|
||||||
|
: await window.WWebJS.processMediaData(options.media, {
|
||||||
forceSticker: options.sendMediaAsSticker,
|
forceSticker: options.sendMediaAsSticker,
|
||||||
forceGif: options.sendVideoAsGif,
|
forceGif: options.sendVideoAsGif,
|
||||||
forceVoice: options.sendAudioAsVoice,
|
forceVoice: options.sendAudioAsVoice,
|
||||||
|
|
@ -362,6 +363,34 @@ exports.LoadUtils = () => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.WWebJS.processStickerData = async (mediaInfo) => {
|
||||||
|
if (mediaInfo.mimetype !== 'image/webp') throw new Error('Invalid media type');
|
||||||
|
|
||||||
|
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||||
|
let filehash = await window.WWebJS.getFileHash(file);
|
||||||
|
let mediaKey = await window.WWebJS.generateHash(32);
|
||||||
|
|
||||||
|
const controller = new AbortController();
|
||||||
|
const uploadedInfo = await window.Store.UploadUtils.encryptAndUpload({
|
||||||
|
blob: file,
|
||||||
|
type: 'sticker',
|
||||||
|
signal: controller.signal,
|
||||||
|
mediaKey
|
||||||
|
});
|
||||||
|
|
||||||
|
const stickerInfo = {
|
||||||
|
...uploadedInfo,
|
||||||
|
clientUrl: uploadedInfo.url,
|
||||||
|
deprecatedMms3Url: uploadedInfo.url,
|
||||||
|
uploadhash: uploadedInfo.encFilehash,
|
||||||
|
size: file.size,
|
||||||
|
type: 'sticker',
|
||||||
|
filehash
|
||||||
|
};
|
||||||
|
|
||||||
|
return stickerInfo;
|
||||||
|
};
|
||||||
|
|
||||||
window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, forceMediaHd, sendToChannel }) => {
|
window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, forceMediaHd, sendToChannel }) => {
|
||||||
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, file.type);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue