Skip to content

Commit

Permalink
fix: forwardMessagesToChats is missing from ChatStore (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurboss committed Dec 7, 2023
1 parent f46afa3 commit 788a37f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -86,6 +86,6 @@
"webpack-cli": "^5.1.4"
},
"engines": {
"whatsapp-web": ">=2.2321.6-beta"
"whatsapp-web": ">=2.2326.10-beta"
}
}
6 changes: 4 additions & 2 deletions src/chat/functions/forwardMessage.ts
Expand Up @@ -15,7 +15,8 @@
*/

import { assertFindChat } from '../../assert';
import { ChatStore, MsgKey, Wid } from '../../whatsapp';
import { MsgKey, Wid } from '../../whatsapp';
import { forwardMessagesToChats } from '../../whatsapp/functions';
import { getMessageById } from '..';

export interface ForwardMessagesOptions {
Expand All @@ -42,7 +43,8 @@ export async function forwardMessage(
const chat = await assertFindChat(toChatId);

const msg = await getMessageById(msgId);
return await ChatStore.forwardMessagesToChats(

return await forwardMessagesToChats(
[msg],
[chat],
options.displayCaptionText
Expand Down
44 changes: 44 additions & 0 deletions src/whatsapp/functions/forwardMessagesToChats.ts
@@ -0,0 +1,44 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { injectFallbackModule } from '../../webpack';
import { exportModule } from '../exportModule';
import { ChatModel, MsgModel } from '../models';
import { ChatStore } from '../stores';

/** @whatsapp 69951
* @whatsapp 450192 >= 2.2353.0
*/
export declare function forwardMessagesToChats(
msgs: MsgModel[],
chats: ChatModel[],
displayCaptionText?: boolean
): Promise<boolean>;

exportModule(
exports,
{ forwardMessagesToChats: 'forwardMessagesToChats' },
(m) => m.forwardMessagesToChats
);

injectFallbackModule('forwardMessagesToChats', {
forwardMessagesToChats: (
msgs: MsgModel[],
chats: ChatModel[],
displayCaptionText?: boolean
): Promise<boolean> =>
ChatStore.forwardMessagesToChats(msgs, chats, displayCaptionText),
});
1 change: 1 addition & 0 deletions src/whatsapp/functions/index.ts
Expand Up @@ -42,6 +42,7 @@ export * from './fetchLinkPreview';
export * from './findChat';
export * from './findCommonGroups';
export * from './findFirstWebLink';
export * from './forwardMessagesToChats';
export * from './frontendFireAndForget';
export * from './generateVideoThumbsAndDuration';
export * from './genLinkDeviceCodeForPhoneNumber';
Expand Down

0 comments on commit 788a37f

Please sign in to comment.