n8n-nodes-mautic-advanced 0.3.4 → 0.3.6
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.
|
@@ -188,7 +188,7 @@ async function editDoNotContactList(context, itemIndex) {
|
|
|
188
188
|
const action = (0, ApiHelpers_1.getRequiredParam)(context, 'action', itemIndex);
|
|
189
189
|
const channel = (0, ApiHelpers_1.getRequiredParam)(context, 'channel', itemIndex);
|
|
190
190
|
const body = { action, channel };
|
|
191
|
-
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', `/contacts/${contactId}/dnc/${
|
|
191
|
+
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', `/contacts/${contactId}/dnc/${channel}/${action}`, body);
|
|
192
192
|
return response.contact;
|
|
193
193
|
}
|
|
194
194
|
async function addUtmTags(context, itemIndex) {
|
|
@@ -262,6 +262,47 @@ async function getContactCompanies(context, itemIndex) {
|
|
|
262
262
|
const contactId = (0, ApiHelpers_1.getRequiredParam)(context, 'contactId', itemIndex);
|
|
263
263
|
return await (0, ApiHelpers_1.makePaginatedRequest)(context, 'companies', 'GET', `/contacts/${contactId}/companies`);
|
|
264
264
|
}
|
|
265
|
+
function normalizeTagsInput(tagsInput) {
|
|
266
|
+
// Handle different input formats for tags
|
|
267
|
+
// If it's already an array of strings, return as is
|
|
268
|
+
if (Array.isArray(tagsInput) && tagsInput.every((tag) => typeof tag === 'string')) {
|
|
269
|
+
return tagsInput;
|
|
270
|
+
}
|
|
271
|
+
// If it's a string, split by comma
|
|
272
|
+
if (typeof tagsInput === 'string') {
|
|
273
|
+
return tagsInput
|
|
274
|
+
.split(',')
|
|
275
|
+
.map((tag) => tag.trim())
|
|
276
|
+
.filter((tag) => tag.length > 0);
|
|
277
|
+
}
|
|
278
|
+
// If it's an array of objects with 'tag' property
|
|
279
|
+
if (Array.isArray(tagsInput) && tagsInput.every((item) => typeof item === 'object' && item.tag)) {
|
|
280
|
+
return tagsInput.map((item) => item.tag);
|
|
281
|
+
}
|
|
282
|
+
// If it's a complex object (like user's input with inputA/inputB)
|
|
283
|
+
if (typeof tagsInput === 'object' && tagsInput !== null) {
|
|
284
|
+
const tags = [];
|
|
285
|
+
// Handle inputA and inputB structure
|
|
286
|
+
if (tagsInput.inputA && Array.isArray(tagsInput.inputA)) {
|
|
287
|
+
tags.push(...tagsInput.inputA.map((item) => item.tag || item).filter(Boolean));
|
|
288
|
+
}
|
|
289
|
+
if (tagsInput.inputB && Array.isArray(tagsInput.inputB)) {
|
|
290
|
+
tags.push(...tagsInput.inputB.map((item) => item.tag || item).filter(Boolean));
|
|
291
|
+
}
|
|
292
|
+
// If no inputA/inputB, try to extract from any array properties
|
|
293
|
+
if (tags.length === 0) {
|
|
294
|
+
Object.values(tagsInput).forEach((value) => {
|
|
295
|
+
if (Array.isArray(value)) {
|
|
296
|
+
tags.push(...value.map((item) => item.tag || item).filter(Boolean));
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
// Remove duplicates and return
|
|
301
|
+
return [...new Set(tags)];
|
|
302
|
+
}
|
|
303
|
+
// Fallback: return empty array
|
|
304
|
+
return [];
|
|
305
|
+
}
|
|
265
306
|
function addContactFields(body, fields) {
|
|
266
307
|
const addressUi = fields.addressUi;
|
|
267
308
|
if (addressUi?.addressValues) {
|
|
@@ -296,7 +337,7 @@ function addContactFields(body, fields) {
|
|
|
296
337
|
if (fields.preferredChannel)
|
|
297
338
|
body.preferred_channel = fields.preferredChannel;
|
|
298
339
|
if (fields.tags)
|
|
299
|
-
body.tags = fields.tags
|
|
340
|
+
body.tags = normalizeTagsInput(fields.tags);
|
|
300
341
|
const customFieldsUi = fields.customFieldsUi;
|
|
301
342
|
if (customFieldsUi?.customFieldValues) {
|
|
302
343
|
const { customFieldValues } = customFieldsUi;
|
package/package.json
CHANGED