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:
parent
18b1d32825
commit
ab321f3d7e
2 changed files with 11 additions and 2 deletions
|
|
@ -88,7 +88,6 @@ exports.ExposeStore = () => {
|
||||||
window.Store.WidToJid = window.require('WAWebWidToJid');
|
window.Store.WidToJid = window.require('WAWebWidToJid');
|
||||||
window.Store.JidToWid = window.require('WAWebJidToWid');
|
window.Store.JidToWid = window.require('WAWebJidToWid');
|
||||||
window.Store.getMsgInfo = window.require('WAWebApiMessageInfoStore').queryMsgInfo;
|
window.Store.getMsgInfo = window.require('WAWebApiMessageInfoStore').queryMsgInfo;
|
||||||
window.Store.pinUnpinMsg = window.require('WAWebSendPinMessageAction').sendPinInChatMsg;
|
|
||||||
window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists;
|
window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists;
|
||||||
window.Store.ReplyUtils = window.require('WAWebMsgReply');
|
window.Store.ReplyUtils = window.require('WAWebMsgReply');
|
||||||
window.Store.BotSecret = window.require('WAWebBotMessageSecret');
|
window.Store.BotSecret = window.require('WAWebBotMessageSecret');
|
||||||
|
|
@ -99,6 +98,7 @@ exports.ExposeStore = () => {
|
||||||
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
|
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
|
||||||
window.Store.PinnedMsgUtils = window.require('WAWebPinInChatSchema');
|
window.Store.PinnedMsgUtils = window.require('WAWebPinInChatSchema');
|
||||||
window.Store.ChatGetters = window.require('WAWebChatGetters');
|
window.Store.ChatGetters = window.require('WAWebChatGetters');
|
||||||
|
window.Store.PinnedMsgUtils = window.require('WAWebSendPinMessageAction');
|
||||||
window.Store.UploadUtils = window.require('WAWebUploadManager');
|
window.Store.UploadUtils = window.require('WAWebUploadManager');
|
||||||
window.Store.WAWebStreamModel = window.require('WAWebStreamModel');
|
window.Store.WAWebStreamModel = window.require('WAWebStreamModel');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1100,7 +1100,16 @@ exports.LoadUtils = () => {
|
||||||
window.WWebJS.pinUnpinMsgAction = async (msgId, action, duration) => {
|
window.WWebJS.pinUnpinMsgAction = async (msgId, action, duration) => {
|
||||||
const message = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
|
const message = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
|
||||||
if (!message) return false;
|
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';
|
return response.messageSendResult === 'OK';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue