strapi-plugin-magic-mail 2.10.8 → 2.10.10
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/CHANGELOG.md +14 -0
- package/dist/_chunks/{App-cpuAww_Y.js → App-CInlcJMb.js} +15 -3
- package/dist/_chunks/{App-CDFT2wYy.mjs → App-D4bFKNcg.mjs} +15 -3
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +134 -76
- package/dist/server/index.mjs +134 -76
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.10.10](https://github.com/Schero94/Magic-Mail/compare/v2.10.9...v2.10.10) (2026-04-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **validation:** auto-strip Strapi system metadata before .strict() check ([039b889](https://github.com/Schero94/Magic-Mail/commit/039b889d96d6a076e199bec7497304c6900b8165))
|
|
7
|
+
|
|
8
|
+
## [2.10.9](https://github.com/Schero94/Magic-Mail/compare/v2.10.8...v2.10.9) (2026-04-21)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **email-designer:** resolve PUT 500s on template update by whitelisting payload + proper error propagation ([29dd0c0](https://github.com/Schero94/Magic-Mail/commit/29dd0c0f6744a87108323ba511246502c5c3fc84))
|
|
14
|
+
|
|
1
15
|
## [2.10.8](https://github.com/Schero94/Magic-Mail/compare/v2.10.7...v2.10.8) (2026-04-21)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -6442,12 +6442,24 @@ const EditorPage = () => {
|
|
|
6442
6442
|
setSaving(false);
|
|
6443
6443
|
return;
|
|
6444
6444
|
}
|
|
6445
|
+
const refIdRaw = templateData.templateReferenceId;
|
|
6446
|
+
const refIdParsed = refIdRaw === "" || refIdRaw === null || refIdRaw === void 0 ? void 0 : Number.parseInt(refIdRaw, 10);
|
|
6445
6447
|
const payload = {
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
+
name: templateData.name,
|
|
6449
|
+
subject: templateData.subject,
|
|
6448
6450
|
bodyHtml,
|
|
6449
|
-
|
|
6451
|
+
bodyText: templateData.bodyText,
|
|
6452
|
+
design,
|
|
6453
|
+
category: templateData.category,
|
|
6454
|
+
isActive: templateData.isActive,
|
|
6455
|
+
tags: templateData.tags
|
|
6450
6456
|
};
|
|
6457
|
+
if (Number.isFinite(refIdParsed)) {
|
|
6458
|
+
payload.templateReferenceId = refIdParsed;
|
|
6459
|
+
}
|
|
6460
|
+
Object.keys(payload).forEach((k) => {
|
|
6461
|
+
if (payload[k] === void 0) delete payload[k];
|
|
6462
|
+
});
|
|
6451
6463
|
let response;
|
|
6452
6464
|
if (isNewTemplate) {
|
|
6453
6465
|
response = await post("/magic-mail/designer/templates", payload);
|
|
@@ -6419,12 +6419,24 @@ const EditorPage = () => {
|
|
|
6419
6419
|
setSaving(false);
|
|
6420
6420
|
return;
|
|
6421
6421
|
}
|
|
6422
|
+
const refIdRaw = templateData.templateReferenceId;
|
|
6423
|
+
const refIdParsed = refIdRaw === "" || refIdRaw === null || refIdRaw === void 0 ? void 0 : Number.parseInt(refIdRaw, 10);
|
|
6422
6424
|
const payload = {
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
+
name: templateData.name,
|
|
6426
|
+
subject: templateData.subject,
|
|
6425
6427
|
bodyHtml,
|
|
6426
|
-
|
|
6428
|
+
bodyText: templateData.bodyText,
|
|
6429
|
+
design,
|
|
6430
|
+
category: templateData.category,
|
|
6431
|
+
isActive: templateData.isActive,
|
|
6432
|
+
tags: templateData.tags
|
|
6427
6433
|
};
|
|
6434
|
+
if (Number.isFinite(refIdParsed)) {
|
|
6435
|
+
payload.templateReferenceId = refIdParsed;
|
|
6436
|
+
}
|
|
6437
|
+
Object.keys(payload).forEach((k) => {
|
|
6438
|
+
if (payload[k] === void 0) delete payload[k];
|
|
6439
|
+
});
|
|
6428
6440
|
let response;
|
|
6429
6441
|
if (isNewTemplate) {
|
|
6430
6442
|
response = await post("/magic-mail/designer/templates", payload);
|
package/dist/admin/index.js
CHANGED
|
@@ -68,7 +68,7 @@ const index = {
|
|
|
68
68
|
id: `${pluginId}.plugin.name`,
|
|
69
69
|
defaultMessage: "MagicMail"
|
|
70
70
|
},
|
|
71
|
-
Component: () => Promise.resolve().then(() => require("../_chunks/App-
|
|
71
|
+
Component: () => Promise.resolve().then(() => require("../_chunks/App-CInlcJMb.js")),
|
|
72
72
|
permissions: pluginPermissions
|
|
73
73
|
});
|
|
74
74
|
app.createSettingSection(
|
package/dist/admin/index.mjs
CHANGED
|
@@ -67,7 +67,7 @@ const index = {
|
|
|
67
67
|
id: `${pluginId}.plugin.name`,
|
|
68
68
|
defaultMessage: "MagicMail"
|
|
69
69
|
},
|
|
70
|
-
Component: () => import("../_chunks/App-
|
|
70
|
+
Component: () => import("../_chunks/App-D4bFKNcg.mjs"),
|
|
71
71
|
permissions: pluginPermissions
|
|
72
72
|
});
|
|
73
73
|
app.createSettingSection(
|
package/dist/server/index.js
CHANGED
|
@@ -1118,29 +1118,30 @@ const schemas = {
|
|
|
1118
1118
|
// a number via parseInt() before POSTing. Accepting both shapes
|
|
1119
1119
|
// keeps the wizard working either way — the service layer stores
|
|
1120
1120
|
// the DB column as a string regardless.
|
|
1121
|
-
templateReferenceId: z.union([safeString, z.number().int().nonnegative()]).optional(),
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
bodyText
|
|
1121
|
+
templateReferenceId: z.union([safeString, z.number().int().nonnegative()]).optional().nullable(),
|
|
1122
|
+
// Optional/nullable mirrors the content-type schema: Strapi serves
|
|
1123
|
+
// absent DB columns as `null`, and the editor re-sends the whole
|
|
1124
|
+
// document on save. Accepting null avoids spurious 400s whenever a
|
|
1125
|
+
// template has no category/bodyText/tags yet.
|
|
1126
|
+
name: safeString.optional().nullable(),
|
|
1127
|
+
subject: headerSafe.optional().nullable(),
|
|
1128
|
+
bodyHtml: safeText.optional().nullable(),
|
|
1129
|
+
bodyText: safeText.optional().nullable(),
|
|
1126
1130
|
design: z.record(z.unknown()).optional().nullable(),
|
|
1127
|
-
category: safeString.optional(),
|
|
1128
|
-
isActive: z.boolean().optional(),
|
|
1129
|
-
tags: z.array(safeString).max(50).optional()
|
|
1131
|
+
category: safeString.optional().nullable(),
|
|
1132
|
+
isActive: z.boolean().optional().nullable(),
|
|
1133
|
+
tags: z.array(safeString).max(50).optional().nullable()
|
|
1130
1134
|
}).strict(),
|
|
1131
1135
|
"emailDesigner.update": z.object({
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
subject: headerSafe.optional(),
|
|
1138
|
-
bodyHtml: safeText.optional(),
|
|
1139
|
-
bodyText: safeText.optional(),
|
|
1136
|
+
templateReferenceId: z.union([safeString, z.number().int().nonnegative()]).optional().nullable(),
|
|
1137
|
+
name: safeString.optional().nullable(),
|
|
1138
|
+
subject: headerSafe.optional().nullable(),
|
|
1139
|
+
bodyHtml: safeText.optional().nullable(),
|
|
1140
|
+
bodyText: safeText.optional().nullable(),
|
|
1140
1141
|
design: z.record(z.unknown()).optional().nullable(),
|
|
1141
|
-
category: safeString.optional(),
|
|
1142
|
-
isActive: z.boolean().optional(),
|
|
1143
|
-
tags: z.array(safeString).max(50).optional()
|
|
1142
|
+
category: safeString.optional().nullable(),
|
|
1143
|
+
isActive: z.boolean().optional().nullable(),
|
|
1144
|
+
tags: z.array(safeString).max(50).optional().nullable()
|
|
1144
1145
|
}).strict(),
|
|
1145
1146
|
"emailDesigner.renderTemplate": z.object({
|
|
1146
1147
|
data: z.record(z.unknown()).optional()
|
|
@@ -1255,16 +1256,52 @@ const schemas = {
|
|
|
1255
1256
|
phoneNumber: z.string().min(5).max(32).regex(/^[\d+\-() ]+$/)
|
|
1256
1257
|
})
|
|
1257
1258
|
};
|
|
1259
|
+
const STRAPI_METADATA_FIELDS = Object.freeze([
|
|
1260
|
+
"id",
|
|
1261
|
+
"documentId",
|
|
1262
|
+
"createdAt",
|
|
1263
|
+
"updatedAt",
|
|
1264
|
+
"publishedAt",
|
|
1265
|
+
"locale",
|
|
1266
|
+
"localizations",
|
|
1267
|
+
"createdBy",
|
|
1268
|
+
"updatedBy",
|
|
1269
|
+
"__component",
|
|
1270
|
+
// Populated relations/components we never want to round-trip as a write:
|
|
1271
|
+
"versions"
|
|
1272
|
+
]);
|
|
1273
|
+
function stripStrapiMetadata(body, schemaName) {
|
|
1274
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return body;
|
|
1275
|
+
const cleaned = { ...body };
|
|
1276
|
+
const removed = [];
|
|
1277
|
+
for (const key of STRAPI_METADATA_FIELDS) {
|
|
1278
|
+
if (key in cleaned) {
|
|
1279
|
+
delete cleaned[key];
|
|
1280
|
+
removed.push(key);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
if (removed.length > 0 && typeof strapi !== "undefined" && strapi?.log?.debug) {
|
|
1284
|
+
strapi.log.debug(
|
|
1285
|
+
`[magic-mail] Stripped Strapi metadata from ${schemaName} payload: ${removed.join(", ")}`
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1288
|
+
return cleaned;
|
|
1289
|
+
}
|
|
1258
1290
|
function validate$5(schemaName, body) {
|
|
1259
1291
|
const schema = schemas[schemaName];
|
|
1260
1292
|
if (!schema) {
|
|
1261
1293
|
throw new Error(`Unknown validation schema: ${schemaName}`);
|
|
1262
1294
|
}
|
|
1263
|
-
const
|
|
1295
|
+
const sanitized = stripStrapiMetadata(body, schemaName);
|
|
1296
|
+
const result2 = schema.safeParse(sanitized);
|
|
1264
1297
|
if (!result2.success) {
|
|
1265
1298
|
const strapiErrors = require$$1__default.default.errors;
|
|
1266
1299
|
const flattened = result2.error.flatten();
|
|
1267
1300
|
const strapiLog = typeof strapi !== "undefined" && strapi && strapi.log ? strapi.log : null;
|
|
1301
|
+
const details = { ...flattened.fieldErrors };
|
|
1302
|
+
if (Array.isArray(flattened.formErrors) && flattened.formErrors.length > 0) {
|
|
1303
|
+
details._form = flattened.formErrors;
|
|
1304
|
+
}
|
|
1268
1305
|
if (strapiLog) {
|
|
1269
1306
|
strapiLog.warn(
|
|
1270
1307
|
`[magic-mail] Validation failed for schema '${schemaName}': ` + JSON.stringify({
|
|
@@ -1273,23 +1310,38 @@ function validate$5(schemaName, body) {
|
|
|
1273
1310
|
})
|
|
1274
1311
|
);
|
|
1275
1312
|
}
|
|
1276
|
-
throw new strapiErrors.ValidationError("Validation failed",
|
|
1313
|
+
throw new strapiErrors.ValidationError("Validation failed", details);
|
|
1277
1314
|
}
|
|
1278
1315
|
return result2.data;
|
|
1279
1316
|
}
|
|
1280
|
-
function handleControllerError$
|
|
1281
|
-
const
|
|
1317
|
+
function handleControllerError$4(ctx, err, logPrefix, fallbackMessage) {
|
|
1318
|
+
const strapiErrors = require$$1__default.default.errors;
|
|
1319
|
+
const knownStrapiNames = /* @__PURE__ */ new Set([
|
|
1320
|
+
"ApplicationError",
|
|
1321
|
+
"ValidationError",
|
|
1322
|
+
"YupValidationError",
|
|
1323
|
+
"PaginationError",
|
|
1324
|
+
"NotFoundError",
|
|
1325
|
+
"ForbiddenError",
|
|
1326
|
+
"UnauthorizedError",
|
|
1327
|
+
"PayloadTooLargeError",
|
|
1328
|
+
"PolicyError",
|
|
1329
|
+
"NotImplementedError",
|
|
1330
|
+
"RateLimitError",
|
|
1331
|
+
"HttpError"
|
|
1332
|
+
]);
|
|
1333
|
+
const isStrapiError = err && typeof err === "object" && err instanceof strapiErrors.ApplicationError || err && typeof err.name === "string" && knownStrapiNames.has(err.name);
|
|
1282
1334
|
if (isStrapiError) {
|
|
1283
1335
|
strapi.log.warn(
|
|
1284
|
-
`${logPrefix}: ${err.name}
|
|
1336
|
+
`${logPrefix}: ${err.name} — ${err.message}` + (err.details && Object.keys(err.details).length > 0 ? ` | details=${JSON.stringify(err.details)}` : "")
|
|
1285
1337
|
);
|
|
1286
1338
|
throw err;
|
|
1287
1339
|
}
|
|
1288
1340
|
strapi.log.error(`${logPrefix}:`, err);
|
|
1289
1341
|
ctx.throw(500, fallbackMessage || err.message || "Internal server error");
|
|
1290
1342
|
}
|
|
1291
|
-
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$
|
|
1292
|
-
const { validate: validate$4, handleControllerError: handleControllerError$
|
|
1343
|
+
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$4 };
|
|
1344
|
+
const { validate: validate$4, handleControllerError: handleControllerError$3 } = validation;
|
|
1293
1345
|
function stripAttachmentPaths(body) {
|
|
1294
1346
|
if (body && Array.isArray(body.attachments)) {
|
|
1295
1347
|
body.attachments = body.attachments.map(({ path: path2, ...safe }) => safe);
|
|
@@ -1305,7 +1357,7 @@ var controller$1 = {
|
|
|
1305
1357
|
const result2 = await emailRouter2.send(body);
|
|
1306
1358
|
ctx.body = { success: true, ...result2 };
|
|
1307
1359
|
} catch (err) {
|
|
1308
|
-
handleControllerError$
|
|
1360
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending email", "Failed to send email");
|
|
1309
1361
|
}
|
|
1310
1362
|
},
|
|
1311
1363
|
async sendMessage(ctx) {
|
|
@@ -1316,7 +1368,7 @@ var controller$1 = {
|
|
|
1316
1368
|
const result2 = await emailRouter2.sendMessage(body);
|
|
1317
1369
|
ctx.body = { success: true, ...result2 };
|
|
1318
1370
|
} catch (err) {
|
|
1319
|
-
handleControllerError$
|
|
1371
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending message", "Failed to send message");
|
|
1320
1372
|
}
|
|
1321
1373
|
},
|
|
1322
1374
|
async sendWhatsApp(ctx) {
|
|
@@ -1326,7 +1378,7 @@ var controller$1 = {
|
|
|
1326
1378
|
const result2 = await emailRouter2.sendWhatsApp(body);
|
|
1327
1379
|
ctx.body = { success: true, ...result2 };
|
|
1328
1380
|
} catch (err) {
|
|
1329
|
-
handleControllerError$
|
|
1381
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending WhatsApp", "Failed to send WhatsApp message");
|
|
1330
1382
|
}
|
|
1331
1383
|
},
|
|
1332
1384
|
async getWhatsAppStatus(ctx) {
|
|
@@ -1354,11 +1406,11 @@ var controller$1 = {
|
|
|
1354
1406
|
const result2 = await emailRouter2.checkWhatsAppNumber(phoneNumber);
|
|
1355
1407
|
ctx.body = { success: true, data: result2 };
|
|
1356
1408
|
} catch (err) {
|
|
1357
|
-
handleControllerError$
|
|
1409
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error checking WhatsApp number", "Failed to check phone number");
|
|
1358
1410
|
}
|
|
1359
1411
|
}
|
|
1360
1412
|
};
|
|
1361
|
-
const { validate: validate$3, handleControllerError: handleControllerError$
|
|
1413
|
+
const { validate: validate$3, handleControllerError: handleControllerError$2 } = validation;
|
|
1362
1414
|
var accounts$1 = {
|
|
1363
1415
|
/**
|
|
1364
1416
|
* Get all email accounts
|
|
@@ -1401,7 +1453,7 @@ var accounts$1 = {
|
|
|
1401
1453
|
message: "Email account created successfully"
|
|
1402
1454
|
};
|
|
1403
1455
|
} catch (err) {
|
|
1404
|
-
handleControllerError$
|
|
1456
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error creating account", "Error creating email account");
|
|
1405
1457
|
}
|
|
1406
1458
|
},
|
|
1407
1459
|
/**
|
|
@@ -1419,7 +1471,7 @@ var accounts$1 = {
|
|
|
1419
1471
|
data: account
|
|
1420
1472
|
};
|
|
1421
1473
|
} catch (err) {
|
|
1422
|
-
handleControllerError$
|
|
1474
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error getting account", "Error fetching email account");
|
|
1423
1475
|
}
|
|
1424
1476
|
},
|
|
1425
1477
|
/**
|
|
@@ -1447,7 +1499,7 @@ var accounts$1 = {
|
|
|
1447
1499
|
message: "Email account updated successfully"
|
|
1448
1500
|
};
|
|
1449
1501
|
} catch (err) {
|
|
1450
|
-
handleControllerError$
|
|
1502
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error updating account", "Error updating email account");
|
|
1451
1503
|
}
|
|
1452
1504
|
},
|
|
1453
1505
|
/**
|
|
@@ -1467,7 +1519,7 @@ var accounts$1 = {
|
|
|
1467
1519
|
const result2 = await accountManager2.testAccount(accountId, recipientEmail, testOptions);
|
|
1468
1520
|
ctx.body = result2;
|
|
1469
1521
|
} catch (err) {
|
|
1470
|
-
handleControllerError$
|
|
1522
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error testing account", "Error testing email account");
|
|
1471
1523
|
}
|
|
1472
1524
|
},
|
|
1473
1525
|
/**
|
|
@@ -2116,7 +2168,7 @@ var oauth$3 = {
|
|
|
2116
2168
|
}
|
|
2117
2169
|
}
|
|
2118
2170
|
};
|
|
2119
|
-
const { handleControllerError } = validation;
|
|
2171
|
+
const { handleControllerError: handleControllerError$1 } = validation;
|
|
2120
2172
|
const ROUTING_RULE_UID = "plugin::magic-mail.routing-rule";
|
|
2121
2173
|
const ALLOWED_RULE_FIELDS = [
|
|
2122
2174
|
"name",
|
|
@@ -2152,7 +2204,7 @@ var routingRules$1 = {
|
|
|
2152
2204
|
data: rules
|
|
2153
2205
|
};
|
|
2154
2206
|
} catch (err) {
|
|
2155
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2207
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2156
2208
|
}
|
|
2157
2209
|
},
|
|
2158
2210
|
/**
|
|
@@ -2171,7 +2223,7 @@ var routingRules$1 = {
|
|
|
2171
2223
|
data: rule2
|
|
2172
2224
|
};
|
|
2173
2225
|
} catch (err) {
|
|
2174
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2226
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2175
2227
|
}
|
|
2176
2228
|
},
|
|
2177
2229
|
/**
|
|
@@ -2193,7 +2245,7 @@ var routingRules$1 = {
|
|
|
2193
2245
|
};
|
|
2194
2246
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule created: ${rule2.name}`);
|
|
2195
2247
|
} catch (err) {
|
|
2196
|
-
handleControllerError(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2248
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2197
2249
|
}
|
|
2198
2250
|
},
|
|
2199
2251
|
/**
|
|
@@ -2217,7 +2269,7 @@ var routingRules$1 = {
|
|
|
2217
2269
|
};
|
|
2218
2270
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule updated: ${rule2.name}`);
|
|
2219
2271
|
} catch (err) {
|
|
2220
|
-
handleControllerError(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2272
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2221
2273
|
}
|
|
2222
2274
|
},
|
|
2223
2275
|
/**
|
|
@@ -2238,7 +2290,7 @@ var routingRules$1 = {
|
|
|
2238
2290
|
};
|
|
2239
2291
|
strapi.log.info(`[magic-mail] Routing rule deleted: ${ruleId}`);
|
|
2240
2292
|
} catch (err) {
|
|
2241
|
-
handleControllerError(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2293
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2242
2294
|
}
|
|
2243
2295
|
}
|
|
2244
2296
|
};
|
|
@@ -2679,7 +2731,10 @@ var license$1 = ({ strapi: strapi2 }) => ({
|
|
|
2679
2731
|
}
|
|
2680
2732
|
}
|
|
2681
2733
|
});
|
|
2682
|
-
const { validate: validate$2 } = validation;
|
|
2734
|
+
const { validate: validate$2, handleControllerError } = validation;
|
|
2735
|
+
function isNotFoundMessage(err) {
|
|
2736
|
+
return err && typeof err.message === "string" && err.message.includes("not found");
|
|
2737
|
+
}
|
|
2683
2738
|
var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
2684
2739
|
/**
|
|
2685
2740
|
* Get all templates
|
|
@@ -2692,7 +2747,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2692
2747
|
data: templates
|
|
2693
2748
|
});
|
|
2694
2749
|
} catch (error) {
|
|
2695
|
-
ctx
|
|
2750
|
+
handleControllerError(ctx, error, "[magic-mail] Error listing templates");
|
|
2696
2751
|
}
|
|
2697
2752
|
},
|
|
2698
2753
|
/**
|
|
@@ -2710,7 +2765,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2710
2765
|
data: template
|
|
2711
2766
|
});
|
|
2712
2767
|
} catch (error) {
|
|
2713
|
-
ctx
|
|
2768
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching template");
|
|
2714
2769
|
}
|
|
2715
2770
|
},
|
|
2716
2771
|
/**
|
|
@@ -2724,10 +2779,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2724
2779
|
data: template
|
|
2725
2780
|
});
|
|
2726
2781
|
} catch (error) {
|
|
2727
|
-
if (error.message.includes("limit reached") || error.message.includes("already exists")) {
|
|
2782
|
+
if (error && typeof error.message === "string" && (error.message.includes("limit reached") || error.message.includes("already exists"))) {
|
|
2728
2783
|
return ctx.badRequest(error.message);
|
|
2729
2784
|
}
|
|
2730
|
-
ctx
|
|
2785
|
+
handleControllerError(ctx, error, "[magic-mail] Error creating template");
|
|
2731
2786
|
}
|
|
2732
2787
|
},
|
|
2733
2788
|
/**
|
|
@@ -2742,10 +2797,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2742
2797
|
data: template
|
|
2743
2798
|
});
|
|
2744
2799
|
} catch (error) {
|
|
2745
|
-
if (error
|
|
2800
|
+
if (isNotFoundMessage(error)) {
|
|
2746
2801
|
return ctx.notFound(error.message);
|
|
2747
2802
|
}
|
|
2748
|
-
ctx
|
|
2803
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating template");
|
|
2749
2804
|
}
|
|
2750
2805
|
},
|
|
2751
2806
|
/**
|
|
@@ -2760,7 +2815,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2760
2815
|
message: "Template deleted successfully"
|
|
2761
2816
|
});
|
|
2762
2817
|
} catch (error) {
|
|
2763
|
-
|
|
2818
|
+
if (isNotFoundMessage(error)) {
|
|
2819
|
+
return ctx.notFound(error.message);
|
|
2820
|
+
}
|
|
2821
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting template");
|
|
2764
2822
|
}
|
|
2765
2823
|
},
|
|
2766
2824
|
/**
|
|
@@ -2775,7 +2833,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2775
2833
|
data: versions
|
|
2776
2834
|
});
|
|
2777
2835
|
} catch (error) {
|
|
2778
|
-
|
|
2836
|
+
if (isNotFoundMessage(error)) {
|
|
2837
|
+
return ctx.notFound(error.message);
|
|
2838
|
+
}
|
|
2839
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching versions");
|
|
2779
2840
|
}
|
|
2780
2841
|
},
|
|
2781
2842
|
/**
|
|
@@ -2790,10 +2851,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2790
2851
|
data: template
|
|
2791
2852
|
});
|
|
2792
2853
|
} catch (error) {
|
|
2793
|
-
if (error
|
|
2854
|
+
if (isNotFoundMessage(error)) {
|
|
2794
2855
|
return ctx.notFound(error.message);
|
|
2795
2856
|
}
|
|
2796
|
-
ctx
|
|
2857
|
+
handleControllerError(ctx, error, "[magic-mail] Error restoring version");
|
|
2797
2858
|
}
|
|
2798
2859
|
},
|
|
2799
2860
|
/**
|
|
@@ -2808,13 +2869,13 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2808
2869
|
data: result2
|
|
2809
2870
|
});
|
|
2810
2871
|
} catch (error) {
|
|
2811
|
-
if (error
|
|
2872
|
+
if (isNotFoundMessage(error)) {
|
|
2812
2873
|
return ctx.notFound(error.message);
|
|
2813
2874
|
}
|
|
2814
|
-
if (error.message.includes("does not belong")) {
|
|
2875
|
+
if (error && typeof error.message === "string" && error.message.includes("does not belong")) {
|
|
2815
2876
|
return ctx.badRequest(error.message);
|
|
2816
2877
|
}
|
|
2817
|
-
ctx
|
|
2878
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting version");
|
|
2818
2879
|
}
|
|
2819
2880
|
},
|
|
2820
2881
|
/**
|
|
@@ -2829,10 +2890,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2829
2890
|
data: result2
|
|
2830
2891
|
});
|
|
2831
2892
|
} catch (error) {
|
|
2832
|
-
if (error
|
|
2893
|
+
if (isNotFoundMessage(error)) {
|
|
2833
2894
|
return ctx.notFound(error.message);
|
|
2834
2895
|
}
|
|
2835
|
-
ctx
|
|
2896
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting all versions");
|
|
2836
2897
|
}
|
|
2837
2898
|
},
|
|
2838
2899
|
/**
|
|
@@ -2848,10 +2909,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2848
2909
|
data: rendered
|
|
2849
2910
|
});
|
|
2850
2911
|
} catch (error) {
|
|
2851
|
-
if (error
|
|
2912
|
+
if (isNotFoundMessage(error)) {
|
|
2852
2913
|
return ctx.notFound(error.message);
|
|
2853
2914
|
}
|
|
2854
|
-
ctx
|
|
2915
|
+
handleControllerError(ctx, error, "[magic-mail] Error rendering template");
|
|
2855
2916
|
}
|
|
2856
2917
|
},
|
|
2857
2918
|
/**
|
|
@@ -2866,10 +2927,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2866
2927
|
data: templates
|
|
2867
2928
|
});
|
|
2868
2929
|
} catch (error) {
|
|
2869
|
-
if (error.message.includes("requires")) {
|
|
2930
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2870
2931
|
return ctx.forbidden(error.message);
|
|
2871
2932
|
}
|
|
2872
|
-
ctx
|
|
2933
|
+
handleControllerError(ctx, error, "[magic-mail] Error exporting templates");
|
|
2873
2934
|
}
|
|
2874
2935
|
},
|
|
2875
2936
|
/**
|
|
@@ -2887,10 +2948,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2887
2948
|
data: results
|
|
2888
2949
|
});
|
|
2889
2950
|
} catch (error) {
|
|
2890
|
-
if (error.message.includes("requires")) {
|
|
2951
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2891
2952
|
return ctx.forbidden(error.message);
|
|
2892
2953
|
}
|
|
2893
|
-
ctx
|
|
2954
|
+
handleControllerError(ctx, error, "[magic-mail] Error importing templates");
|
|
2894
2955
|
}
|
|
2895
2956
|
},
|
|
2896
2957
|
/**
|
|
@@ -2904,7 +2965,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2904
2965
|
data: stats
|
|
2905
2966
|
});
|
|
2906
2967
|
} catch (error) {
|
|
2907
|
-
ctx
|
|
2968
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching stats");
|
|
2908
2969
|
}
|
|
2909
2970
|
},
|
|
2910
2971
|
/**
|
|
@@ -2919,7 +2980,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2919
2980
|
data: template
|
|
2920
2981
|
});
|
|
2921
2982
|
} catch (error) {
|
|
2922
|
-
ctx
|
|
2983
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching core template");
|
|
2923
2984
|
}
|
|
2924
2985
|
},
|
|
2925
2986
|
/**
|
|
@@ -2934,7 +2995,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2934
2995
|
data: template
|
|
2935
2996
|
});
|
|
2936
2997
|
} catch (error) {
|
|
2937
|
-
ctx
|
|
2998
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating core template");
|
|
2938
2999
|
}
|
|
2939
3000
|
},
|
|
2940
3001
|
/**
|
|
@@ -2948,7 +3009,8 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2948
3009
|
if (!template) {
|
|
2949
3010
|
return ctx.notFound("Template not found");
|
|
2950
3011
|
}
|
|
2951
|
-
let fileContent
|
|
3012
|
+
let fileContent;
|
|
3013
|
+
let fileName;
|
|
2952
3014
|
if (type === "json") {
|
|
2953
3015
|
fileContent = JSON.stringify(template.design, null, 2);
|
|
2954
3016
|
fileName = `template-${id}.json`;
|
|
@@ -2963,8 +3025,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2963
3025
|
ctx.set("Content-Disposition", `attachment; filename="${fileName}"`);
|
|
2964
3026
|
ctx.send(fileContent);
|
|
2965
3027
|
} catch (error) {
|
|
2966
|
-
|
|
2967
|
-
ctx.throw(500, error.message);
|
|
3028
|
+
handleControllerError(ctx, error, "[magic-mail] Error downloading template");
|
|
2968
3029
|
}
|
|
2969
3030
|
},
|
|
2970
3031
|
/**
|
|
@@ -2979,10 +3040,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2979
3040
|
data: duplicated
|
|
2980
3041
|
});
|
|
2981
3042
|
} catch (error) {
|
|
2982
|
-
if (error
|
|
3043
|
+
if (isNotFoundMessage(error)) {
|
|
2983
3044
|
return ctx.notFound(error.message);
|
|
2984
3045
|
}
|
|
2985
|
-
ctx
|
|
3046
|
+
handleControllerError(ctx, error, "[magic-mail] Error duplicating template");
|
|
2986
3047
|
}
|
|
2987
3048
|
},
|
|
2988
3049
|
/**
|
|
@@ -3002,7 +3063,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3002
3063
|
const rendered = await strapi2.plugin("magic-mail").service("email-designer").renderTemplate(template.templateReferenceId, {
|
|
3003
3064
|
name: "Test User",
|
|
3004
3065
|
email: to
|
|
3005
|
-
// Add more default test variables as needed
|
|
3006
3066
|
});
|
|
3007
3067
|
const emailRouterService = strapi2.plugin("magic-mail").service("email-router");
|
|
3008
3068
|
const sendOptions = {
|
|
@@ -3010,7 +3070,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3010
3070
|
subject: rendered.subject || template.subject,
|
|
3011
3071
|
html: rendered.html,
|
|
3012
3072
|
text: rendered.text,
|
|
3013
|
-
// Add template tracking info
|
|
3014
3073
|
templateId: template.templateReferenceId,
|
|
3015
3074
|
templateName: template.name
|
|
3016
3075
|
};
|
|
@@ -3028,8 +3087,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3028
3087
|
}
|
|
3029
3088
|
});
|
|
3030
3089
|
} catch (error) {
|
|
3031
|
-
|
|
3032
|
-
return ctx.badRequest(error.message || "Failed to send test email");
|
|
3090
|
+
handleControllerError(ctx, error, "[magic-mail] Error sending test email");
|
|
3033
3091
|
}
|
|
3034
3092
|
}
|
|
3035
3093
|
});
|
|
@@ -15851,7 +15909,7 @@ var oauth$1 = ({ strapi: strapi2 }) => ({
|
|
|
15851
15909
|
return account;
|
|
15852
15910
|
}
|
|
15853
15911
|
});
|
|
15854
|
-
const version = "2.10.
|
|
15912
|
+
const version = "2.10.9";
|
|
15855
15913
|
const require$$2 = {
|
|
15856
15914
|
version
|
|
15857
15915
|
};
|
package/dist/server/index.mjs
CHANGED
|
@@ -1105,29 +1105,30 @@ const schemas = {
|
|
|
1105
1105
|
// a number via parseInt() before POSTing. Accepting both shapes
|
|
1106
1106
|
// keeps the wizard working either way — the service layer stores
|
|
1107
1107
|
// the DB column as a string regardless.
|
|
1108
|
-
templateReferenceId: z.union([safeString, z.number().int().nonnegative()]).optional(),
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
bodyText
|
|
1108
|
+
templateReferenceId: z.union([safeString, z.number().int().nonnegative()]).optional().nullable(),
|
|
1109
|
+
// Optional/nullable mirrors the content-type schema: Strapi serves
|
|
1110
|
+
// absent DB columns as `null`, and the editor re-sends the whole
|
|
1111
|
+
// document on save. Accepting null avoids spurious 400s whenever a
|
|
1112
|
+
// template has no category/bodyText/tags yet.
|
|
1113
|
+
name: safeString.optional().nullable(),
|
|
1114
|
+
subject: headerSafe.optional().nullable(),
|
|
1115
|
+
bodyHtml: safeText.optional().nullable(),
|
|
1116
|
+
bodyText: safeText.optional().nullable(),
|
|
1113
1117
|
design: z.record(z.unknown()).optional().nullable(),
|
|
1114
|
-
category: safeString.optional(),
|
|
1115
|
-
isActive: z.boolean().optional(),
|
|
1116
|
-
tags: z.array(safeString).max(50).optional()
|
|
1118
|
+
category: safeString.optional().nullable(),
|
|
1119
|
+
isActive: z.boolean().optional().nullable(),
|
|
1120
|
+
tags: z.array(safeString).max(50).optional().nullable()
|
|
1117
1121
|
}).strict(),
|
|
1118
1122
|
"emailDesigner.update": z.object({
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
subject: headerSafe.optional(),
|
|
1125
|
-
bodyHtml: safeText.optional(),
|
|
1126
|
-
bodyText: safeText.optional(),
|
|
1123
|
+
templateReferenceId: z.union([safeString, z.number().int().nonnegative()]).optional().nullable(),
|
|
1124
|
+
name: safeString.optional().nullable(),
|
|
1125
|
+
subject: headerSafe.optional().nullable(),
|
|
1126
|
+
bodyHtml: safeText.optional().nullable(),
|
|
1127
|
+
bodyText: safeText.optional().nullable(),
|
|
1127
1128
|
design: z.record(z.unknown()).optional().nullable(),
|
|
1128
|
-
category: safeString.optional(),
|
|
1129
|
-
isActive: z.boolean().optional(),
|
|
1130
|
-
tags: z.array(safeString).max(50).optional()
|
|
1129
|
+
category: safeString.optional().nullable(),
|
|
1130
|
+
isActive: z.boolean().optional().nullable(),
|
|
1131
|
+
tags: z.array(safeString).max(50).optional().nullable()
|
|
1131
1132
|
}).strict(),
|
|
1132
1133
|
"emailDesigner.renderTemplate": z.object({
|
|
1133
1134
|
data: z.record(z.unknown()).optional()
|
|
@@ -1242,16 +1243,52 @@ const schemas = {
|
|
|
1242
1243
|
phoneNumber: z.string().min(5).max(32).regex(/^[\d+\-() ]+$/)
|
|
1243
1244
|
})
|
|
1244
1245
|
};
|
|
1246
|
+
const STRAPI_METADATA_FIELDS = Object.freeze([
|
|
1247
|
+
"id",
|
|
1248
|
+
"documentId",
|
|
1249
|
+
"createdAt",
|
|
1250
|
+
"updatedAt",
|
|
1251
|
+
"publishedAt",
|
|
1252
|
+
"locale",
|
|
1253
|
+
"localizations",
|
|
1254
|
+
"createdBy",
|
|
1255
|
+
"updatedBy",
|
|
1256
|
+
"__component",
|
|
1257
|
+
// Populated relations/components we never want to round-trip as a write:
|
|
1258
|
+
"versions"
|
|
1259
|
+
]);
|
|
1260
|
+
function stripStrapiMetadata(body, schemaName) {
|
|
1261
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return body;
|
|
1262
|
+
const cleaned = { ...body };
|
|
1263
|
+
const removed = [];
|
|
1264
|
+
for (const key of STRAPI_METADATA_FIELDS) {
|
|
1265
|
+
if (key in cleaned) {
|
|
1266
|
+
delete cleaned[key];
|
|
1267
|
+
removed.push(key);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
if (removed.length > 0 && typeof strapi !== "undefined" && strapi?.log?.debug) {
|
|
1271
|
+
strapi.log.debug(
|
|
1272
|
+
`[magic-mail] Stripped Strapi metadata from ${schemaName} payload: ${removed.join(", ")}`
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
return cleaned;
|
|
1276
|
+
}
|
|
1245
1277
|
function validate$5(schemaName, body) {
|
|
1246
1278
|
const schema = schemas[schemaName];
|
|
1247
1279
|
if (!schema) {
|
|
1248
1280
|
throw new Error(`Unknown validation schema: ${schemaName}`);
|
|
1249
1281
|
}
|
|
1250
|
-
const
|
|
1282
|
+
const sanitized = stripStrapiMetadata(body, schemaName);
|
|
1283
|
+
const result2 = schema.safeParse(sanitized);
|
|
1251
1284
|
if (!result2.success) {
|
|
1252
1285
|
const strapiErrors = require$$1$2.errors;
|
|
1253
1286
|
const flattened = result2.error.flatten();
|
|
1254
1287
|
const strapiLog = typeof strapi !== "undefined" && strapi && strapi.log ? strapi.log : null;
|
|
1288
|
+
const details = { ...flattened.fieldErrors };
|
|
1289
|
+
if (Array.isArray(flattened.formErrors) && flattened.formErrors.length > 0) {
|
|
1290
|
+
details._form = flattened.formErrors;
|
|
1291
|
+
}
|
|
1255
1292
|
if (strapiLog) {
|
|
1256
1293
|
strapiLog.warn(
|
|
1257
1294
|
`[magic-mail] Validation failed for schema '${schemaName}': ` + JSON.stringify({
|
|
@@ -1260,23 +1297,38 @@ function validate$5(schemaName, body) {
|
|
|
1260
1297
|
})
|
|
1261
1298
|
);
|
|
1262
1299
|
}
|
|
1263
|
-
throw new strapiErrors.ValidationError("Validation failed",
|
|
1300
|
+
throw new strapiErrors.ValidationError("Validation failed", details);
|
|
1264
1301
|
}
|
|
1265
1302
|
return result2.data;
|
|
1266
1303
|
}
|
|
1267
|
-
function handleControllerError$
|
|
1268
|
-
const
|
|
1304
|
+
function handleControllerError$4(ctx, err, logPrefix, fallbackMessage) {
|
|
1305
|
+
const strapiErrors = require$$1$2.errors;
|
|
1306
|
+
const knownStrapiNames = /* @__PURE__ */ new Set([
|
|
1307
|
+
"ApplicationError",
|
|
1308
|
+
"ValidationError",
|
|
1309
|
+
"YupValidationError",
|
|
1310
|
+
"PaginationError",
|
|
1311
|
+
"NotFoundError",
|
|
1312
|
+
"ForbiddenError",
|
|
1313
|
+
"UnauthorizedError",
|
|
1314
|
+
"PayloadTooLargeError",
|
|
1315
|
+
"PolicyError",
|
|
1316
|
+
"NotImplementedError",
|
|
1317
|
+
"RateLimitError",
|
|
1318
|
+
"HttpError"
|
|
1319
|
+
]);
|
|
1320
|
+
const isStrapiError = err && typeof err === "object" && err instanceof strapiErrors.ApplicationError || err && typeof err.name === "string" && knownStrapiNames.has(err.name);
|
|
1269
1321
|
if (isStrapiError) {
|
|
1270
1322
|
strapi.log.warn(
|
|
1271
|
-
`${logPrefix}: ${err.name}
|
|
1323
|
+
`${logPrefix}: ${err.name} — ${err.message}` + (err.details && Object.keys(err.details).length > 0 ? ` | details=${JSON.stringify(err.details)}` : "")
|
|
1272
1324
|
);
|
|
1273
1325
|
throw err;
|
|
1274
1326
|
}
|
|
1275
1327
|
strapi.log.error(`${logPrefix}:`, err);
|
|
1276
1328
|
ctx.throw(500, fallbackMessage || err.message || "Internal server error");
|
|
1277
1329
|
}
|
|
1278
|
-
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$
|
|
1279
|
-
const { validate: validate$4, handleControllerError: handleControllerError$
|
|
1330
|
+
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$4 };
|
|
1331
|
+
const { validate: validate$4, handleControllerError: handleControllerError$3 } = validation;
|
|
1280
1332
|
function stripAttachmentPaths(body) {
|
|
1281
1333
|
if (body && Array.isArray(body.attachments)) {
|
|
1282
1334
|
body.attachments = body.attachments.map(({ path: path2, ...safe }) => safe);
|
|
@@ -1292,7 +1344,7 @@ var controller$1 = {
|
|
|
1292
1344
|
const result2 = await emailRouter2.send(body);
|
|
1293
1345
|
ctx.body = { success: true, ...result2 };
|
|
1294
1346
|
} catch (err) {
|
|
1295
|
-
handleControllerError$
|
|
1347
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending email", "Failed to send email");
|
|
1296
1348
|
}
|
|
1297
1349
|
},
|
|
1298
1350
|
async sendMessage(ctx) {
|
|
@@ -1303,7 +1355,7 @@ var controller$1 = {
|
|
|
1303
1355
|
const result2 = await emailRouter2.sendMessage(body);
|
|
1304
1356
|
ctx.body = { success: true, ...result2 };
|
|
1305
1357
|
} catch (err) {
|
|
1306
|
-
handleControllerError$
|
|
1358
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending message", "Failed to send message");
|
|
1307
1359
|
}
|
|
1308
1360
|
},
|
|
1309
1361
|
async sendWhatsApp(ctx) {
|
|
@@ -1313,7 +1365,7 @@ var controller$1 = {
|
|
|
1313
1365
|
const result2 = await emailRouter2.sendWhatsApp(body);
|
|
1314
1366
|
ctx.body = { success: true, ...result2 };
|
|
1315
1367
|
} catch (err) {
|
|
1316
|
-
handleControllerError$
|
|
1368
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending WhatsApp", "Failed to send WhatsApp message");
|
|
1317
1369
|
}
|
|
1318
1370
|
},
|
|
1319
1371
|
async getWhatsAppStatus(ctx) {
|
|
@@ -1341,11 +1393,11 @@ var controller$1 = {
|
|
|
1341
1393
|
const result2 = await emailRouter2.checkWhatsAppNumber(phoneNumber);
|
|
1342
1394
|
ctx.body = { success: true, data: result2 };
|
|
1343
1395
|
} catch (err) {
|
|
1344
|
-
handleControllerError$
|
|
1396
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error checking WhatsApp number", "Failed to check phone number");
|
|
1345
1397
|
}
|
|
1346
1398
|
}
|
|
1347
1399
|
};
|
|
1348
|
-
const { validate: validate$3, handleControllerError: handleControllerError$
|
|
1400
|
+
const { validate: validate$3, handleControllerError: handleControllerError$2 } = validation;
|
|
1349
1401
|
var accounts$1 = {
|
|
1350
1402
|
/**
|
|
1351
1403
|
* Get all email accounts
|
|
@@ -1388,7 +1440,7 @@ var accounts$1 = {
|
|
|
1388
1440
|
message: "Email account created successfully"
|
|
1389
1441
|
};
|
|
1390
1442
|
} catch (err) {
|
|
1391
|
-
handleControllerError$
|
|
1443
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error creating account", "Error creating email account");
|
|
1392
1444
|
}
|
|
1393
1445
|
},
|
|
1394
1446
|
/**
|
|
@@ -1406,7 +1458,7 @@ var accounts$1 = {
|
|
|
1406
1458
|
data: account
|
|
1407
1459
|
};
|
|
1408
1460
|
} catch (err) {
|
|
1409
|
-
handleControllerError$
|
|
1461
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error getting account", "Error fetching email account");
|
|
1410
1462
|
}
|
|
1411
1463
|
},
|
|
1412
1464
|
/**
|
|
@@ -1434,7 +1486,7 @@ var accounts$1 = {
|
|
|
1434
1486
|
message: "Email account updated successfully"
|
|
1435
1487
|
};
|
|
1436
1488
|
} catch (err) {
|
|
1437
|
-
handleControllerError$
|
|
1489
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error updating account", "Error updating email account");
|
|
1438
1490
|
}
|
|
1439
1491
|
},
|
|
1440
1492
|
/**
|
|
@@ -1454,7 +1506,7 @@ var accounts$1 = {
|
|
|
1454
1506
|
const result2 = await accountManager2.testAccount(accountId, recipientEmail, testOptions);
|
|
1455
1507
|
ctx.body = result2;
|
|
1456
1508
|
} catch (err) {
|
|
1457
|
-
handleControllerError$
|
|
1509
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error testing account", "Error testing email account");
|
|
1458
1510
|
}
|
|
1459
1511
|
},
|
|
1460
1512
|
/**
|
|
@@ -2103,7 +2155,7 @@ var oauth$3 = {
|
|
|
2103
2155
|
}
|
|
2104
2156
|
}
|
|
2105
2157
|
};
|
|
2106
|
-
const { handleControllerError } = validation;
|
|
2158
|
+
const { handleControllerError: handleControllerError$1 } = validation;
|
|
2107
2159
|
const ROUTING_RULE_UID = "plugin::magic-mail.routing-rule";
|
|
2108
2160
|
const ALLOWED_RULE_FIELDS = [
|
|
2109
2161
|
"name",
|
|
@@ -2139,7 +2191,7 @@ var routingRules$1 = {
|
|
|
2139
2191
|
data: rules
|
|
2140
2192
|
};
|
|
2141
2193
|
} catch (err) {
|
|
2142
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2194
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2143
2195
|
}
|
|
2144
2196
|
},
|
|
2145
2197
|
/**
|
|
@@ -2158,7 +2210,7 @@ var routingRules$1 = {
|
|
|
2158
2210
|
data: rule2
|
|
2159
2211
|
};
|
|
2160
2212
|
} catch (err) {
|
|
2161
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2213
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2162
2214
|
}
|
|
2163
2215
|
},
|
|
2164
2216
|
/**
|
|
@@ -2180,7 +2232,7 @@ var routingRules$1 = {
|
|
|
2180
2232
|
};
|
|
2181
2233
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule created: ${rule2.name}`);
|
|
2182
2234
|
} catch (err) {
|
|
2183
|
-
handleControllerError(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2235
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2184
2236
|
}
|
|
2185
2237
|
},
|
|
2186
2238
|
/**
|
|
@@ -2204,7 +2256,7 @@ var routingRules$1 = {
|
|
|
2204
2256
|
};
|
|
2205
2257
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule updated: ${rule2.name}`);
|
|
2206
2258
|
} catch (err) {
|
|
2207
|
-
handleControllerError(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2259
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2208
2260
|
}
|
|
2209
2261
|
},
|
|
2210
2262
|
/**
|
|
@@ -2225,7 +2277,7 @@ var routingRules$1 = {
|
|
|
2225
2277
|
};
|
|
2226
2278
|
strapi.log.info(`[magic-mail] Routing rule deleted: ${ruleId}`);
|
|
2227
2279
|
} catch (err) {
|
|
2228
|
-
handleControllerError(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2280
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2229
2281
|
}
|
|
2230
2282
|
}
|
|
2231
2283
|
};
|
|
@@ -2666,7 +2718,10 @@ var license$1 = ({ strapi: strapi2 }) => ({
|
|
|
2666
2718
|
}
|
|
2667
2719
|
}
|
|
2668
2720
|
});
|
|
2669
|
-
const { validate: validate$2 } = validation;
|
|
2721
|
+
const { validate: validate$2, handleControllerError } = validation;
|
|
2722
|
+
function isNotFoundMessage(err) {
|
|
2723
|
+
return err && typeof err.message === "string" && err.message.includes("not found");
|
|
2724
|
+
}
|
|
2670
2725
|
var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
2671
2726
|
/**
|
|
2672
2727
|
* Get all templates
|
|
@@ -2679,7 +2734,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2679
2734
|
data: templates
|
|
2680
2735
|
});
|
|
2681
2736
|
} catch (error) {
|
|
2682
|
-
ctx
|
|
2737
|
+
handleControllerError(ctx, error, "[magic-mail] Error listing templates");
|
|
2683
2738
|
}
|
|
2684
2739
|
},
|
|
2685
2740
|
/**
|
|
@@ -2697,7 +2752,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2697
2752
|
data: template
|
|
2698
2753
|
});
|
|
2699
2754
|
} catch (error) {
|
|
2700
|
-
ctx
|
|
2755
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching template");
|
|
2701
2756
|
}
|
|
2702
2757
|
},
|
|
2703
2758
|
/**
|
|
@@ -2711,10 +2766,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2711
2766
|
data: template
|
|
2712
2767
|
});
|
|
2713
2768
|
} catch (error) {
|
|
2714
|
-
if (error.message.includes("limit reached") || error.message.includes("already exists")) {
|
|
2769
|
+
if (error && typeof error.message === "string" && (error.message.includes("limit reached") || error.message.includes("already exists"))) {
|
|
2715
2770
|
return ctx.badRequest(error.message);
|
|
2716
2771
|
}
|
|
2717
|
-
ctx
|
|
2772
|
+
handleControllerError(ctx, error, "[magic-mail] Error creating template");
|
|
2718
2773
|
}
|
|
2719
2774
|
},
|
|
2720
2775
|
/**
|
|
@@ -2729,10 +2784,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2729
2784
|
data: template
|
|
2730
2785
|
});
|
|
2731
2786
|
} catch (error) {
|
|
2732
|
-
if (error
|
|
2787
|
+
if (isNotFoundMessage(error)) {
|
|
2733
2788
|
return ctx.notFound(error.message);
|
|
2734
2789
|
}
|
|
2735
|
-
ctx
|
|
2790
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating template");
|
|
2736
2791
|
}
|
|
2737
2792
|
},
|
|
2738
2793
|
/**
|
|
@@ -2747,7 +2802,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2747
2802
|
message: "Template deleted successfully"
|
|
2748
2803
|
});
|
|
2749
2804
|
} catch (error) {
|
|
2750
|
-
|
|
2805
|
+
if (isNotFoundMessage(error)) {
|
|
2806
|
+
return ctx.notFound(error.message);
|
|
2807
|
+
}
|
|
2808
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting template");
|
|
2751
2809
|
}
|
|
2752
2810
|
},
|
|
2753
2811
|
/**
|
|
@@ -2762,7 +2820,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2762
2820
|
data: versions
|
|
2763
2821
|
});
|
|
2764
2822
|
} catch (error) {
|
|
2765
|
-
|
|
2823
|
+
if (isNotFoundMessage(error)) {
|
|
2824
|
+
return ctx.notFound(error.message);
|
|
2825
|
+
}
|
|
2826
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching versions");
|
|
2766
2827
|
}
|
|
2767
2828
|
},
|
|
2768
2829
|
/**
|
|
@@ -2777,10 +2838,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2777
2838
|
data: template
|
|
2778
2839
|
});
|
|
2779
2840
|
} catch (error) {
|
|
2780
|
-
if (error
|
|
2841
|
+
if (isNotFoundMessage(error)) {
|
|
2781
2842
|
return ctx.notFound(error.message);
|
|
2782
2843
|
}
|
|
2783
|
-
ctx
|
|
2844
|
+
handleControllerError(ctx, error, "[magic-mail] Error restoring version");
|
|
2784
2845
|
}
|
|
2785
2846
|
},
|
|
2786
2847
|
/**
|
|
@@ -2795,13 +2856,13 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2795
2856
|
data: result2
|
|
2796
2857
|
});
|
|
2797
2858
|
} catch (error) {
|
|
2798
|
-
if (error
|
|
2859
|
+
if (isNotFoundMessage(error)) {
|
|
2799
2860
|
return ctx.notFound(error.message);
|
|
2800
2861
|
}
|
|
2801
|
-
if (error.message.includes("does not belong")) {
|
|
2862
|
+
if (error && typeof error.message === "string" && error.message.includes("does not belong")) {
|
|
2802
2863
|
return ctx.badRequest(error.message);
|
|
2803
2864
|
}
|
|
2804
|
-
ctx
|
|
2865
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting version");
|
|
2805
2866
|
}
|
|
2806
2867
|
},
|
|
2807
2868
|
/**
|
|
@@ -2816,10 +2877,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2816
2877
|
data: result2
|
|
2817
2878
|
});
|
|
2818
2879
|
} catch (error) {
|
|
2819
|
-
if (error
|
|
2880
|
+
if (isNotFoundMessage(error)) {
|
|
2820
2881
|
return ctx.notFound(error.message);
|
|
2821
2882
|
}
|
|
2822
|
-
ctx
|
|
2883
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting all versions");
|
|
2823
2884
|
}
|
|
2824
2885
|
},
|
|
2825
2886
|
/**
|
|
@@ -2835,10 +2896,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2835
2896
|
data: rendered
|
|
2836
2897
|
});
|
|
2837
2898
|
} catch (error) {
|
|
2838
|
-
if (error
|
|
2899
|
+
if (isNotFoundMessage(error)) {
|
|
2839
2900
|
return ctx.notFound(error.message);
|
|
2840
2901
|
}
|
|
2841
|
-
ctx
|
|
2902
|
+
handleControllerError(ctx, error, "[magic-mail] Error rendering template");
|
|
2842
2903
|
}
|
|
2843
2904
|
},
|
|
2844
2905
|
/**
|
|
@@ -2853,10 +2914,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2853
2914
|
data: templates
|
|
2854
2915
|
});
|
|
2855
2916
|
} catch (error) {
|
|
2856
|
-
if (error.message.includes("requires")) {
|
|
2917
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2857
2918
|
return ctx.forbidden(error.message);
|
|
2858
2919
|
}
|
|
2859
|
-
ctx
|
|
2920
|
+
handleControllerError(ctx, error, "[magic-mail] Error exporting templates");
|
|
2860
2921
|
}
|
|
2861
2922
|
},
|
|
2862
2923
|
/**
|
|
@@ -2874,10 +2935,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2874
2935
|
data: results
|
|
2875
2936
|
});
|
|
2876
2937
|
} catch (error) {
|
|
2877
|
-
if (error.message.includes("requires")) {
|
|
2938
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2878
2939
|
return ctx.forbidden(error.message);
|
|
2879
2940
|
}
|
|
2880
|
-
ctx
|
|
2941
|
+
handleControllerError(ctx, error, "[magic-mail] Error importing templates");
|
|
2881
2942
|
}
|
|
2882
2943
|
},
|
|
2883
2944
|
/**
|
|
@@ -2891,7 +2952,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2891
2952
|
data: stats
|
|
2892
2953
|
});
|
|
2893
2954
|
} catch (error) {
|
|
2894
|
-
ctx
|
|
2955
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching stats");
|
|
2895
2956
|
}
|
|
2896
2957
|
},
|
|
2897
2958
|
/**
|
|
@@ -2906,7 +2967,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2906
2967
|
data: template
|
|
2907
2968
|
});
|
|
2908
2969
|
} catch (error) {
|
|
2909
|
-
ctx
|
|
2970
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching core template");
|
|
2910
2971
|
}
|
|
2911
2972
|
},
|
|
2912
2973
|
/**
|
|
@@ -2921,7 +2982,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2921
2982
|
data: template
|
|
2922
2983
|
});
|
|
2923
2984
|
} catch (error) {
|
|
2924
|
-
ctx
|
|
2985
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating core template");
|
|
2925
2986
|
}
|
|
2926
2987
|
},
|
|
2927
2988
|
/**
|
|
@@ -2935,7 +2996,8 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2935
2996
|
if (!template) {
|
|
2936
2997
|
return ctx.notFound("Template not found");
|
|
2937
2998
|
}
|
|
2938
|
-
let fileContent
|
|
2999
|
+
let fileContent;
|
|
3000
|
+
let fileName;
|
|
2939
3001
|
if (type === "json") {
|
|
2940
3002
|
fileContent = JSON.stringify(template.design, null, 2);
|
|
2941
3003
|
fileName = `template-${id}.json`;
|
|
@@ -2950,8 +3012,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2950
3012
|
ctx.set("Content-Disposition", `attachment; filename="${fileName}"`);
|
|
2951
3013
|
ctx.send(fileContent);
|
|
2952
3014
|
} catch (error) {
|
|
2953
|
-
|
|
2954
|
-
ctx.throw(500, error.message);
|
|
3015
|
+
handleControllerError(ctx, error, "[magic-mail] Error downloading template");
|
|
2955
3016
|
}
|
|
2956
3017
|
},
|
|
2957
3018
|
/**
|
|
@@ -2966,10 +3027,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2966
3027
|
data: duplicated
|
|
2967
3028
|
});
|
|
2968
3029
|
} catch (error) {
|
|
2969
|
-
if (error
|
|
3030
|
+
if (isNotFoundMessage(error)) {
|
|
2970
3031
|
return ctx.notFound(error.message);
|
|
2971
3032
|
}
|
|
2972
|
-
ctx
|
|
3033
|
+
handleControllerError(ctx, error, "[magic-mail] Error duplicating template");
|
|
2973
3034
|
}
|
|
2974
3035
|
},
|
|
2975
3036
|
/**
|
|
@@ -2989,7 +3050,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2989
3050
|
const rendered = await strapi2.plugin("magic-mail").service("email-designer").renderTemplate(template.templateReferenceId, {
|
|
2990
3051
|
name: "Test User",
|
|
2991
3052
|
email: to
|
|
2992
|
-
// Add more default test variables as needed
|
|
2993
3053
|
});
|
|
2994
3054
|
const emailRouterService = strapi2.plugin("magic-mail").service("email-router");
|
|
2995
3055
|
const sendOptions = {
|
|
@@ -2997,7 +3057,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2997
3057
|
subject: rendered.subject || template.subject,
|
|
2998
3058
|
html: rendered.html,
|
|
2999
3059
|
text: rendered.text,
|
|
3000
|
-
// Add template tracking info
|
|
3001
3060
|
templateId: template.templateReferenceId,
|
|
3002
3061
|
templateName: template.name
|
|
3003
3062
|
};
|
|
@@ -3015,8 +3074,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3015
3074
|
}
|
|
3016
3075
|
});
|
|
3017
3076
|
} catch (error) {
|
|
3018
|
-
|
|
3019
|
-
return ctx.badRequest(error.message || "Failed to send test email");
|
|
3077
|
+
handleControllerError(ctx, error, "[magic-mail] Error sending test email");
|
|
3020
3078
|
}
|
|
3021
3079
|
}
|
|
3022
3080
|
});
|
|
@@ -15838,7 +15896,7 @@ var oauth$1 = ({ strapi: strapi2 }) => ({
|
|
|
15838
15896
|
return account;
|
|
15839
15897
|
}
|
|
15840
15898
|
});
|
|
15841
|
-
const version = "2.10.
|
|
15899
|
+
const version = "2.10.9";
|
|
15842
15900
|
const require$$2 = {
|
|
15843
15901
|
version
|
|
15844
15902
|
};
|
package/package.json
CHANGED