@itsliaaa/baileys 0.1.16-beta.1 → 0.1.16-beta.2
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 +14 -4
- package/WAProto/index.js +1082 -5
- package/lib/Socket/messages-send.js +7 -4
- package/lib/Utils/messages.js +1 -1
- package/lib/WABinary/generic-utils.js +15 -10
- package/package.json +1 -1
|
@@ -429,7 +429,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
429
429
|
}
|
|
430
430
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
431
431
|
};
|
|
432
|
-
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }) => {
|
|
432
|
+
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, addBizAttributes, statusJidList }) => {
|
|
433
433
|
const meId = authState.creds.me.id;
|
|
434
434
|
const meLid = authState.creds.me?.lid;
|
|
435
435
|
const isRetryResend = !!participant?.jid;
|
|
@@ -802,8 +802,8 @@ export const makeMessagesSocket = (config) => {
|
|
|
802
802
|
stanza.content.push(...additionalNodes);
|
|
803
803
|
}
|
|
804
804
|
// Lia@Changes 30-01-26 --- Add Biz Binary Node to support button messages
|
|
805
|
-
if (shouldIncludeBizBinaryNode(innerMessage)) {
|
|
806
|
-
const bizNode = getBizBinaryNode(innerMessage);
|
|
805
|
+
if (shouldIncludeBizBinaryNode(innerMessage) || addBizAttributes) {
|
|
806
|
+
const bizNode = getBizBinaryNode(innerMessage, addBizAttributes);
|
|
807
807
|
stanza.content.push(bizNode);
|
|
808
808
|
}
|
|
809
809
|
logger.debug({ msgId }, `sending message to ${participants.length} devices`);
|
|
@@ -1124,6 +1124,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
1124
1124
|
const isPollResultMsg = 'pollResult' in content && !!content.pollResult;
|
|
1125
1125
|
const isPollUpdateMsg = 'pollUpdate' in content && !!content.pollUpdate;
|
|
1126
1126
|
const isAiMsg = 'ai' in content && !!content.ai;
|
|
1127
|
+
const isNeedBizAttrs = 'secureMetaServiceLabel' in content && !!content.secureMetaServiceLabel;
|
|
1127
1128
|
const additionalAttributes = options.additionalAttributes || {};
|
|
1128
1129
|
const additionalNodes = options.additionalNodes || [];
|
|
1129
1130
|
// required for delete
|
|
@@ -1143,7 +1144,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
1143
1144
|
additionalAttributes.edit = '2';
|
|
1144
1145
|
}
|
|
1145
1146
|
else if (isPollMsg) {
|
|
1146
|
-
if (!
|
|
1147
|
+
if (!isNewsletter && isQuizMsg) {
|
|
1147
1148
|
throw new Boom('Quiz are only allowed for newsletter', { statusCode: 400 });
|
|
1148
1149
|
}
|
|
1149
1150
|
additionalNodes.push({
|
|
@@ -1185,6 +1186,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
1185
1186
|
await relayMessage(jid, fullMsg.message, {
|
|
1186
1187
|
messageId: fullMsg.key.id,
|
|
1187
1188
|
useCachedGroupMetadata: options.useCachedGroupMetadata,
|
|
1189
|
+
addBizAttributes: isNeedBizAttrs,
|
|
1188
1190
|
statusJidList: options.statusJidList,
|
|
1189
1191
|
additionalAttributes,
|
|
1190
1192
|
additionalNodes
|
|
@@ -1219,6 +1221,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
1219
1221
|
await relayMessage(jid, albumMsg.message, {
|
|
1220
1222
|
messageId: albumMsg.key.id,
|
|
1221
1223
|
useCachedGroupMetadata: options.useCachedGroupMetadata,
|
|
1224
|
+
addBizAttributes: isNeedBizAttrs,
|
|
1222
1225
|
statusJidList: options.statusJidList,
|
|
1223
1226
|
additionalAttributes,
|
|
1224
1227
|
additionalNodes
|
package/lib/Utils/messages.js
CHANGED
|
@@ -122,7 +122,7 @@ export const prepareWAMessageMedia = async (message, options) => {
|
|
|
122
122
|
return obj;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
const isNewsletter =
|
|
125
|
+
const isNewsletter = isJidNewsletter(options.jid);
|
|
126
126
|
const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined';
|
|
127
127
|
const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') && typeof uploadData.jpegThumbnail === 'undefined';
|
|
128
128
|
const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true && typeof uploadData.waveform === 'undefined';
|
|
@@ -153,7 +153,8 @@ const MIXED_NATIVE_FLOW = {
|
|
|
153
153
|
}
|
|
154
154
|
]
|
|
155
155
|
};
|
|
156
|
-
export const getBizBinaryNode = (message) => {
|
|
156
|
+
export const getBizBinaryNode = (message, addBizAttributes) => {
|
|
157
|
+
const bizAttributes = {};
|
|
157
158
|
const flowMsg = message.interactiveMessage?.nativeFlowMessage;
|
|
158
159
|
const firstButtonName = flowMsg?.buttons?.[0]?.name;
|
|
159
160
|
const qualityContent = {
|
|
@@ -164,21 +165,25 @@ export const getBizBinaryNode = (message) => {
|
|
|
164
165
|
},
|
|
165
166
|
content: DECISION_SOURCE_CONTENT
|
|
166
167
|
};
|
|
168
|
+
if (addBizAttributes) {
|
|
169
|
+
bizAttributes.actual_actors = '2';
|
|
170
|
+
bizAttributes.host_storage = '2';
|
|
171
|
+
bizAttributes.privacy_mode_ts = `${Date.now() / 1_000 | 0}`;
|
|
172
|
+
}
|
|
167
173
|
if (firstButtonName === 'review_and_pay' || firstButtonName === 'payment_info') {
|
|
174
|
+
bizAttributes.native_flow_name = firstButtonName === 'review_and_pay' ?
|
|
175
|
+
'order_details' :
|
|
176
|
+
firstButtonName;
|
|
168
177
|
return {
|
|
169
178
|
tag: 'biz',
|
|
170
|
-
attrs:
|
|
171
|
-
native_flow_name: firstButtonName === 'review_and_pay' ?
|
|
172
|
-
'order_details' :
|
|
173
|
-
firstButtonName
|
|
174
|
-
},
|
|
179
|
+
attrs: bizAttributes,
|
|
175
180
|
content: [qualityContent]
|
|
176
181
|
};
|
|
177
182
|
}
|
|
178
183
|
if (firstButtonName && FLOWS_MAP[firstButtonName]) {
|
|
179
184
|
return {
|
|
180
185
|
tag: 'biz',
|
|
181
|
-
attrs:
|
|
186
|
+
attrs: bizAttributes,
|
|
182
187
|
content: [
|
|
183
188
|
{
|
|
184
189
|
tag: 'interactive',
|
|
@@ -197,7 +202,7 @@ export const getBizBinaryNode = (message) => {
|
|
|
197
202
|
if (flowMsg || message.buttonsMessage || message.templateMessage) {
|
|
198
203
|
return {
|
|
199
204
|
tag: 'biz',
|
|
200
|
-
attrs:
|
|
205
|
+
attrs: bizAttributes,
|
|
201
206
|
content: [
|
|
202
207
|
MIXED_NATIVE_FLOW,
|
|
203
208
|
qualityContent
|
|
@@ -207,7 +212,7 @@ export const getBizBinaryNode = (message) => {
|
|
|
207
212
|
if (message.listMessage) {
|
|
208
213
|
return {
|
|
209
214
|
tag: 'biz',
|
|
210
|
-
attrs:
|
|
215
|
+
attrs: bizAttributes,
|
|
211
216
|
content: [
|
|
212
217
|
LIST_TYPE_CONTENT,
|
|
213
218
|
qualityContent
|
|
@@ -216,7 +221,7 @@ export const getBizBinaryNode = (message) => {
|
|
|
216
221
|
}
|
|
217
222
|
return {
|
|
218
223
|
tag: 'biz',
|
|
219
|
-
attrs:
|
|
224
|
+
attrs: bizAttributes,
|
|
220
225
|
content: [qualityContent]
|
|
221
226
|
};
|
|
222
227
|
}
|