Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: forwardMessagesToChats is missing from ChatStore #1535

Merged
merged 12 commits into from
Dec 7, 2023
10 changes: 5 additions & 5 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@types/shelljs": "^0.8.15",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"@wppconnect/wa-version": "^1.2.163",
"@wppconnect/wa-version": "^1.2.164",
"buffer": "^6.0.3",
"compare-versions": "^6.1.0",
"compressorjs": "^1.2.1",
Expand Down Expand Up @@ -86,6 +86,6 @@
"webpack-cli": "^5.1.4"
},
"engines": {
"whatsapp-web": ">=2.2321.6-beta"
"whatsapp-web": ">=2.2326.10-beta"
}
}
11 changes: 6 additions & 5 deletions src/chat/functions/forwardMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

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

const msg = await getMessageById(msgId);
return await ChatStore.forwardMessagesToChats(
[msg],
[chat],
options.displayCaptionText
);
let forwardMessageFunc = ChatStore.forwardMessagesToChats;
if (typeof forwardMessageFunc !== 'function') {
forwardMessageFunc = forwardMessagesToChats;
}
return await forwardMessageFunc([msg], [chat], options.displayCaptionText);
keyurboss marked this conversation as resolved.
Show resolved Hide resolved
}
44 changes: 44 additions & 0 deletions src/whatsapp/functions/forwardMessagesToChats.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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