File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed
Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import * as webpack from '../webpack';
1818import { ChatModel , functions } from '../whatsapp' ;
1919import { wrapModuleFunction } from '../whatsapp/exportModule' ;
2020import {
21+ findOrCreateLatestChat ,
2122 isUnreadTypeMsg ,
2223 mediaTypeFromProtobuf ,
2324 typeAttributeFromProtobuf ,
@@ -81,6 +82,23 @@ function applyPatch() {
8182
8283 return func ( ...args ) ;
8384 } ) ;
85+
86+ /**
87+ * Fixed error on try send message to some lids
88+ */
89+ wrapModuleFunction ( findOrCreateLatestChat , async ( func , ...args ) => {
90+ const [ chat , type ] = args ;
91+
92+ if ( chat . isLid ( ) && type != 'username_contactless_search' ) {
93+ try {
94+ return await func ( ...args ) ;
95+ } catch ( error ) {
96+ return await func ( chat , 'username_contactless_search' ) ;
97+ }
98+ }
99+
100+ return await func ( ...args ) ;
101+ } ) ;
84102}
85103
86104function applyPatchModel ( ) {
Original file line number Diff line number Diff line change 1+ /*!
2+ * Copyright 2021 WPPConnect Team
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ import { exportModule } from '../exportModule' ;
18+ import { Wid } from '../misc' ;
19+ import { ChatModel } from '../models' ;
20+
21+ /** @whatsapp WAWebFindChatAction
22+ */
23+ export declare function findOrCreateLatestChat (
24+ wid : Wid ,
25+ type ?: 'username_contactless_search'
26+ ) : Promise < ChatModel > ;
27+
28+ exportModule (
29+ exports ,
30+ {
31+ findOrCreateLatestChat : 'findOrCreateLatestChat' ,
32+ } ,
33+ ( m ) => m . findOrCreateLatestChat
34+ ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export * from './fetchLinkPreview';
4848export * from './findChat' ;
4949export * from './findCommonGroups' ;
5050export * from './findFirstWebLink' ;
51+ export * from './findOrCreateLatestChat' ;
5152export * from './forwardMessagesToChats' ;
5253export * from './frontendFireAndForget' ;
5354export * from './genBotMsgSecretFromMsgSecret' ;
You can’t perform that action at this time.
0 commit comments