kage-baileys 25.3.35 → 25.3.36
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.
|
@@ -110,4 +110,89 @@ export function binaryNodeToString(node, i = 0) {
|
|
|
110
110
|
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
|
111
111
|
return tag + content;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Builds the <biz> binary node required for interactive / native flow / carousel messages.
|
|
116
|
+
* Used by Builders (Button, Carousel, A2UI, etc.) when calling relayMessage with additionalNodes.
|
|
117
|
+
*/
|
|
118
|
+
const BIZ_SPECIAL = new Set([
|
|
119
|
+
'mpm',
|
|
120
|
+
'cta_catalog',
|
|
121
|
+
'send_location',
|
|
122
|
+
'call_permission_request',
|
|
123
|
+
'wa_payment_transaction_details',
|
|
124
|
+
'automated_greeting_message_view_catalog'
|
|
125
|
+
]);
|
|
126
|
+
|
|
127
|
+
const UNWRAP_KEYS = [
|
|
128
|
+
'viewOnceMessage',
|
|
129
|
+
'viewOnceMessageV2',
|
|
130
|
+
'viewOnceMessageV2Extension',
|
|
131
|
+
'ephemeralMessage',
|
|
132
|
+
'documentWithCaptionMessage'
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
function unwrapMessage(message) {
|
|
136
|
+
const seen = new Set();
|
|
137
|
+
while (message && typeof message === 'object') {
|
|
138
|
+
if (seen.has(message)) break;
|
|
139
|
+
seen.add(message);
|
|
140
|
+
const key = UNWRAP_KEYS.find(k => message[k]?.message);
|
|
141
|
+
if (!key) return message;
|
|
142
|
+
message = message[key].message;
|
|
143
|
+
}
|
|
144
|
+
return message;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function getBizBinaryNode(message) {
|
|
148
|
+
const inner = unwrapMessage(message);
|
|
149
|
+
const interactive = inner?.interactiveMessage;
|
|
150
|
+
if (!interactive) {
|
|
151
|
+
// Fallback node so callers that always push [getBizBinaryNode(...)] don't put undefined
|
|
152
|
+
return { tag: 'biz', attrs: {} };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const flow = interactive.nativeFlowMessage;
|
|
156
|
+
const carousel = interactive.carouselMessage;
|
|
157
|
+
if (!carousel && !flow) {
|
|
158
|
+
return { tag: 'biz', attrs: {} };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (carousel) {
|
|
162
|
+
return {
|
|
163
|
+
tag: 'biz',
|
|
164
|
+
attrs: {},
|
|
165
|
+
content: [{
|
|
166
|
+
tag: 'interactive',
|
|
167
|
+
attrs: { type: 'native_flow', v: '1' },
|
|
168
|
+
content: [{ tag: 'native_flow', attrs: { v: '9', name: 'mixed' } }]
|
|
169
|
+
}]
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const buttons = flow?.buttons || [];
|
|
174
|
+
const name = buttons[0]?.name;
|
|
175
|
+
const uniform = buttons.length > 0 && buttons.every(b => b.name === name);
|
|
176
|
+
|
|
177
|
+
if (uniform && (name === 'review_and_pay' || name === 'payment_info' || name === 'payment_method' || name === 'payment_status')) {
|
|
178
|
+
return {
|
|
179
|
+
tag: 'biz',
|
|
180
|
+
attrs: { native_flow_name: name === 'review_and_pay' ? 'order_details' : name }
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const specialized = uniform && BIZ_SPECIAL.has(name);
|
|
185
|
+
return {
|
|
186
|
+
tag: 'biz',
|
|
187
|
+
attrs: {},
|
|
188
|
+
content: [{
|
|
189
|
+
tag: 'interactive',
|
|
190
|
+
attrs: { type: 'native_flow', v: '1' },
|
|
191
|
+
content: [{
|
|
192
|
+
tag: 'native_flow',
|
|
193
|
+
attrs: { v: specialized ? '2' : '9', name: specialized ? name : 'mixed' }
|
|
194
|
+
}]
|
|
195
|
+
}]
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=generic-utils.js.map
|