Skip to content

Commit

Permalink
fix: Fixed send message with quotedMsg (fix #721)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Oct 30, 2022
1 parent b54a03b commit 0931800
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/chat/functions/prepareRawMessage.ts
Expand Up @@ -19,7 +19,7 @@ import { getParticipants } from '../../group';
import { WPPError } from '../../util';
import { ChatModel, MsgKey, MsgModel, UserPrefs, Wid } from '../../whatsapp';
import { ACK } from '../../whatsapp/enums';
import { unixTime } from '../../whatsapp/functions';
import { canReplyMsg, unixTime } from '../../whatsapp/functions';
import { defaultSendMessageOptions, RawMessage, SendMessageOptions } from '..';
import { generateMessageID, getMessageById } from '.';

Expand Down Expand Up @@ -160,7 +160,7 @@ export async function prepareRawMessage<T extends RawMessage>(
});
}

if (!options.quotedMsg?.isStatusV3 && !options.quotedMsg.canReply()) {
if (!options.quotedMsg?.isStatusV3 && !canReplyMsg(options.quotedMsg)) {
throw new WPPError(
'quoted_msg_can_not_reply',
'QuotedMsg can not reply',
Expand Down
38 changes: 38 additions & 0 deletions src/whatsapp/functions/canReplyMsg.ts
@@ -0,0 +1,38 @@
/*!
* 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 * as webpack from '../../webpack';
import { exportModule } from '../exportModule';
import { MsgModel } from '../models';

/**
* @whatsapp 973480 >= 2.2241.6
*/
export declare function canReplyMsg(msg: MsgModel): boolean;

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

webpack.injectFallbackModule('canReplyMsg', {
canReplyMsg: (msg: MsgModel) => {
return msg.canReply?.() || false;
},
});
1 change: 1 addition & 0 deletions src/whatsapp/functions/index.ts
Expand Up @@ -17,6 +17,7 @@
export * from './addAndSendMsgToChat';
export * from './blockContact';
export * from './calculateFilehashFromBlob';
export * from './canReplyMsg';
export * from './collections';
export * from './createMsgProtobuf';
export * from './createOrUpdateReactions';
Expand Down
2 changes: 1 addition & 1 deletion src/whatsapp/models/MsgModel.ts
Expand Up @@ -335,7 +335,7 @@ export declare class MsgModel extends Model {
hasSymbol(): boolean;
mayFail(): any;
isUnsentPhoneMsg(): boolean;
canReply(): boolean;
canReply?(): boolean;
canPrivateReply(): boolean;
canPrivateReplyInRestrictedGrp(): boolean;
canForward(): boolean;
Expand Down

0 comments on commit 0931800

Please sign in to comment.