@queenanya/baileys 6.9.2 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -13
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +5 -2
- package/lib/Socket/business.d.ts +46 -8
- package/lib/Socket/business.js +1 -0
- package/lib/Socket/chats.d.ts +10 -2
- package/lib/Socket/chats.js +42 -3
- package/lib/Socket/groups.d.ts +17 -3
- package/lib/Socket/groups.js +12 -1
- package/lib/Socket/index.d.ts +46 -8
- package/lib/Socket/messages-recv.d.ts +45 -9
- package/lib/Socket/messages-recv.js +184 -22
- package/lib/Socket/messages-send.d.ts +40 -6
- package/lib/Socket/messages-send.js +153 -37
- package/lib/Socket/newsletter.d.ts +140 -0
- package/lib/Socket/newsletter.js +249 -0
- package/lib/Socket/registration.d.ts +46 -11
- package/lib/Socket/socket.js +18 -4
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +11 -44
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Chat.d.ts +5 -0
- package/lib/Types/Events.d.ts +40 -2
- package/lib/Types/GroupMetadata.d.ts +3 -1
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Message.d.ts +39 -27
- package/lib/Types/Newsletter.d.ts +79 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Socket.d.ts +7 -0
- package/lib/Types/index.d.ts +9 -0
- package/lib/Types/index.js +1 -0
- package/lib/Utils/auth-utils.js +1 -0
- package/lib/Utils/chat-utils.js +16 -0
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +4 -2
- package/lib/Utils/decode-wa-message.d.ts +1 -0
- package/lib/Utils/decode-wa-message.js +50 -22
- package/lib/Utils/generics.d.ts +30 -10
- package/lib/Utils/generics.js +82 -10
- package/lib/Utils/history.d.ts +4 -0
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/logger.d.ts +1 -3
- package/lib/Utils/messages-media.d.ts +10 -1
- package/lib/Utils/messages-media.js +61 -18
- package/lib/Utils/messages.d.ts +2 -1
- package/lib/Utils/messages.js +77 -76
- package/lib/Utils/noise-handler.d.ts +3 -2
- package/lib/Utils/noise-handler.js +18 -5
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +53 -21
- package/lib/Utils/signal.js +21 -16
- package/lib/Utils/use-multi-file-auth-state.js +16 -3
- package/lib/WABinary/decode.d.ts +2 -2
- package/lib/WABinary/decode.js +6 -4
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +1 -1
- package/lib/WABinary/jid-utils.d.ts +3 -1
- package/lib/WABinary/jid-utils.js +4 -1
- package/package.json +32 -27
package/lib/Socket/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/// <reference types="long" />
|
|
1
2
|
/// <reference types="node" />
|
|
2
3
|
import { UserFacingSocketConfig } from '../Types';
|
|
3
4
|
declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
4
5
|
register: (code: string) => Promise<import("./registration").ExistsResponse>;
|
|
5
6
|
requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions | undefined) => Promise<import("./registration").ExistsResponse>;
|
|
7
|
+
logger: import("pino").Logger<never>;
|
|
6
8
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
7
9
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
8
10
|
products: import("../Types").Product[];
|
|
@@ -19,22 +21,50 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
19
21
|
sendMessageAck: ({ tag, attrs, content }: import("../index").BinaryNode) => Promise<void>;
|
|
20
22
|
sendRetryRequest: (node: import("../index").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
21
23
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
24
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
|
25
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
22
26
|
getPrivacyTokens: (jids: string[]) => Promise<import("../index").BinaryNode>;
|
|
23
27
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
24
|
-
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache,
|
|
28
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
25
29
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
26
|
-
sendReceipts: (keys: import("../Types").
|
|
27
|
-
|
|
28
|
-
[key: string]: string;
|
|
29
|
-
};
|
|
30
|
-
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
30
|
+
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
31
|
+
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
31
32
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
32
33
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
33
34
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
34
35
|
[_: string]: string;
|
|
35
36
|
}>;
|
|
37
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
38
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
|
39
|
+
[key: string]: string;
|
|
40
|
+
} | undefined) => Promise<{
|
|
41
|
+
nodes: import("../index").BinaryNode[];
|
|
42
|
+
shouldIncludeDeviceIdentity: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../index").JidWithDevice[]>;
|
|
36
45
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
37
46
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
47
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
48
|
+
duration: string;
|
|
49
|
+
}>;
|
|
50
|
+
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
51
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
52
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
53
|
+
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
54
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
55
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
56
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
|
57
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
|
58
|
+
newsletterMute: (jid: string) => Promise<void>;
|
|
59
|
+
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
60
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
61
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
62
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
63
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
64
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
65
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
66
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
67
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
38
68
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
39
69
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
40
70
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -55,7 +85,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
55
85
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
56
86
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
57
87
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
58
|
-
|
|
88
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
89
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
59
90
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
60
91
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
61
92
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
@@ -77,6 +108,11 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
77
108
|
jid: string;
|
|
78
109
|
}[]>;
|
|
79
110
|
fetchBlocklist: () => Promise<string[]>;
|
|
111
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
112
|
+
user: string;
|
|
113
|
+
duration: number;
|
|
114
|
+
setAt: Date;
|
|
115
|
+
}[]>;
|
|
80
116
|
fetchStatus: (jid: string) => Promise<{
|
|
81
117
|
status: string | undefined;
|
|
82
118
|
setAt: Date;
|
|
@@ -86,17 +122,19 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
86
122
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
87
123
|
updateProfileName: (name: string) => Promise<void>;
|
|
88
124
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
125
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
89
126
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
90
127
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
91
128
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
92
129
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
93
130
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
94
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
131
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
95
132
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
96
133
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
97
134
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
98
135
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
99
136
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
137
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
100
138
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
101
139
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
102
140
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -1,28 +1,56 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Boom } from '@hapi/boom';
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
|
-
import { MessageReceiptType, MessageRelayOptions, SocketConfig } from '../Types';
|
|
4
|
+
import { MessageReceiptType, MessageRelayOptions, SocketConfig, WAMessageKey } from '../Types';
|
|
5
5
|
import { BinaryNode } from '../WABinary';
|
|
6
6
|
export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
7
7
|
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
|
8
8
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
9
9
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
10
|
+
fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
11
|
+
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<'RESOLVED' | string | undefined>;
|
|
10
12
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
11
13
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
12
|
-
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache,
|
|
14
|
+
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
13
15
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
14
|
-
sendReceipts: (keys:
|
|
15
|
-
|
|
16
|
-
[key: string]: string;
|
|
17
|
-
};
|
|
18
|
-
readMessages: (keys: proto.IMessageKey[]) => Promise<void>;
|
|
16
|
+
sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
17
|
+
readMessages: (keys: WAMessageKey[]) => Promise<void>;
|
|
19
18
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
20
19
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
21
20
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
22
21
|
[_: string]: string;
|
|
23
22
|
}>;
|
|
23
|
+
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
24
|
+
createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
} | undefined) => Promise<{
|
|
27
|
+
nodes: BinaryNode[];
|
|
28
|
+
shouldIncludeDeviceIdentity: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
24
31
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
25
32
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
|
|
33
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
34
|
+
duration: string;
|
|
35
|
+
}>;
|
|
36
|
+
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
37
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
38
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
39
|
+
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
40
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
41
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
42
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
|
43
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
|
44
|
+
newsletterMute: (jid: string) => Promise<void>;
|
|
45
|
+
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
46
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
47
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
48
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
49
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
50
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
51
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
52
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
53
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
26
54
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
27
55
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
28
56
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -43,7 +71,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
43
71
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
44
72
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
45
73
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
46
|
-
|
|
74
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
75
|
+
groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
47
76
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
48
77
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
49
78
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
@@ -65,6 +94,11 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
65
94
|
jid: string;
|
|
66
95
|
}[]>;
|
|
67
96
|
fetchBlocklist: () => Promise<string[]>;
|
|
97
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
98
|
+
user: string;
|
|
99
|
+
duration: number;
|
|
100
|
+
setAt: Date;
|
|
101
|
+
}[]>;
|
|
68
102
|
fetchStatus: (jid: string) => Promise<{
|
|
69
103
|
status: string | undefined;
|
|
70
104
|
setAt: Date;
|
|
@@ -74,17 +108,19 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
74
108
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
75
109
|
updateProfileName: (name: string) => Promise<void>;
|
|
76
110
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
111
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
77
112
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
78
113
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
79
114
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
80
115
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
81
116
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
82
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
117
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
83
118
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
84
119
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
85
120
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
86
121
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
87
122
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
123
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
88
124
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
89
125
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
90
126
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -17,9 +17,9 @@ const WABinary_1 = require("../WABinary");
|
|
|
17
17
|
const groups_1 = require("./groups");
|
|
18
18
|
const messages_send_1 = require("./messages-send");
|
|
19
19
|
const makeMessagesRecvSocket = (config) => {
|
|
20
|
-
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
|
|
20
|
+
const { logger, retryRequestDelayMs, maxMsgRetryCount, ignoreMsgLoading, getMessage, shouldIgnoreJid } = config;
|
|
21
21
|
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
22
|
-
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, } = sock;
|
|
22
|
+
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, sendPeerDataOperationMessage, } = sock;
|
|
23
23
|
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
|
24
24
|
const retryMutex = (0, make_mutex_1.makeMutex)();
|
|
25
25
|
const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
|
|
@@ -30,6 +30,10 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
30
30
|
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER,
|
|
31
31
|
useClones: false
|
|
32
32
|
});
|
|
33
|
+
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
34
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
35
|
+
useClones: false
|
|
36
|
+
});
|
|
33
37
|
let sendActiveReceipts = false;
|
|
34
38
|
const sendMessageAck = async ({ tag, attrs, content }) => {
|
|
35
39
|
const stanza = {
|
|
@@ -75,16 +79,24 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
75
79
|
await query(stanza);
|
|
76
80
|
};
|
|
77
81
|
const sendRetryRequest = async (node, forceIncludeKeys = false) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
82
|
+
const { fullMessage } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '');
|
|
83
|
+
const { key: msgKey } = fullMessage;
|
|
84
|
+
const msgId = msgKey.id;
|
|
85
|
+
const key = `${msgId}:${msgKey === null || msgKey === void 0 ? void 0 : msgKey.participant}`;
|
|
86
|
+
let retryCount = msgRetryCache.get(key) || 0;
|
|
80
87
|
if (retryCount >= maxMsgRetryCount) {
|
|
81
88
|
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing');
|
|
82
|
-
msgRetryCache.del(
|
|
89
|
+
msgRetryCache.del(key);
|
|
83
90
|
return;
|
|
84
91
|
}
|
|
85
92
|
retryCount += 1;
|
|
86
|
-
msgRetryCache.set(
|
|
93
|
+
msgRetryCache.set(key, retryCount);
|
|
87
94
|
const { account, signedPreKey, signedIdentityKey: identityKey } = authState.creds;
|
|
95
|
+
if (retryCount === 1) {
|
|
96
|
+
//request a resend via phone
|
|
97
|
+
const msgId = await requestPlaceholderResend(msgKey);
|
|
98
|
+
logger.debug(`sendRetryRequest: requested placeholder resend for message ${msgId}`);
|
|
99
|
+
}
|
|
88
100
|
const deviceIdentity = (0, Utils_1.encodeSignedDeviceIdentity)(account, true);
|
|
89
101
|
await authState.keys.transaction(async () => {
|
|
90
102
|
const receipt = {
|
|
@@ -163,6 +175,8 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
163
175
|
}
|
|
164
176
|
};
|
|
165
177
|
const handleGroupNotification = (participant, child, msg) => {
|
|
178
|
+
var _a, _b, _c, _d;
|
|
179
|
+
const participantJid = ((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(child, 'participant')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.jid) || participant;
|
|
166
180
|
switch (child === null || child === void 0 ? void 0 : child.tag) {
|
|
167
181
|
case 'create':
|
|
168
182
|
const metadata = (0, groups_1.extractGroupMetadata)(child);
|
|
@@ -188,6 +202,11 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
188
202
|
}
|
|
189
203
|
};
|
|
190
204
|
break;
|
|
205
|
+
case 'modify':
|
|
206
|
+
const oldNumber = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.jid);
|
|
207
|
+
msg.messageStubParameters = oldNumber || [];
|
|
208
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER;
|
|
209
|
+
break;
|
|
191
210
|
case 'promote':
|
|
192
211
|
case 'demote':
|
|
193
212
|
case 'remove':
|
|
@@ -209,6 +228,11 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
209
228
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;
|
|
210
229
|
msg.messageStubParameters = [child.attrs.subject];
|
|
211
230
|
break;
|
|
231
|
+
case 'description':
|
|
232
|
+
const description = (_d = (_c = (0, WABinary_1.getBinaryNodeChild)(child, 'body')) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.toString();
|
|
233
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION;
|
|
234
|
+
msg.messageStubParameters = description ? [description] : undefined;
|
|
235
|
+
break;
|
|
212
236
|
case 'announcement':
|
|
213
237
|
case 'not_announcement':
|
|
214
238
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE;
|
|
@@ -237,6 +261,59 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
237
261
|
msg.messageStubParameters = [approvalMode.attrs.state];
|
|
238
262
|
}
|
|
239
263
|
break;
|
|
264
|
+
case 'created_membership_requests':
|
|
265
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;
|
|
266
|
+
msg.messageStubParameters = [participantJid, 'created', child.attrs.request_method];
|
|
267
|
+
break;
|
|
268
|
+
case 'revoked_membership_requests':
|
|
269
|
+
const isDenied = (0, WABinary_1.areJidsSameUser)(participantJid, participant);
|
|
270
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;
|
|
271
|
+
msg.messageStubParameters = [participantJid, isDenied ? 'revoked' : 'rejected'];
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const handleNewsletterNotification = (id, node) => {
|
|
276
|
+
const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
277
|
+
const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
|
|
278
|
+
const server_id = message.attrs.server_id;
|
|
279
|
+
const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
|
|
280
|
+
const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
|
|
281
|
+
if (reactionsList) {
|
|
282
|
+
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
|
|
283
|
+
if (reactions.length === 0) {
|
|
284
|
+
ev.emit('newsletter.reaction', { id, server_id, reaction: { removed: true } });
|
|
285
|
+
}
|
|
286
|
+
reactions.forEach(item => {
|
|
287
|
+
var _a, _b;
|
|
288
|
+
ev.emit('newsletter.reaction', { id, server_id, reaction: { code: (_a = item.attrs) === null || _a === void 0 ? void 0 : _a.code, count: +((_b = item.attrs) === null || _b === void 0 ? void 0 : _b.count) } });
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
if (viewsList.length) {
|
|
292
|
+
viewsList.forEach(item => {
|
|
293
|
+
ev.emit('newsletter.view', { id, server_id, count: +item.attrs.count });
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
const handleMexNewsletterNotification = (id, node) => {
|
|
298
|
+
var _a;
|
|
299
|
+
const operation = node === null || node === void 0 ? void 0 : node.attrs.op_name;
|
|
300
|
+
const content = JSON.parse((_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString());
|
|
301
|
+
let contentPath;
|
|
302
|
+
if (operation === Types_1.MexOperations.PROMOTE || operation === Types_1.MexOperations.DEMOTE) {
|
|
303
|
+
let action;
|
|
304
|
+
if (operation === Types_1.MexOperations.PROMOTE) {
|
|
305
|
+
action = 'promote';
|
|
306
|
+
contentPath = content.data[Types_1.XWAPaths.PROMOTE];
|
|
307
|
+
}
|
|
308
|
+
if (operation === Types_1.MexOperations.DEMOTE) {
|
|
309
|
+
action = 'demote';
|
|
310
|
+
contentPath = content.data[Types_1.XWAPaths.DEMOTE];
|
|
311
|
+
}
|
|
312
|
+
ev.emit('newsletter-participants.update', { id, author: contentPath.actor.pn, user: contentPath.user.pn, new_role: contentPath.user_new_role, action });
|
|
313
|
+
}
|
|
314
|
+
if (operation === Types_1.MexOperations.UPDATE) {
|
|
315
|
+
contentPath = content.data[Types_1.XWAPaths.METADATA_UPDATE];
|
|
316
|
+
ev.emit('newsletter-settings.update', { id, update: contentPath.thread_metadata.settings });
|
|
240
317
|
}
|
|
241
318
|
};
|
|
242
319
|
const processNotification = async (node) => {
|
|
@@ -259,6 +336,12 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
259
336
|
logger.debug({ jid }, 'got privacy token update');
|
|
260
337
|
}
|
|
261
338
|
break;
|
|
339
|
+
case 'newsletter':
|
|
340
|
+
handleNewsletterNotification(node.attrs.from, child);
|
|
341
|
+
break;
|
|
342
|
+
case 'mex':
|
|
343
|
+
handleMexNewsletterNotification(node.attrs.from, child);
|
|
344
|
+
break;
|
|
262
345
|
case 'w:gp2':
|
|
263
346
|
handleGroupNotification(node.attrs.participant, child, result);
|
|
264
347
|
break;
|
|
@@ -269,6 +352,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
269
352
|
case 'encrypt':
|
|
270
353
|
await handleEncryptNotification(node);
|
|
271
354
|
break;
|
|
355
|
+
case 'newsletter':
|
|
356
|
+
// TO DO
|
|
357
|
+
break;
|
|
272
358
|
case 'devices':
|
|
273
359
|
const devices = (0, WABinary_1.getBinaryNodeChildren)(child, 'device');
|
|
274
360
|
if ((0, WABinary_1.areJidsSameUser)(child.attrs.jid, authState.creds.me.id)) {
|
|
@@ -287,7 +373,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
287
373
|
const setPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'set');
|
|
288
374
|
const delPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'delete');
|
|
289
375
|
ev.emit('contacts.update', [{
|
|
290
|
-
id: (0, WABinary_1.jidNormalizedUser)((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.
|
|
376
|
+
id: (0, WABinary_1.jidNormalizedUser)((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.from) || ((_c = (_b = (setPicture || delPicture)) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.hash) || '',
|
|
291
377
|
imgUrl: setPicture ? 'changed' : 'removed'
|
|
292
378
|
}]);
|
|
293
379
|
if ((0, WABinary_1.isJidGroup)(from)) {
|
|
@@ -332,7 +418,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
332
418
|
const ref = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'link_code_pairing_ref'));
|
|
333
419
|
const primaryIdentityPublicKey = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'primary_identity_pub'));
|
|
334
420
|
const primaryEphemeralPublicKeyWrapped = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'link_code_pairing_wrapped_primary_ephemeral_pub'));
|
|
335
|
-
const codePairingPublicKey = decipherLinkPublicKey(primaryEphemeralPublicKeyWrapped);
|
|
421
|
+
const codePairingPublicKey = await decipherLinkPublicKey(primaryEphemeralPublicKeyWrapped);
|
|
336
422
|
const companionSharedKey = Utils_1.Curve.sharedKey(authState.creds.pairingEphemeralKeyPair.private, codePairingPublicKey);
|
|
337
423
|
const random = (0, crypto_1.randomBytes)(32);
|
|
338
424
|
const linkCodeSalt = (0, crypto_1.randomBytes)(32);
|
|
@@ -389,10 +475,10 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
389
475
|
return result;
|
|
390
476
|
}
|
|
391
477
|
};
|
|
392
|
-
function decipherLinkPublicKey(data) {
|
|
478
|
+
async function decipherLinkPublicKey(data) {
|
|
393
479
|
const buffer = toRequiredBuffer(data);
|
|
394
480
|
const salt = buffer.slice(0, 32);
|
|
395
|
-
const secretKey = (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
481
|
+
const secretKey = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
396
482
|
const iv = buffer.slice(32, 48);
|
|
397
483
|
const payload = buffer.slice(48, 80);
|
|
398
484
|
return (0, Utils_1.aesDecryptCTR)(payload, secretKey, iv);
|
|
@@ -461,7 +547,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
461
547
|
fromMe,
|
|
462
548
|
participant: attrs.participant
|
|
463
549
|
};
|
|
464
|
-
if (shouldIgnoreJid(remoteJid)) {
|
|
550
|
+
if (shouldIgnoreJid(remoteJid) && remoteJid !== '@s.whatsapp.net') {
|
|
465
551
|
logger.debug({ remoteJid }, 'ignoring receipt from jid');
|
|
466
552
|
await sendMessageAck(node);
|
|
467
553
|
return;
|
|
@@ -480,7 +566,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
480
566
|
// or another device of ours has read some messages
|
|
481
567
|
status > WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK ||
|
|
482
568
|
!isNodeFromMe)) {
|
|
483
|
-
if ((0, WABinary_1.isJidGroup)(remoteJid)) {
|
|
569
|
+
if ((0, WABinary_1.isJidGroup)(remoteJid) || (0, WABinary_1.isJidStatusBroadcast)(remoteJid)) {
|
|
484
570
|
if (attrs.participant) {
|
|
485
571
|
const updateKey = status === WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK ? 'receiptTimestamp' : 'readTimestamp';
|
|
486
572
|
ev.emit('message-receipt.update', ids.map(id => ({
|
|
@@ -527,7 +613,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
527
613
|
};
|
|
528
614
|
const handleNotification = async (node) => {
|
|
529
615
|
const remoteJid = node.attrs.from;
|
|
530
|
-
if (shouldIgnoreJid(remoteJid)) {
|
|
616
|
+
if (shouldIgnoreJid(remoteJid) && remoteJid !== '@s.whatsapp.net') {
|
|
531
617
|
logger.debug({ remoteJid, id: node.attrs.id }, 'ignored notification');
|
|
532
618
|
await sendMessageAck(node);
|
|
533
619
|
return;
|
|
@@ -555,18 +641,41 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
555
641
|
]);
|
|
556
642
|
};
|
|
557
643
|
const handleMessage = async (node) => {
|
|
558
|
-
var _a, _b;
|
|
644
|
+
var _a, _b, _c;
|
|
645
|
+
if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
|
|
646
|
+
if (ignoreMsgLoading && node.attrs.offline) {
|
|
647
|
+
logger.debug({ key: node.attrs.key }, 'ignored offline message');
|
|
648
|
+
await sendMessageAck(node);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
logger.debug({ key: node.attrs.key }, 'ignored message');
|
|
652
|
+
await sendMessageAck(node);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
let response;
|
|
656
|
+
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !(0, WABinary_1.getBinaryNodeChild)(node, 'enc')) {
|
|
657
|
+
await sendMessageAck(node);
|
|
658
|
+
const { key } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '').fullMessage;
|
|
659
|
+
response = await requestPlaceholderResend(key);
|
|
660
|
+
if (response === 'RESOLVED') {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
logger.debug('received unavailable message, acked and requested resend from phone');
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
if (placeholderResendCache.get(node.attrs.id)) {
|
|
667
|
+
placeholderResendCache.del(node.attrs.id);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
559
670
|
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
|
|
560
|
-
if (
|
|
671
|
+
if (response && ((_a = msg === null || msg === void 0 ? void 0 : msg.messageStubParameters) === null || _a === void 0 ? void 0 : _a[0]) === Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT) {
|
|
672
|
+
msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
|
|
673
|
+
}
|
|
674
|
+
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
|
|
561
675
|
if (node.attrs.sender_pn) {
|
|
562
676
|
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
|
|
563
677
|
}
|
|
564
678
|
}
|
|
565
|
-
if (shouldIgnoreJid(msg.key.remoteJid)) {
|
|
566
|
-
logger.debug({ key: msg.key }, 'ignored message');
|
|
567
|
-
await sendMessageAck(node);
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
679
|
await Promise.all([
|
|
571
680
|
processingMutex.mutex(async () => {
|
|
572
681
|
await decrypt();
|
|
@@ -574,6 +683,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
574
683
|
if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
|
575
684
|
retryMutex.mutex(async () => {
|
|
576
685
|
if (ws.isOpen) {
|
|
686
|
+
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable')) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
577
689
|
const encNode = (0, WABinary_1.getBinaryNodeChild)(node, 'enc');
|
|
578
690
|
await sendRetryRequest(node, !encNode);
|
|
579
691
|
if (retryRequestDelayMs) {
|
|
@@ -616,6 +728,54 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
616
728
|
sendMessageAck(node)
|
|
617
729
|
]);
|
|
618
730
|
};
|
|
731
|
+
const fetchMessageHistory = async (count, oldestMsgKey, oldestMsgTimestamp) => {
|
|
732
|
+
var _a;
|
|
733
|
+
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
734
|
+
throw new boom_1.Boom('Not authenticated');
|
|
735
|
+
}
|
|
736
|
+
const pdoMessage = {
|
|
737
|
+
historySyncOnDemandRequest: {
|
|
738
|
+
chatJid: oldestMsgKey.remoteJid,
|
|
739
|
+
oldestMsgFromMe: oldestMsgKey.fromMe,
|
|
740
|
+
oldestMsgId: oldestMsgKey.id,
|
|
741
|
+
oldestMsgTimestampMs: oldestMsgTimestamp,
|
|
742
|
+
onDemandMsgCount: count
|
|
743
|
+
},
|
|
744
|
+
peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.HISTORY_SYNC_ON_DEMAND
|
|
745
|
+
};
|
|
746
|
+
return sendPeerDataOperationMessage(pdoMessage);
|
|
747
|
+
};
|
|
748
|
+
const requestPlaceholderResend = async (messageKey) => {
|
|
749
|
+
var _a;
|
|
750
|
+
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
751
|
+
throw new boom_1.Boom('Not authenticated');
|
|
752
|
+
}
|
|
753
|
+
if (placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
754
|
+
logger.debug('already requested resend', { messageKey });
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
placeholderResendCache.set(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id, true);
|
|
759
|
+
}
|
|
760
|
+
await (0, Utils_1.delay)(5000);
|
|
761
|
+
if (!placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
762
|
+
logger.debug('message received while resend requested', { messageKey });
|
|
763
|
+
return 'RESOLVED';
|
|
764
|
+
}
|
|
765
|
+
const pdoMessage = {
|
|
766
|
+
placeholderMessageResendRequest: [{
|
|
767
|
+
messageKey
|
|
768
|
+
}],
|
|
769
|
+
peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND
|
|
770
|
+
};
|
|
771
|
+
setTimeout(() => {
|
|
772
|
+
if (placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
773
|
+
logger.debug('PDO message without response after 15 seconds. Phone possibly offline', { messageKey });
|
|
774
|
+
placeholderResendCache.del(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id);
|
|
775
|
+
}
|
|
776
|
+
}, 15000);
|
|
777
|
+
return sendPeerDataOperationMessage(pdoMessage);
|
|
778
|
+
};
|
|
619
779
|
const handleCall = async (node) => {
|
|
620
780
|
const { attrs } = node;
|
|
621
781
|
const [infoChild] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
@@ -650,7 +810,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
650
810
|
await sendMessageAck(node);
|
|
651
811
|
};
|
|
652
812
|
const handleBadAck = async ({ attrs }) => {
|
|
653
|
-
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id };
|
|
813
|
+
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, server_id: attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
|
|
654
814
|
// current hypothesis is that if pash is sent in the ack
|
|
655
815
|
// it means -- the message hasn't reached all devices yet
|
|
656
816
|
// we'll retry sending the message here
|
|
@@ -745,7 +905,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
745
905
|
...sock,
|
|
746
906
|
sendMessageAck,
|
|
747
907
|
sendRetryRequest,
|
|
748
|
-
rejectCall
|
|
908
|
+
rejectCall,
|
|
909
|
+
fetchMessageHistory,
|
|
910
|
+
requestPlaceholderResend,
|
|
749
911
|
};
|
|
750
912
|
};
|
|
751
913
|
exports.makeMessagesRecvSocket = makeMessagesRecvSocket;
|