strapi-plugin-magic-mail 2.10.7 → 2.10.9
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-BJBweFJi.js → App-CInlcJMb.js} +21 -5
- package/dist/_chunks/{App-PxOT9hIQ.mjs → App-D4bFKNcg.mjs} +21 -5
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +101 -75
- package/dist/server/index.mjs +101 -75
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.10.9](https://github.com/Schero94/Magic-Mail/compare/v2.10.8...v2.10.9) (2026-04-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **email-designer:** resolve PUT 500s on template update by whitelisting payload + proper error propagation ([29dd0c0](https://github.com/Schero94/Magic-Mail/commit/29dd0c0f6744a87108323ba511246502c5c3fc84))
|
|
7
|
+
|
|
8
|
+
## [2.10.8](https://github.com/Schero94/Magic-Mail/compare/v2.10.7...v2.10.8) (2026-04-21)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **editor:** navigate to newly created templates by templateReferenceId, not DB id ([617dc01](https://github.com/Schero94/Magic-Mail/commit/617dc01106101a7407bcfadbb61bbe49ef8eb43e))
|
|
14
|
+
|
|
1
15
|
## [2.10.7](https://github.com/Schero94/Magic-Mail/compare/v2.10.6...v2.10.7) (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);
|
|
@@ -6458,8 +6470,12 @@ const EditorPage = () => {
|
|
|
6458
6470
|
type: "success",
|
|
6459
6471
|
message: isNewTemplate ? "Template created!" : "Template saved!"
|
|
6460
6472
|
});
|
|
6461
|
-
if (isNewTemplate
|
|
6462
|
-
|
|
6473
|
+
if (isNewTemplate) {
|
|
6474
|
+
const created = response.data?.data;
|
|
6475
|
+
const navId = created?.templateReferenceId ?? created?.id;
|
|
6476
|
+
if (navId !== void 0 && navId !== null) {
|
|
6477
|
+
navigate(`/plugins/magic-mail/designer/${navId}`);
|
|
6478
|
+
}
|
|
6463
6479
|
}
|
|
6464
6480
|
} catch (error) {
|
|
6465
6481
|
toggleNotification({
|
|
@@ -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);
|
|
@@ -6435,8 +6447,12 @@ const EditorPage = () => {
|
|
|
6435
6447
|
type: "success",
|
|
6436
6448
|
message: isNewTemplate ? "Template created!" : "Template saved!"
|
|
6437
6449
|
});
|
|
6438
|
-
if (isNewTemplate
|
|
6439
|
-
|
|
6450
|
+
if (isNewTemplate) {
|
|
6451
|
+
const created = response.data?.data;
|
|
6452
|
+
const navId = created?.templateReferenceId ?? created?.id;
|
|
6453
|
+
if (navId !== void 0 && navId !== null) {
|
|
6454
|
+
navigate(`/plugins/magic-mail/designer/${navId}`);
|
|
6455
|
+
}
|
|
6440
6456
|
}
|
|
6441
6457
|
} catch (error) {
|
|
6442
6458
|
toggleNotification({
|
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()
|
|
@@ -1265,6 +1266,10 @@ function validate$5(schemaName, body) {
|
|
|
1265
1266
|
const strapiErrors = require$$1__default.default.errors;
|
|
1266
1267
|
const flattened = result2.error.flatten();
|
|
1267
1268
|
const strapiLog = typeof strapi !== "undefined" && strapi && strapi.log ? strapi.log : null;
|
|
1269
|
+
const details = { ...flattened.fieldErrors };
|
|
1270
|
+
if (Array.isArray(flattened.formErrors) && flattened.formErrors.length > 0) {
|
|
1271
|
+
details._form = flattened.formErrors;
|
|
1272
|
+
}
|
|
1268
1273
|
if (strapiLog) {
|
|
1269
1274
|
strapiLog.warn(
|
|
1270
1275
|
`[magic-mail] Validation failed for schema '${schemaName}': ` + JSON.stringify({
|
|
@@ -1273,23 +1278,38 @@ function validate$5(schemaName, body) {
|
|
|
1273
1278
|
})
|
|
1274
1279
|
);
|
|
1275
1280
|
}
|
|
1276
|
-
throw new strapiErrors.ValidationError("Validation failed",
|
|
1281
|
+
throw new strapiErrors.ValidationError("Validation failed", details);
|
|
1277
1282
|
}
|
|
1278
1283
|
return result2.data;
|
|
1279
1284
|
}
|
|
1280
|
-
function handleControllerError$
|
|
1281
|
-
const
|
|
1285
|
+
function handleControllerError$4(ctx, err, logPrefix, fallbackMessage) {
|
|
1286
|
+
const strapiErrors = require$$1__default.default.errors;
|
|
1287
|
+
const knownStrapiNames = /* @__PURE__ */ new Set([
|
|
1288
|
+
"ApplicationError",
|
|
1289
|
+
"ValidationError",
|
|
1290
|
+
"YupValidationError",
|
|
1291
|
+
"PaginationError",
|
|
1292
|
+
"NotFoundError",
|
|
1293
|
+
"ForbiddenError",
|
|
1294
|
+
"UnauthorizedError",
|
|
1295
|
+
"PayloadTooLargeError",
|
|
1296
|
+
"PolicyError",
|
|
1297
|
+
"NotImplementedError",
|
|
1298
|
+
"RateLimitError",
|
|
1299
|
+
"HttpError"
|
|
1300
|
+
]);
|
|
1301
|
+
const isStrapiError = err && typeof err === "object" && err instanceof strapiErrors.ApplicationError || err && typeof err.name === "string" && knownStrapiNames.has(err.name);
|
|
1282
1302
|
if (isStrapiError) {
|
|
1283
1303
|
strapi.log.warn(
|
|
1284
|
-
`${logPrefix}: ${err.name}
|
|
1304
|
+
`${logPrefix}: ${err.name} — ${err.message}` + (err.details && Object.keys(err.details).length > 0 ? ` | details=${JSON.stringify(err.details)}` : "")
|
|
1285
1305
|
);
|
|
1286
1306
|
throw err;
|
|
1287
1307
|
}
|
|
1288
1308
|
strapi.log.error(`${logPrefix}:`, err);
|
|
1289
1309
|
ctx.throw(500, fallbackMessage || err.message || "Internal server error");
|
|
1290
1310
|
}
|
|
1291
|
-
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$
|
|
1292
|
-
const { validate: validate$4, handleControllerError: handleControllerError$
|
|
1311
|
+
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$4 };
|
|
1312
|
+
const { validate: validate$4, handleControllerError: handleControllerError$3 } = validation;
|
|
1293
1313
|
function stripAttachmentPaths(body) {
|
|
1294
1314
|
if (body && Array.isArray(body.attachments)) {
|
|
1295
1315
|
body.attachments = body.attachments.map(({ path: path2, ...safe }) => safe);
|
|
@@ -1305,7 +1325,7 @@ var controller$1 = {
|
|
|
1305
1325
|
const result2 = await emailRouter2.send(body);
|
|
1306
1326
|
ctx.body = { success: true, ...result2 };
|
|
1307
1327
|
} catch (err) {
|
|
1308
|
-
handleControllerError$
|
|
1328
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending email", "Failed to send email");
|
|
1309
1329
|
}
|
|
1310
1330
|
},
|
|
1311
1331
|
async sendMessage(ctx) {
|
|
@@ -1316,7 +1336,7 @@ var controller$1 = {
|
|
|
1316
1336
|
const result2 = await emailRouter2.sendMessage(body);
|
|
1317
1337
|
ctx.body = { success: true, ...result2 };
|
|
1318
1338
|
} catch (err) {
|
|
1319
|
-
handleControllerError$
|
|
1339
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending message", "Failed to send message");
|
|
1320
1340
|
}
|
|
1321
1341
|
},
|
|
1322
1342
|
async sendWhatsApp(ctx) {
|
|
@@ -1326,7 +1346,7 @@ var controller$1 = {
|
|
|
1326
1346
|
const result2 = await emailRouter2.sendWhatsApp(body);
|
|
1327
1347
|
ctx.body = { success: true, ...result2 };
|
|
1328
1348
|
} catch (err) {
|
|
1329
|
-
handleControllerError$
|
|
1349
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending WhatsApp", "Failed to send WhatsApp message");
|
|
1330
1350
|
}
|
|
1331
1351
|
},
|
|
1332
1352
|
async getWhatsAppStatus(ctx) {
|
|
@@ -1354,11 +1374,11 @@ var controller$1 = {
|
|
|
1354
1374
|
const result2 = await emailRouter2.checkWhatsAppNumber(phoneNumber);
|
|
1355
1375
|
ctx.body = { success: true, data: result2 };
|
|
1356
1376
|
} catch (err) {
|
|
1357
|
-
handleControllerError$
|
|
1377
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error checking WhatsApp number", "Failed to check phone number");
|
|
1358
1378
|
}
|
|
1359
1379
|
}
|
|
1360
1380
|
};
|
|
1361
|
-
const { validate: validate$3, handleControllerError: handleControllerError$
|
|
1381
|
+
const { validate: validate$3, handleControllerError: handleControllerError$2 } = validation;
|
|
1362
1382
|
var accounts$1 = {
|
|
1363
1383
|
/**
|
|
1364
1384
|
* Get all email accounts
|
|
@@ -1401,7 +1421,7 @@ var accounts$1 = {
|
|
|
1401
1421
|
message: "Email account created successfully"
|
|
1402
1422
|
};
|
|
1403
1423
|
} catch (err) {
|
|
1404
|
-
handleControllerError$
|
|
1424
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error creating account", "Error creating email account");
|
|
1405
1425
|
}
|
|
1406
1426
|
},
|
|
1407
1427
|
/**
|
|
@@ -1419,7 +1439,7 @@ var accounts$1 = {
|
|
|
1419
1439
|
data: account
|
|
1420
1440
|
};
|
|
1421
1441
|
} catch (err) {
|
|
1422
|
-
handleControllerError$
|
|
1442
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error getting account", "Error fetching email account");
|
|
1423
1443
|
}
|
|
1424
1444
|
},
|
|
1425
1445
|
/**
|
|
@@ -1447,7 +1467,7 @@ var accounts$1 = {
|
|
|
1447
1467
|
message: "Email account updated successfully"
|
|
1448
1468
|
};
|
|
1449
1469
|
} catch (err) {
|
|
1450
|
-
handleControllerError$
|
|
1470
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error updating account", "Error updating email account");
|
|
1451
1471
|
}
|
|
1452
1472
|
},
|
|
1453
1473
|
/**
|
|
@@ -1467,7 +1487,7 @@ var accounts$1 = {
|
|
|
1467
1487
|
const result2 = await accountManager2.testAccount(accountId, recipientEmail, testOptions);
|
|
1468
1488
|
ctx.body = result2;
|
|
1469
1489
|
} catch (err) {
|
|
1470
|
-
handleControllerError$
|
|
1490
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error testing account", "Error testing email account");
|
|
1471
1491
|
}
|
|
1472
1492
|
},
|
|
1473
1493
|
/**
|
|
@@ -2116,7 +2136,7 @@ var oauth$3 = {
|
|
|
2116
2136
|
}
|
|
2117
2137
|
}
|
|
2118
2138
|
};
|
|
2119
|
-
const { handleControllerError } = validation;
|
|
2139
|
+
const { handleControllerError: handleControllerError$1 } = validation;
|
|
2120
2140
|
const ROUTING_RULE_UID = "plugin::magic-mail.routing-rule";
|
|
2121
2141
|
const ALLOWED_RULE_FIELDS = [
|
|
2122
2142
|
"name",
|
|
@@ -2152,7 +2172,7 @@ var routingRules$1 = {
|
|
|
2152
2172
|
data: rules
|
|
2153
2173
|
};
|
|
2154
2174
|
} catch (err) {
|
|
2155
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2175
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2156
2176
|
}
|
|
2157
2177
|
},
|
|
2158
2178
|
/**
|
|
@@ -2171,7 +2191,7 @@ var routingRules$1 = {
|
|
|
2171
2191
|
data: rule2
|
|
2172
2192
|
};
|
|
2173
2193
|
} catch (err) {
|
|
2174
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2194
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2175
2195
|
}
|
|
2176
2196
|
},
|
|
2177
2197
|
/**
|
|
@@ -2193,7 +2213,7 @@ var routingRules$1 = {
|
|
|
2193
2213
|
};
|
|
2194
2214
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule created: ${rule2.name}`);
|
|
2195
2215
|
} catch (err) {
|
|
2196
|
-
handleControllerError(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2216
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2197
2217
|
}
|
|
2198
2218
|
},
|
|
2199
2219
|
/**
|
|
@@ -2217,7 +2237,7 @@ var routingRules$1 = {
|
|
|
2217
2237
|
};
|
|
2218
2238
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule updated: ${rule2.name}`);
|
|
2219
2239
|
} catch (err) {
|
|
2220
|
-
handleControllerError(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2240
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2221
2241
|
}
|
|
2222
2242
|
},
|
|
2223
2243
|
/**
|
|
@@ -2238,7 +2258,7 @@ var routingRules$1 = {
|
|
|
2238
2258
|
};
|
|
2239
2259
|
strapi.log.info(`[magic-mail] Routing rule deleted: ${ruleId}`);
|
|
2240
2260
|
} catch (err) {
|
|
2241
|
-
handleControllerError(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2261
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2242
2262
|
}
|
|
2243
2263
|
}
|
|
2244
2264
|
};
|
|
@@ -2679,7 +2699,10 @@ var license$1 = ({ strapi: strapi2 }) => ({
|
|
|
2679
2699
|
}
|
|
2680
2700
|
}
|
|
2681
2701
|
});
|
|
2682
|
-
const { validate: validate$2 } = validation;
|
|
2702
|
+
const { validate: validate$2, handleControllerError } = validation;
|
|
2703
|
+
function isNotFoundMessage(err) {
|
|
2704
|
+
return err && typeof err.message === "string" && err.message.includes("not found");
|
|
2705
|
+
}
|
|
2683
2706
|
var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
2684
2707
|
/**
|
|
2685
2708
|
* Get all templates
|
|
@@ -2692,7 +2715,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2692
2715
|
data: templates
|
|
2693
2716
|
});
|
|
2694
2717
|
} catch (error) {
|
|
2695
|
-
ctx
|
|
2718
|
+
handleControllerError(ctx, error, "[magic-mail] Error listing templates");
|
|
2696
2719
|
}
|
|
2697
2720
|
},
|
|
2698
2721
|
/**
|
|
@@ -2710,7 +2733,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2710
2733
|
data: template
|
|
2711
2734
|
});
|
|
2712
2735
|
} catch (error) {
|
|
2713
|
-
ctx
|
|
2736
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching template");
|
|
2714
2737
|
}
|
|
2715
2738
|
},
|
|
2716
2739
|
/**
|
|
@@ -2724,10 +2747,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2724
2747
|
data: template
|
|
2725
2748
|
});
|
|
2726
2749
|
} catch (error) {
|
|
2727
|
-
if (error.message.includes("limit reached") || error.message.includes("already exists")) {
|
|
2750
|
+
if (error && typeof error.message === "string" && (error.message.includes("limit reached") || error.message.includes("already exists"))) {
|
|
2728
2751
|
return ctx.badRequest(error.message);
|
|
2729
2752
|
}
|
|
2730
|
-
ctx
|
|
2753
|
+
handleControllerError(ctx, error, "[magic-mail] Error creating template");
|
|
2731
2754
|
}
|
|
2732
2755
|
},
|
|
2733
2756
|
/**
|
|
@@ -2742,10 +2765,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2742
2765
|
data: template
|
|
2743
2766
|
});
|
|
2744
2767
|
} catch (error) {
|
|
2745
|
-
if (error
|
|
2768
|
+
if (isNotFoundMessage(error)) {
|
|
2746
2769
|
return ctx.notFound(error.message);
|
|
2747
2770
|
}
|
|
2748
|
-
ctx
|
|
2771
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating template");
|
|
2749
2772
|
}
|
|
2750
2773
|
},
|
|
2751
2774
|
/**
|
|
@@ -2760,7 +2783,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2760
2783
|
message: "Template deleted successfully"
|
|
2761
2784
|
});
|
|
2762
2785
|
} catch (error) {
|
|
2763
|
-
|
|
2786
|
+
if (isNotFoundMessage(error)) {
|
|
2787
|
+
return ctx.notFound(error.message);
|
|
2788
|
+
}
|
|
2789
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting template");
|
|
2764
2790
|
}
|
|
2765
2791
|
},
|
|
2766
2792
|
/**
|
|
@@ -2775,7 +2801,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2775
2801
|
data: versions
|
|
2776
2802
|
});
|
|
2777
2803
|
} catch (error) {
|
|
2778
|
-
|
|
2804
|
+
if (isNotFoundMessage(error)) {
|
|
2805
|
+
return ctx.notFound(error.message);
|
|
2806
|
+
}
|
|
2807
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching versions");
|
|
2779
2808
|
}
|
|
2780
2809
|
},
|
|
2781
2810
|
/**
|
|
@@ -2790,10 +2819,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2790
2819
|
data: template
|
|
2791
2820
|
});
|
|
2792
2821
|
} catch (error) {
|
|
2793
|
-
if (error
|
|
2822
|
+
if (isNotFoundMessage(error)) {
|
|
2794
2823
|
return ctx.notFound(error.message);
|
|
2795
2824
|
}
|
|
2796
|
-
ctx
|
|
2825
|
+
handleControllerError(ctx, error, "[magic-mail] Error restoring version");
|
|
2797
2826
|
}
|
|
2798
2827
|
},
|
|
2799
2828
|
/**
|
|
@@ -2808,13 +2837,13 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2808
2837
|
data: result2
|
|
2809
2838
|
});
|
|
2810
2839
|
} catch (error) {
|
|
2811
|
-
if (error
|
|
2840
|
+
if (isNotFoundMessage(error)) {
|
|
2812
2841
|
return ctx.notFound(error.message);
|
|
2813
2842
|
}
|
|
2814
|
-
if (error.message.includes("does not belong")) {
|
|
2843
|
+
if (error && typeof error.message === "string" && error.message.includes("does not belong")) {
|
|
2815
2844
|
return ctx.badRequest(error.message);
|
|
2816
2845
|
}
|
|
2817
|
-
ctx
|
|
2846
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting version");
|
|
2818
2847
|
}
|
|
2819
2848
|
},
|
|
2820
2849
|
/**
|
|
@@ -2829,10 +2858,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2829
2858
|
data: result2
|
|
2830
2859
|
});
|
|
2831
2860
|
} catch (error) {
|
|
2832
|
-
if (error
|
|
2861
|
+
if (isNotFoundMessage(error)) {
|
|
2833
2862
|
return ctx.notFound(error.message);
|
|
2834
2863
|
}
|
|
2835
|
-
ctx
|
|
2864
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting all versions");
|
|
2836
2865
|
}
|
|
2837
2866
|
},
|
|
2838
2867
|
/**
|
|
@@ -2848,10 +2877,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2848
2877
|
data: rendered
|
|
2849
2878
|
});
|
|
2850
2879
|
} catch (error) {
|
|
2851
|
-
if (error
|
|
2880
|
+
if (isNotFoundMessage(error)) {
|
|
2852
2881
|
return ctx.notFound(error.message);
|
|
2853
2882
|
}
|
|
2854
|
-
ctx
|
|
2883
|
+
handleControllerError(ctx, error, "[magic-mail] Error rendering template");
|
|
2855
2884
|
}
|
|
2856
2885
|
},
|
|
2857
2886
|
/**
|
|
@@ -2866,10 +2895,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2866
2895
|
data: templates
|
|
2867
2896
|
});
|
|
2868
2897
|
} catch (error) {
|
|
2869
|
-
if (error.message.includes("requires")) {
|
|
2898
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2870
2899
|
return ctx.forbidden(error.message);
|
|
2871
2900
|
}
|
|
2872
|
-
ctx
|
|
2901
|
+
handleControllerError(ctx, error, "[magic-mail] Error exporting templates");
|
|
2873
2902
|
}
|
|
2874
2903
|
},
|
|
2875
2904
|
/**
|
|
@@ -2887,10 +2916,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2887
2916
|
data: results
|
|
2888
2917
|
});
|
|
2889
2918
|
} catch (error) {
|
|
2890
|
-
if (error.message.includes("requires")) {
|
|
2919
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2891
2920
|
return ctx.forbidden(error.message);
|
|
2892
2921
|
}
|
|
2893
|
-
ctx
|
|
2922
|
+
handleControllerError(ctx, error, "[magic-mail] Error importing templates");
|
|
2894
2923
|
}
|
|
2895
2924
|
},
|
|
2896
2925
|
/**
|
|
@@ -2904,7 +2933,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2904
2933
|
data: stats
|
|
2905
2934
|
});
|
|
2906
2935
|
} catch (error) {
|
|
2907
|
-
ctx
|
|
2936
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching stats");
|
|
2908
2937
|
}
|
|
2909
2938
|
},
|
|
2910
2939
|
/**
|
|
@@ -2919,7 +2948,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2919
2948
|
data: template
|
|
2920
2949
|
});
|
|
2921
2950
|
} catch (error) {
|
|
2922
|
-
ctx
|
|
2951
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching core template");
|
|
2923
2952
|
}
|
|
2924
2953
|
},
|
|
2925
2954
|
/**
|
|
@@ -2934,7 +2963,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2934
2963
|
data: template
|
|
2935
2964
|
});
|
|
2936
2965
|
} catch (error) {
|
|
2937
|
-
ctx
|
|
2966
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating core template");
|
|
2938
2967
|
}
|
|
2939
2968
|
},
|
|
2940
2969
|
/**
|
|
@@ -2948,7 +2977,8 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2948
2977
|
if (!template) {
|
|
2949
2978
|
return ctx.notFound("Template not found");
|
|
2950
2979
|
}
|
|
2951
|
-
let fileContent
|
|
2980
|
+
let fileContent;
|
|
2981
|
+
let fileName;
|
|
2952
2982
|
if (type === "json") {
|
|
2953
2983
|
fileContent = JSON.stringify(template.design, null, 2);
|
|
2954
2984
|
fileName = `template-${id}.json`;
|
|
@@ -2963,8 +2993,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2963
2993
|
ctx.set("Content-Disposition", `attachment; filename="${fileName}"`);
|
|
2964
2994
|
ctx.send(fileContent);
|
|
2965
2995
|
} catch (error) {
|
|
2966
|
-
|
|
2967
|
-
ctx.throw(500, error.message);
|
|
2996
|
+
handleControllerError(ctx, error, "[magic-mail] Error downloading template");
|
|
2968
2997
|
}
|
|
2969
2998
|
},
|
|
2970
2999
|
/**
|
|
@@ -2979,10 +3008,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2979
3008
|
data: duplicated
|
|
2980
3009
|
});
|
|
2981
3010
|
} catch (error) {
|
|
2982
|
-
if (error
|
|
3011
|
+
if (isNotFoundMessage(error)) {
|
|
2983
3012
|
return ctx.notFound(error.message);
|
|
2984
3013
|
}
|
|
2985
|
-
ctx
|
|
3014
|
+
handleControllerError(ctx, error, "[magic-mail] Error duplicating template");
|
|
2986
3015
|
}
|
|
2987
3016
|
},
|
|
2988
3017
|
/**
|
|
@@ -3002,7 +3031,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3002
3031
|
const rendered = await strapi2.plugin("magic-mail").service("email-designer").renderTemplate(template.templateReferenceId, {
|
|
3003
3032
|
name: "Test User",
|
|
3004
3033
|
email: to
|
|
3005
|
-
// Add more default test variables as needed
|
|
3006
3034
|
});
|
|
3007
3035
|
const emailRouterService = strapi2.plugin("magic-mail").service("email-router");
|
|
3008
3036
|
const sendOptions = {
|
|
@@ -3010,7 +3038,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3010
3038
|
subject: rendered.subject || template.subject,
|
|
3011
3039
|
html: rendered.html,
|
|
3012
3040
|
text: rendered.text,
|
|
3013
|
-
// Add template tracking info
|
|
3014
3041
|
templateId: template.templateReferenceId,
|
|
3015
3042
|
templateName: template.name
|
|
3016
3043
|
};
|
|
@@ -3028,8 +3055,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3028
3055
|
}
|
|
3029
3056
|
});
|
|
3030
3057
|
} catch (error) {
|
|
3031
|
-
|
|
3032
|
-
return ctx.badRequest(error.message || "Failed to send test email");
|
|
3058
|
+
handleControllerError(ctx, error, "[magic-mail] Error sending test email");
|
|
3033
3059
|
}
|
|
3034
3060
|
}
|
|
3035
3061
|
});
|
|
@@ -15851,7 +15877,7 @@ var oauth$1 = ({ strapi: strapi2 }) => ({
|
|
|
15851
15877
|
return account;
|
|
15852
15878
|
}
|
|
15853
15879
|
});
|
|
15854
|
-
const version = "2.10.
|
|
15880
|
+
const version = "2.10.8";
|
|
15855
15881
|
const require$$2 = {
|
|
15856
15882
|
version
|
|
15857
15883
|
};
|
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()
|
|
@@ -1252,6 +1253,10 @@ function validate$5(schemaName, body) {
|
|
|
1252
1253
|
const strapiErrors = require$$1$2.errors;
|
|
1253
1254
|
const flattened = result2.error.flatten();
|
|
1254
1255
|
const strapiLog = typeof strapi !== "undefined" && strapi && strapi.log ? strapi.log : null;
|
|
1256
|
+
const details = { ...flattened.fieldErrors };
|
|
1257
|
+
if (Array.isArray(flattened.formErrors) && flattened.formErrors.length > 0) {
|
|
1258
|
+
details._form = flattened.formErrors;
|
|
1259
|
+
}
|
|
1255
1260
|
if (strapiLog) {
|
|
1256
1261
|
strapiLog.warn(
|
|
1257
1262
|
`[magic-mail] Validation failed for schema '${schemaName}': ` + JSON.stringify({
|
|
@@ -1260,23 +1265,38 @@ function validate$5(schemaName, body) {
|
|
|
1260
1265
|
})
|
|
1261
1266
|
);
|
|
1262
1267
|
}
|
|
1263
|
-
throw new strapiErrors.ValidationError("Validation failed",
|
|
1268
|
+
throw new strapiErrors.ValidationError("Validation failed", details);
|
|
1264
1269
|
}
|
|
1265
1270
|
return result2.data;
|
|
1266
1271
|
}
|
|
1267
|
-
function handleControllerError$
|
|
1268
|
-
const
|
|
1272
|
+
function handleControllerError$4(ctx, err, logPrefix, fallbackMessage) {
|
|
1273
|
+
const strapiErrors = require$$1$2.errors;
|
|
1274
|
+
const knownStrapiNames = /* @__PURE__ */ new Set([
|
|
1275
|
+
"ApplicationError",
|
|
1276
|
+
"ValidationError",
|
|
1277
|
+
"YupValidationError",
|
|
1278
|
+
"PaginationError",
|
|
1279
|
+
"NotFoundError",
|
|
1280
|
+
"ForbiddenError",
|
|
1281
|
+
"UnauthorizedError",
|
|
1282
|
+
"PayloadTooLargeError",
|
|
1283
|
+
"PolicyError",
|
|
1284
|
+
"NotImplementedError",
|
|
1285
|
+
"RateLimitError",
|
|
1286
|
+
"HttpError"
|
|
1287
|
+
]);
|
|
1288
|
+
const isStrapiError = err && typeof err === "object" && err instanceof strapiErrors.ApplicationError || err && typeof err.name === "string" && knownStrapiNames.has(err.name);
|
|
1269
1289
|
if (isStrapiError) {
|
|
1270
1290
|
strapi.log.warn(
|
|
1271
|
-
`${logPrefix}: ${err.name}
|
|
1291
|
+
`${logPrefix}: ${err.name} — ${err.message}` + (err.details && Object.keys(err.details).length > 0 ? ` | details=${JSON.stringify(err.details)}` : "")
|
|
1272
1292
|
);
|
|
1273
1293
|
throw err;
|
|
1274
1294
|
}
|
|
1275
1295
|
strapi.log.error(`${logPrefix}:`, err);
|
|
1276
1296
|
ctx.throw(500, fallbackMessage || err.message || "Internal server error");
|
|
1277
1297
|
}
|
|
1278
|
-
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$
|
|
1279
|
-
const { validate: validate$4, handleControllerError: handleControllerError$
|
|
1298
|
+
var validation = { validate: validate$5, schemas, handleControllerError: handleControllerError$4 };
|
|
1299
|
+
const { validate: validate$4, handleControllerError: handleControllerError$3 } = validation;
|
|
1280
1300
|
function stripAttachmentPaths(body) {
|
|
1281
1301
|
if (body && Array.isArray(body.attachments)) {
|
|
1282
1302
|
body.attachments = body.attachments.map(({ path: path2, ...safe }) => safe);
|
|
@@ -1292,7 +1312,7 @@ var controller$1 = {
|
|
|
1292
1312
|
const result2 = await emailRouter2.send(body);
|
|
1293
1313
|
ctx.body = { success: true, ...result2 };
|
|
1294
1314
|
} catch (err) {
|
|
1295
|
-
handleControllerError$
|
|
1315
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending email", "Failed to send email");
|
|
1296
1316
|
}
|
|
1297
1317
|
},
|
|
1298
1318
|
async sendMessage(ctx) {
|
|
@@ -1303,7 +1323,7 @@ var controller$1 = {
|
|
|
1303
1323
|
const result2 = await emailRouter2.sendMessage(body);
|
|
1304
1324
|
ctx.body = { success: true, ...result2 };
|
|
1305
1325
|
} catch (err) {
|
|
1306
|
-
handleControllerError$
|
|
1326
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending message", "Failed to send message");
|
|
1307
1327
|
}
|
|
1308
1328
|
},
|
|
1309
1329
|
async sendWhatsApp(ctx) {
|
|
@@ -1313,7 +1333,7 @@ var controller$1 = {
|
|
|
1313
1333
|
const result2 = await emailRouter2.sendWhatsApp(body);
|
|
1314
1334
|
ctx.body = { success: true, ...result2 };
|
|
1315
1335
|
} catch (err) {
|
|
1316
|
-
handleControllerError$
|
|
1336
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error sending WhatsApp", "Failed to send WhatsApp message");
|
|
1317
1337
|
}
|
|
1318
1338
|
},
|
|
1319
1339
|
async getWhatsAppStatus(ctx) {
|
|
@@ -1341,11 +1361,11 @@ var controller$1 = {
|
|
|
1341
1361
|
const result2 = await emailRouter2.checkWhatsAppNumber(phoneNumber);
|
|
1342
1362
|
ctx.body = { success: true, data: result2 };
|
|
1343
1363
|
} catch (err) {
|
|
1344
|
-
handleControllerError$
|
|
1364
|
+
handleControllerError$3(ctx, err, "[magic-mail] Error checking WhatsApp number", "Failed to check phone number");
|
|
1345
1365
|
}
|
|
1346
1366
|
}
|
|
1347
1367
|
};
|
|
1348
|
-
const { validate: validate$3, handleControllerError: handleControllerError$
|
|
1368
|
+
const { validate: validate$3, handleControllerError: handleControllerError$2 } = validation;
|
|
1349
1369
|
var accounts$1 = {
|
|
1350
1370
|
/**
|
|
1351
1371
|
* Get all email accounts
|
|
@@ -1388,7 +1408,7 @@ var accounts$1 = {
|
|
|
1388
1408
|
message: "Email account created successfully"
|
|
1389
1409
|
};
|
|
1390
1410
|
} catch (err) {
|
|
1391
|
-
handleControllerError$
|
|
1411
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error creating account", "Error creating email account");
|
|
1392
1412
|
}
|
|
1393
1413
|
},
|
|
1394
1414
|
/**
|
|
@@ -1406,7 +1426,7 @@ var accounts$1 = {
|
|
|
1406
1426
|
data: account
|
|
1407
1427
|
};
|
|
1408
1428
|
} catch (err) {
|
|
1409
|
-
handleControllerError$
|
|
1429
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error getting account", "Error fetching email account");
|
|
1410
1430
|
}
|
|
1411
1431
|
},
|
|
1412
1432
|
/**
|
|
@@ -1434,7 +1454,7 @@ var accounts$1 = {
|
|
|
1434
1454
|
message: "Email account updated successfully"
|
|
1435
1455
|
};
|
|
1436
1456
|
} catch (err) {
|
|
1437
|
-
handleControllerError$
|
|
1457
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error updating account", "Error updating email account");
|
|
1438
1458
|
}
|
|
1439
1459
|
},
|
|
1440
1460
|
/**
|
|
@@ -1454,7 +1474,7 @@ var accounts$1 = {
|
|
|
1454
1474
|
const result2 = await accountManager2.testAccount(accountId, recipientEmail, testOptions);
|
|
1455
1475
|
ctx.body = result2;
|
|
1456
1476
|
} catch (err) {
|
|
1457
|
-
handleControllerError$
|
|
1477
|
+
handleControllerError$2(ctx, err, "[magic-mail] Error testing account", "Error testing email account");
|
|
1458
1478
|
}
|
|
1459
1479
|
},
|
|
1460
1480
|
/**
|
|
@@ -2103,7 +2123,7 @@ var oauth$3 = {
|
|
|
2103
2123
|
}
|
|
2104
2124
|
}
|
|
2105
2125
|
};
|
|
2106
|
-
const { handleControllerError } = validation;
|
|
2126
|
+
const { handleControllerError: handleControllerError$1 } = validation;
|
|
2107
2127
|
const ROUTING_RULE_UID = "plugin::magic-mail.routing-rule";
|
|
2108
2128
|
const ALLOWED_RULE_FIELDS = [
|
|
2109
2129
|
"name",
|
|
@@ -2139,7 +2159,7 @@ var routingRules$1 = {
|
|
|
2139
2159
|
data: rules
|
|
2140
2160
|
};
|
|
2141
2161
|
} catch (err) {
|
|
2142
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2162
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rules", "Error fetching routing rules");
|
|
2143
2163
|
}
|
|
2144
2164
|
},
|
|
2145
2165
|
/**
|
|
@@ -2158,7 +2178,7 @@ var routingRules$1 = {
|
|
|
2158
2178
|
data: rule2
|
|
2159
2179
|
};
|
|
2160
2180
|
} catch (err) {
|
|
2161
|
-
handleControllerError(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2181
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error getting routing rule", "Error fetching routing rule");
|
|
2162
2182
|
}
|
|
2163
2183
|
},
|
|
2164
2184
|
/**
|
|
@@ -2180,7 +2200,7 @@ var routingRules$1 = {
|
|
|
2180
2200
|
};
|
|
2181
2201
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule created: ${rule2.name}`);
|
|
2182
2202
|
} catch (err) {
|
|
2183
|
-
handleControllerError(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2203
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error creating routing rule", "Error creating routing rule");
|
|
2184
2204
|
}
|
|
2185
2205
|
},
|
|
2186
2206
|
/**
|
|
@@ -2204,7 +2224,7 @@ var routingRules$1 = {
|
|
|
2204
2224
|
};
|
|
2205
2225
|
strapi.log.info(`[magic-mail] [SUCCESS] Routing rule updated: ${rule2.name}`);
|
|
2206
2226
|
} catch (err) {
|
|
2207
|
-
handleControllerError(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2227
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error updating routing rule", "Error updating routing rule");
|
|
2208
2228
|
}
|
|
2209
2229
|
},
|
|
2210
2230
|
/**
|
|
@@ -2225,7 +2245,7 @@ var routingRules$1 = {
|
|
|
2225
2245
|
};
|
|
2226
2246
|
strapi.log.info(`[magic-mail] Routing rule deleted: ${ruleId}`);
|
|
2227
2247
|
} catch (err) {
|
|
2228
|
-
handleControllerError(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2248
|
+
handleControllerError$1(ctx, err, "[magic-mail] Error deleting routing rule", "Error deleting routing rule");
|
|
2229
2249
|
}
|
|
2230
2250
|
}
|
|
2231
2251
|
};
|
|
@@ -2666,7 +2686,10 @@ var license$1 = ({ strapi: strapi2 }) => ({
|
|
|
2666
2686
|
}
|
|
2667
2687
|
}
|
|
2668
2688
|
});
|
|
2669
|
-
const { validate: validate$2 } = validation;
|
|
2689
|
+
const { validate: validate$2, handleControllerError } = validation;
|
|
2690
|
+
function isNotFoundMessage(err) {
|
|
2691
|
+
return err && typeof err.message === "string" && err.message.includes("not found");
|
|
2692
|
+
}
|
|
2670
2693
|
var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
2671
2694
|
/**
|
|
2672
2695
|
* Get all templates
|
|
@@ -2679,7 +2702,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2679
2702
|
data: templates
|
|
2680
2703
|
});
|
|
2681
2704
|
} catch (error) {
|
|
2682
|
-
ctx
|
|
2705
|
+
handleControllerError(ctx, error, "[magic-mail] Error listing templates");
|
|
2683
2706
|
}
|
|
2684
2707
|
},
|
|
2685
2708
|
/**
|
|
@@ -2697,7 +2720,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2697
2720
|
data: template
|
|
2698
2721
|
});
|
|
2699
2722
|
} catch (error) {
|
|
2700
|
-
ctx
|
|
2723
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching template");
|
|
2701
2724
|
}
|
|
2702
2725
|
},
|
|
2703
2726
|
/**
|
|
@@ -2711,10 +2734,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2711
2734
|
data: template
|
|
2712
2735
|
});
|
|
2713
2736
|
} catch (error) {
|
|
2714
|
-
if (error.message.includes("limit reached") || error.message.includes("already exists")) {
|
|
2737
|
+
if (error && typeof error.message === "string" && (error.message.includes("limit reached") || error.message.includes("already exists"))) {
|
|
2715
2738
|
return ctx.badRequest(error.message);
|
|
2716
2739
|
}
|
|
2717
|
-
ctx
|
|
2740
|
+
handleControllerError(ctx, error, "[magic-mail] Error creating template");
|
|
2718
2741
|
}
|
|
2719
2742
|
},
|
|
2720
2743
|
/**
|
|
@@ -2729,10 +2752,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2729
2752
|
data: template
|
|
2730
2753
|
});
|
|
2731
2754
|
} catch (error) {
|
|
2732
|
-
if (error
|
|
2755
|
+
if (isNotFoundMessage(error)) {
|
|
2733
2756
|
return ctx.notFound(error.message);
|
|
2734
2757
|
}
|
|
2735
|
-
ctx
|
|
2758
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating template");
|
|
2736
2759
|
}
|
|
2737
2760
|
},
|
|
2738
2761
|
/**
|
|
@@ -2747,7 +2770,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2747
2770
|
message: "Template deleted successfully"
|
|
2748
2771
|
});
|
|
2749
2772
|
} catch (error) {
|
|
2750
|
-
|
|
2773
|
+
if (isNotFoundMessage(error)) {
|
|
2774
|
+
return ctx.notFound(error.message);
|
|
2775
|
+
}
|
|
2776
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting template");
|
|
2751
2777
|
}
|
|
2752
2778
|
},
|
|
2753
2779
|
/**
|
|
@@ -2762,7 +2788,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2762
2788
|
data: versions
|
|
2763
2789
|
});
|
|
2764
2790
|
} catch (error) {
|
|
2765
|
-
|
|
2791
|
+
if (isNotFoundMessage(error)) {
|
|
2792
|
+
return ctx.notFound(error.message);
|
|
2793
|
+
}
|
|
2794
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching versions");
|
|
2766
2795
|
}
|
|
2767
2796
|
},
|
|
2768
2797
|
/**
|
|
@@ -2777,10 +2806,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2777
2806
|
data: template
|
|
2778
2807
|
});
|
|
2779
2808
|
} catch (error) {
|
|
2780
|
-
if (error
|
|
2809
|
+
if (isNotFoundMessage(error)) {
|
|
2781
2810
|
return ctx.notFound(error.message);
|
|
2782
2811
|
}
|
|
2783
|
-
ctx
|
|
2812
|
+
handleControllerError(ctx, error, "[magic-mail] Error restoring version");
|
|
2784
2813
|
}
|
|
2785
2814
|
},
|
|
2786
2815
|
/**
|
|
@@ -2795,13 +2824,13 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2795
2824
|
data: result2
|
|
2796
2825
|
});
|
|
2797
2826
|
} catch (error) {
|
|
2798
|
-
if (error
|
|
2827
|
+
if (isNotFoundMessage(error)) {
|
|
2799
2828
|
return ctx.notFound(error.message);
|
|
2800
2829
|
}
|
|
2801
|
-
if (error.message.includes("does not belong")) {
|
|
2830
|
+
if (error && typeof error.message === "string" && error.message.includes("does not belong")) {
|
|
2802
2831
|
return ctx.badRequest(error.message);
|
|
2803
2832
|
}
|
|
2804
|
-
ctx
|
|
2833
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting version");
|
|
2805
2834
|
}
|
|
2806
2835
|
},
|
|
2807
2836
|
/**
|
|
@@ -2816,10 +2845,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2816
2845
|
data: result2
|
|
2817
2846
|
});
|
|
2818
2847
|
} catch (error) {
|
|
2819
|
-
if (error
|
|
2848
|
+
if (isNotFoundMessage(error)) {
|
|
2820
2849
|
return ctx.notFound(error.message);
|
|
2821
2850
|
}
|
|
2822
|
-
ctx
|
|
2851
|
+
handleControllerError(ctx, error, "[magic-mail] Error deleting all versions");
|
|
2823
2852
|
}
|
|
2824
2853
|
},
|
|
2825
2854
|
/**
|
|
@@ -2835,10 +2864,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2835
2864
|
data: rendered
|
|
2836
2865
|
});
|
|
2837
2866
|
} catch (error) {
|
|
2838
|
-
if (error
|
|
2867
|
+
if (isNotFoundMessage(error)) {
|
|
2839
2868
|
return ctx.notFound(error.message);
|
|
2840
2869
|
}
|
|
2841
|
-
ctx
|
|
2870
|
+
handleControllerError(ctx, error, "[magic-mail] Error rendering template");
|
|
2842
2871
|
}
|
|
2843
2872
|
},
|
|
2844
2873
|
/**
|
|
@@ -2853,10 +2882,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2853
2882
|
data: templates
|
|
2854
2883
|
});
|
|
2855
2884
|
} catch (error) {
|
|
2856
|
-
if (error.message.includes("requires")) {
|
|
2885
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2857
2886
|
return ctx.forbidden(error.message);
|
|
2858
2887
|
}
|
|
2859
|
-
ctx
|
|
2888
|
+
handleControllerError(ctx, error, "[magic-mail] Error exporting templates");
|
|
2860
2889
|
}
|
|
2861
2890
|
},
|
|
2862
2891
|
/**
|
|
@@ -2874,10 +2903,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2874
2903
|
data: results
|
|
2875
2904
|
});
|
|
2876
2905
|
} catch (error) {
|
|
2877
|
-
if (error.message.includes("requires")) {
|
|
2906
|
+
if (error && typeof error.message === "string" && error.message.includes("requires")) {
|
|
2878
2907
|
return ctx.forbidden(error.message);
|
|
2879
2908
|
}
|
|
2880
|
-
ctx
|
|
2909
|
+
handleControllerError(ctx, error, "[magic-mail] Error importing templates");
|
|
2881
2910
|
}
|
|
2882
2911
|
},
|
|
2883
2912
|
/**
|
|
@@ -2891,7 +2920,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2891
2920
|
data: stats
|
|
2892
2921
|
});
|
|
2893
2922
|
} catch (error) {
|
|
2894
|
-
ctx
|
|
2923
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching stats");
|
|
2895
2924
|
}
|
|
2896
2925
|
},
|
|
2897
2926
|
/**
|
|
@@ -2906,7 +2935,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2906
2935
|
data: template
|
|
2907
2936
|
});
|
|
2908
2937
|
} catch (error) {
|
|
2909
|
-
ctx
|
|
2938
|
+
handleControllerError(ctx, error, "[magic-mail] Error fetching core template");
|
|
2910
2939
|
}
|
|
2911
2940
|
},
|
|
2912
2941
|
/**
|
|
@@ -2921,7 +2950,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2921
2950
|
data: template
|
|
2922
2951
|
});
|
|
2923
2952
|
} catch (error) {
|
|
2924
|
-
ctx
|
|
2953
|
+
handleControllerError(ctx, error, "[magic-mail] Error updating core template");
|
|
2925
2954
|
}
|
|
2926
2955
|
},
|
|
2927
2956
|
/**
|
|
@@ -2935,7 +2964,8 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2935
2964
|
if (!template) {
|
|
2936
2965
|
return ctx.notFound("Template not found");
|
|
2937
2966
|
}
|
|
2938
|
-
let fileContent
|
|
2967
|
+
let fileContent;
|
|
2968
|
+
let fileName;
|
|
2939
2969
|
if (type === "json") {
|
|
2940
2970
|
fileContent = JSON.stringify(template.design, null, 2);
|
|
2941
2971
|
fileName = `template-${id}.json`;
|
|
@@ -2950,8 +2980,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2950
2980
|
ctx.set("Content-Disposition", `attachment; filename="${fileName}"`);
|
|
2951
2981
|
ctx.send(fileContent);
|
|
2952
2982
|
} catch (error) {
|
|
2953
|
-
|
|
2954
|
-
ctx.throw(500, error.message);
|
|
2983
|
+
handleControllerError(ctx, error, "[magic-mail] Error downloading template");
|
|
2955
2984
|
}
|
|
2956
2985
|
},
|
|
2957
2986
|
/**
|
|
@@ -2966,10 +2995,10 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2966
2995
|
data: duplicated
|
|
2967
2996
|
});
|
|
2968
2997
|
} catch (error) {
|
|
2969
|
-
if (error
|
|
2998
|
+
if (isNotFoundMessage(error)) {
|
|
2970
2999
|
return ctx.notFound(error.message);
|
|
2971
3000
|
}
|
|
2972
|
-
ctx
|
|
3001
|
+
handleControllerError(ctx, error, "[magic-mail] Error duplicating template");
|
|
2973
3002
|
}
|
|
2974
3003
|
},
|
|
2975
3004
|
/**
|
|
@@ -2989,7 +3018,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2989
3018
|
const rendered = await strapi2.plugin("magic-mail").service("email-designer").renderTemplate(template.templateReferenceId, {
|
|
2990
3019
|
name: "Test User",
|
|
2991
3020
|
email: to
|
|
2992
|
-
// Add more default test variables as needed
|
|
2993
3021
|
});
|
|
2994
3022
|
const emailRouterService = strapi2.plugin("magic-mail").service("email-router");
|
|
2995
3023
|
const sendOptions = {
|
|
@@ -2997,7 +3025,6 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
2997
3025
|
subject: rendered.subject || template.subject,
|
|
2998
3026
|
html: rendered.html,
|
|
2999
3027
|
text: rendered.text,
|
|
3000
|
-
// Add template tracking info
|
|
3001
3028
|
templateId: template.templateReferenceId,
|
|
3002
3029
|
templateName: template.name
|
|
3003
3030
|
};
|
|
@@ -3015,8 +3042,7 @@ var emailDesigner$3 = ({ strapi: strapi2 }) => ({
|
|
|
3015
3042
|
}
|
|
3016
3043
|
});
|
|
3017
3044
|
} catch (error) {
|
|
3018
|
-
|
|
3019
|
-
return ctx.badRequest(error.message || "Failed to send test email");
|
|
3045
|
+
handleControllerError(ctx, error, "[magic-mail] Error sending test email");
|
|
3020
3046
|
}
|
|
3021
3047
|
}
|
|
3022
3048
|
});
|
|
@@ -15838,7 +15864,7 @@ var oauth$1 = ({ strapi: strapi2 }) => ({
|
|
|
15838
15864
|
return account;
|
|
15839
15865
|
}
|
|
15840
15866
|
});
|
|
15841
|
-
const version = "2.10.
|
|
15867
|
+
const version = "2.10.8";
|
|
15842
15868
|
const require$$2 = {
|
|
15843
15869
|
version
|
|
15844
15870
|
};
|
package/package.json
CHANGED