fix: Message.pin and Message.unpin (#3319)

* fix: update function to wweb version >2.3000.0

* feat: add foolproof check

* fix: override internal function correctly
This commit is contained in:
alechkos 2025-08-09 00:35:40 +03:00 • committed by GitHub
commit ab321f3d7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -88,7 +88,6 @@ exports.ExposeStore = () => {
window.Store.WidToJid = window.require('WAWebWidToJid');
window.Store.JidToWid = window.require('WAWebJidToWid');
window.Store.getMsgInfo = window.require('WAWebApiMessageInfoStore').queryMsgInfo;
window.Store.pinUnpinMsg = window.require('WAWebSendPinMessageAction').sendPinInChatMsg;
window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists;
window.Store.ReplyUtils = window.require('WAWebMsgReply');
window.Store.BotSecret = window.require('WAWebBotMessageSecret');
@ -99,6 +98,7 @@ exports.ExposeStore = () => {
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
window.Store.PinnedMsgUtils = window.require('WAWebPinInChatSchema');
window.Store.ChatGetters = window.require('WAWebChatGetters');
window.Store.PinnedMsgUtils = window.require('WAWebSendPinMessageAction');
window.Store.UploadUtils = window.require('WAWebUploadManager');
window.Store.WAWebStreamModel = window.require('WAWebStreamModel');

View file

@ -1100,7 +1100,16 @@ exports.LoadUtils = () => {
window.WWebJS.pinUnpinMsgAction = async (msgId, action, duration) => {
const message = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
if (!message) return false;
const response = await window.Store.pinUnpinMsg(message, action, duration);
if (typeof duration !== 'number') return false;
const originalFunction = window.require('WAWebPinMsgConstants').getPinExpiryDuration;
window.require('WAWebPinMsgConstants').getPinExpiryDuration = () => duration;
const response = await window.Store.PinnedMsgUtils.sendPinInChatMsg(message, action, duration);
window.require('WAWebPinMsgConstants').getPinExpiryDuration = originalFunction;
return response.messageSendResult === 'OK';
};