strapi-plugin-magic-mail 2.2.3 → 2.2.5
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/dist/server/index.js +1 -1
- package/dist/server/index.mjs +1 -1
- package/package.json +1 -3
- package/admin/jsconfig.json +0 -10
- package/admin/src/components/AddAccountModal.jsx +0 -1943
- package/admin/src/components/Initializer.jsx +0 -14
- package/admin/src/components/LicenseGuard.jsx +0 -475
- package/admin/src/components/PluginIcon.jsx +0 -5
- package/admin/src/hooks/useAuthRefresh.js +0 -44
- package/admin/src/hooks/useLicense.js +0 -158
- package/admin/src/index.js +0 -87
- package/admin/src/pages/Analytics.jsx +0 -762
- package/admin/src/pages/App.jsx +0 -111
- package/admin/src/pages/EmailDesigner/EditorPage.jsx +0 -1424
- package/admin/src/pages/EmailDesigner/TemplateList.jsx +0 -1807
- package/admin/src/pages/HomePage.jsx +0 -1170
- package/admin/src/pages/LicensePage.jsx +0 -430
- package/admin/src/pages/RoutingRules.jsx +0 -1141
- package/admin/src/pages/Settings.jsx +0 -603
- package/admin/src/pluginId.js +0 -3
- package/admin/src/translations/de.json +0 -71
- package/admin/src/translations/en.json +0 -70
- package/admin/src/translations/es.json +0 -71
- package/admin/src/translations/fr.json +0 -71
- package/admin/src/translations/pt.json +0 -71
- package/admin/src/utils/fetchWithRetry.js +0 -123
- package/admin/src/utils/getTranslation.js +0 -5
- package/admin/src/utils/theme.js +0 -85
- package/server/jsconfig.json +0 -10
- package/server/src/bootstrap.js +0 -157
- package/server/src/config/features.js +0 -260
- package/server/src/config/index.js +0 -9
- package/server/src/content-types/email-account/schema.json +0 -93
- package/server/src/content-types/email-event/index.js +0 -8
- package/server/src/content-types/email-event/schema.json +0 -57
- package/server/src/content-types/email-link/index.js +0 -8
- package/server/src/content-types/email-link/schema.json +0 -49
- package/server/src/content-types/email-log/index.js +0 -8
- package/server/src/content-types/email-log/schema.json +0 -106
- package/server/src/content-types/email-template/schema.json +0 -74
- package/server/src/content-types/email-template-version/schema.json +0 -60
- package/server/src/content-types/index.js +0 -33
- package/server/src/content-types/routing-rule/schema.json +0 -59
- package/server/src/controllers/accounts.js +0 -229
- package/server/src/controllers/analytics.js +0 -361
- package/server/src/controllers/controller.js +0 -26
- package/server/src/controllers/email-designer.js +0 -474
- package/server/src/controllers/index.js +0 -21
- package/server/src/controllers/license.js +0 -269
- package/server/src/controllers/oauth.js +0 -474
- package/server/src/controllers/routing-rules.js +0 -129
- package/server/src/controllers/test.js +0 -301
- package/server/src/destroy.js +0 -27
- package/server/src/index.js +0 -25
- package/server/src/middlewares/index.js +0 -3
- package/server/src/policies/index.js +0 -3
- package/server/src/register.js +0 -5
- package/server/src/routes/admin.js +0 -469
- package/server/src/routes/content-api.js +0 -37
- package/server/src/routes/index.js +0 -9
- package/server/src/services/account-manager.js +0 -329
- package/server/src/services/analytics.js +0 -512
- package/server/src/services/email-designer.js +0 -717
- package/server/src/services/email-router.js +0 -1446
- package/server/src/services/index.js +0 -17
- package/server/src/services/license-guard.js +0 -423
- package/server/src/services/oauth.js +0 -515
- package/server/src/services/service.js +0 -7
- package/server/src/utils/encryption.js +0 -81
- package/server/src/utils/logger.js +0 -84
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"kind": "collectionType",
|
|
3
|
-
"collectionName": "magic_mail_email_template_versions",
|
|
4
|
-
"info": {
|
|
5
|
-
"singularName": "email-template-version",
|
|
6
|
-
"pluralName": "email-template-versions",
|
|
7
|
-
"displayName": "Email Template Version",
|
|
8
|
-
"description": "Version history for email templates"
|
|
9
|
-
},
|
|
10
|
-
"options": {
|
|
11
|
-
"draftAndPublish": false,
|
|
12
|
-
"timestamps": true
|
|
13
|
-
},
|
|
14
|
-
"pluginOptions": {
|
|
15
|
-
"content-manager": {
|
|
16
|
-
"visible": false
|
|
17
|
-
},
|
|
18
|
-
"content-type-builder": {
|
|
19
|
-
"visible": false
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"attributes": {
|
|
23
|
-
"template": {
|
|
24
|
-
"type": "relation",
|
|
25
|
-
"relation": "manyToOne",
|
|
26
|
-
"target": "plugin::magic-mail.email-template",
|
|
27
|
-
"inversedBy": "versions"
|
|
28
|
-
},
|
|
29
|
-
"versionNumber": {
|
|
30
|
-
"type": "integer",
|
|
31
|
-
"required": true,
|
|
32
|
-
"configurable": false
|
|
33
|
-
},
|
|
34
|
-
"name": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"configurable": false
|
|
37
|
-
},
|
|
38
|
-
"subject": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"configurable": false
|
|
41
|
-
},
|
|
42
|
-
"design": {
|
|
43
|
-
"type": "json",
|
|
44
|
-
"configurable": false
|
|
45
|
-
},
|
|
46
|
-
"bodyHtml": {
|
|
47
|
-
"type": "text",
|
|
48
|
-
"configurable": false
|
|
49
|
-
},
|
|
50
|
-
"bodyText": {
|
|
51
|
-
"type": "text",
|
|
52
|
-
"configurable": false
|
|
53
|
-
},
|
|
54
|
-
"tags": {
|
|
55
|
-
"type": "json",
|
|
56
|
-
"configurable": false
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const emailAccount = require('./email-account/schema.json');
|
|
4
|
-
const routingRule = require('./routing-rule/schema.json');
|
|
5
|
-
const emailLog = require('./email-log/schema.json');
|
|
6
|
-
const emailEvent = require('./email-event/schema.json');
|
|
7
|
-
const emailLink = require('./email-link/schema.json');
|
|
8
|
-
const emailTemplate = require('./email-template/schema.json');
|
|
9
|
-
const emailTemplateVersion = require('./email-template-version/schema.json');
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
'email-account': {
|
|
13
|
-
schema: emailAccount,
|
|
14
|
-
},
|
|
15
|
-
'routing-rule': {
|
|
16
|
-
schema: routingRule,
|
|
17
|
-
},
|
|
18
|
-
'email-log': {
|
|
19
|
-
schema: emailLog,
|
|
20
|
-
},
|
|
21
|
-
'email-event': {
|
|
22
|
-
schema: emailEvent,
|
|
23
|
-
},
|
|
24
|
-
'email-link': {
|
|
25
|
-
schema: emailLink,
|
|
26
|
-
},
|
|
27
|
-
'email-template': {
|
|
28
|
-
schema: emailTemplate,
|
|
29
|
-
},
|
|
30
|
-
'email-template-version': {
|
|
31
|
-
schema: emailTemplateVersion,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"kind": "collectionType",
|
|
3
|
-
"collectionName": "magic_mail_routing_rules",
|
|
4
|
-
"info": {
|
|
5
|
-
"singularName": "routing-rule",
|
|
6
|
-
"pluralName": "routing-rules",
|
|
7
|
-
"displayName": "Email Routing Rule",
|
|
8
|
-
"description": "Rules for routing emails to specific accounts"
|
|
9
|
-
},
|
|
10
|
-
"options": {
|
|
11
|
-
"draftAndPublish": false
|
|
12
|
-
},
|
|
13
|
-
"pluginOptions": {
|
|
14
|
-
"content-manager": {
|
|
15
|
-
"visible": false
|
|
16
|
-
},
|
|
17
|
-
"content-type-builder": {
|
|
18
|
-
"visible": false
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"attributes": {
|
|
22
|
-
"name": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"required": true,
|
|
25
|
-
"unique": true
|
|
26
|
-
},
|
|
27
|
-
"description": {
|
|
28
|
-
"type": "text"
|
|
29
|
-
},
|
|
30
|
-
"isActive": {
|
|
31
|
-
"type": "boolean",
|
|
32
|
-
"default": true,
|
|
33
|
-
"required": true
|
|
34
|
-
},
|
|
35
|
-
"priority": {
|
|
36
|
-
"type": "integer",
|
|
37
|
-
"default": 1,
|
|
38
|
-
"min": 1
|
|
39
|
-
},
|
|
40
|
-
"matchType": {
|
|
41
|
-
"type": "enumeration",
|
|
42
|
-
"enum": ["emailType", "subject", "recipient", "template", "custom"],
|
|
43
|
-
"required": true,
|
|
44
|
-
"default": "emailType"
|
|
45
|
-
},
|
|
46
|
-
"matchValue": {
|
|
47
|
-
"type": "text",
|
|
48
|
-
"required": true
|
|
49
|
-
},
|
|
50
|
-
"accountName": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"required": true
|
|
53
|
-
},
|
|
54
|
-
"fallbackAccountName": {
|
|
55
|
-
"type": "string"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Accounts Controller
|
|
5
|
-
* Manages email accounts CRUD operations
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
/**
|
|
10
|
-
* Get all email accounts
|
|
11
|
-
*/
|
|
12
|
-
async getAll(ctx) {
|
|
13
|
-
try {
|
|
14
|
-
const accountManager = strapi.plugin('magic-mail').service('account-manager');
|
|
15
|
-
const accounts = await accountManager.getAllAccounts();
|
|
16
|
-
|
|
17
|
-
ctx.body = {
|
|
18
|
-
data: accounts,
|
|
19
|
-
meta: { count: accounts.length },
|
|
20
|
-
};
|
|
21
|
-
} catch (err) {
|
|
22
|
-
strapi.log.error('[magic-mail] Error getting accounts:', err);
|
|
23
|
-
ctx.throw(500, 'Error fetching email accounts');
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Create new email account
|
|
29
|
-
*/
|
|
30
|
-
async create(ctx) {
|
|
31
|
-
try {
|
|
32
|
-
const licenseGuard = strapi.plugin('magic-mail').service('license-guard');
|
|
33
|
-
const accountData = ctx.request.body;
|
|
34
|
-
|
|
35
|
-
// Check if provider is allowed by license
|
|
36
|
-
const providerAllowed = await licenseGuard.isProviderAllowed(accountData.provider);
|
|
37
|
-
if (!providerAllowed) {
|
|
38
|
-
ctx.throw(403, `Provider "${accountData.provider}" requires a Premium license or higher. Please upgrade your license.`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check account limit using Document Service count()
|
|
43
|
-
const currentAccounts = await strapi.documents('plugin::magic-mail.email-account').count();
|
|
44
|
-
const maxAccounts = await licenseGuard.getMaxAccounts();
|
|
45
|
-
|
|
46
|
-
if (maxAccounts !== -1 && currentAccounts >= maxAccounts) {
|
|
47
|
-
ctx.throw(403, `Account limit reached (${maxAccounts}). Upgrade your license to add more accounts.`);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const accountManager = strapi.plugin('magic-mail').service('account-manager');
|
|
52
|
-
const account = await accountManager.createAccount(accountData);
|
|
53
|
-
|
|
54
|
-
ctx.body = {
|
|
55
|
-
data: account,
|
|
56
|
-
message: 'Email account created successfully',
|
|
57
|
-
};
|
|
58
|
-
} catch (err) {
|
|
59
|
-
strapi.log.error('[magic-mail] Error creating account:', err);
|
|
60
|
-
ctx.throw(err.status || 500, err.message || 'Error creating email account');
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Get single account with decrypted config (for editing)
|
|
66
|
-
*/
|
|
67
|
-
async getOne(ctx) {
|
|
68
|
-
try {
|
|
69
|
-
const { accountId } = ctx.params;
|
|
70
|
-
const accountManager = strapi.plugin('magic-mail').service('account-manager');
|
|
71
|
-
const account = await accountManager.getAccountWithDecryptedConfig(accountId);
|
|
72
|
-
|
|
73
|
-
ctx.body = {
|
|
74
|
-
data: account,
|
|
75
|
-
};
|
|
76
|
-
} catch (err) {
|
|
77
|
-
strapi.log.error('[magic-mail] Error getting account:', err);
|
|
78
|
-
ctx.throw(500, 'Error fetching email account');
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Update email account
|
|
84
|
-
*/
|
|
85
|
-
async update(ctx) {
|
|
86
|
-
try {
|
|
87
|
-
const { accountId } = ctx.params;
|
|
88
|
-
const accountManager = strapi.plugin('magic-mail').service('account-manager');
|
|
89
|
-
const account = await accountManager.updateAccount(accountId, ctx.request.body);
|
|
90
|
-
|
|
91
|
-
ctx.body = {
|
|
92
|
-
data: account,
|
|
93
|
-
message: 'Email account updated successfully',
|
|
94
|
-
};
|
|
95
|
-
} catch (err) {
|
|
96
|
-
strapi.log.error('[magic-mail] Error updating account:', err);
|
|
97
|
-
ctx.throw(500, err.message || 'Error updating email account');
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Test email account
|
|
103
|
-
*/
|
|
104
|
-
async test(ctx) {
|
|
105
|
-
try {
|
|
106
|
-
const { accountId } = ctx.params;
|
|
107
|
-
const { testEmail, priority, type, unsubscribeUrl } = ctx.request.body;
|
|
108
|
-
|
|
109
|
-
const testOptions = {
|
|
110
|
-
priority: priority || 'normal',
|
|
111
|
-
type: type || 'transactional',
|
|
112
|
-
unsubscribeUrl: unsubscribeUrl || null,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const accountManager = strapi.plugin('magic-mail').service('account-manager');
|
|
116
|
-
const result = await accountManager.testAccount(accountId, testEmail, testOptions);
|
|
117
|
-
|
|
118
|
-
ctx.body = result;
|
|
119
|
-
} catch (err) {
|
|
120
|
-
strapi.log.error('[magic-mail] Error testing account:', err);
|
|
121
|
-
ctx.throw(500, 'Error testing email account');
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Test Strapi Email Service Integration
|
|
127
|
-
* Tests if MagicMail intercepts native Strapi email service
|
|
128
|
-
*/
|
|
129
|
-
async testStrapiService(ctx) {
|
|
130
|
-
try {
|
|
131
|
-
const { testEmail, accountName } = ctx.request.body;
|
|
132
|
-
|
|
133
|
-
if (!testEmail) {
|
|
134
|
-
ctx.throw(400, 'testEmail is required');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
strapi.log.info('[magic-mail] 🧪 Testing Strapi Email Service integration...');
|
|
138
|
-
strapi.log.info('[magic-mail] [EMAIL] Calling strapi.plugin("email").service("email").send()');
|
|
139
|
-
if (accountName) {
|
|
140
|
-
strapi.log.info(`[magic-mail] [FORCE] Forcing specific account: ${accountName}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Call native Strapi email service - should be intercepted by MagicMail!
|
|
144
|
-
const result = await strapi.plugin('email').service('email').send({
|
|
145
|
-
to: testEmail,
|
|
146
|
-
from: 'test@magicmail.com',
|
|
147
|
-
subject: 'MagicMail Integration Test',
|
|
148
|
-
text: 'This email was sent using Strapi\'s native email service but routed through MagicMail!',
|
|
149
|
-
html: `
|
|
150
|
-
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
151
|
-
<h1 style="color: #0EA5E9;">MagicMail Integration Test</h1>
|
|
152
|
-
<p style="font-size: 16px; color: #374151;">
|
|
153
|
-
This email was sent using <strong>Strapi's native email service</strong>
|
|
154
|
-
but <strong>routed through MagicMail's smart routing</strong>!
|
|
155
|
-
</p>
|
|
156
|
-
<div style="background: #F0F9FF; border-left: 4px solid #0EA5E9; padding: 15px; margin: 20px 0;">
|
|
157
|
-
<h3 style="margin-top: 0; color: #0369A1;">Integration Working</h3>
|
|
158
|
-
<p style="margin: 0;">
|
|
159
|
-
MagicMail successfully intercepted the email and applied:
|
|
160
|
-
</p>
|
|
161
|
-
<ul style="margin: 10px 0;">
|
|
162
|
-
<li>Smart routing rules</li>
|
|
163
|
-
<li>Account selection (${accountName ? 'Forced: ' + accountName : 'Primary or by routing rules'})</li>
|
|
164
|
-
<li>Rate limiting</li>
|
|
165
|
-
<li>Email logging</li>
|
|
166
|
-
<li>Statistics tracking</li>
|
|
167
|
-
</ul>
|
|
168
|
-
</div>
|
|
169
|
-
<div style="background: #DCFCE7; border: 1px solid #22C55E; border-radius: 8px; padding: 15px; margin: 20px 0;">
|
|
170
|
-
<h3 style="margin-top: 0; color: #15803D;">Security Features Active</h3>
|
|
171
|
-
<ul style="margin: 10px 0; padding-left: 20px;">
|
|
172
|
-
<li>TLS/SSL Encryption enforced</li>
|
|
173
|
-
<li>Email content validated</li>
|
|
174
|
-
<li>Proper headers included</li>
|
|
175
|
-
<li>Message-ID generated</li>
|
|
176
|
-
</ul>
|
|
177
|
-
</div>
|
|
178
|
-
<p style="color: #6B7280; font-size: 14px; margin-top: 30px;">
|
|
179
|
-
Sent at: ${new Date().toLocaleString()}<br>
|
|
180
|
-
Via: MagicMail Email Router
|
|
181
|
-
</p>
|
|
182
|
-
</div>
|
|
183
|
-
`,
|
|
184
|
-
type: 'transactional',
|
|
185
|
-
accountName: accountName || null, // Force specific account if provided
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
strapi.log.info('[magic-mail] [SUCCESS] Strapi Email Service test completed');
|
|
189
|
-
|
|
190
|
-
ctx.body = {
|
|
191
|
-
success: true,
|
|
192
|
-
message: 'Email sent via Strapi Email Service (intercepted by MagicMail)',
|
|
193
|
-
result,
|
|
194
|
-
info: {
|
|
195
|
-
method: 'strapi.plugin("email").service("email").send()',
|
|
196
|
-
intercepted: true,
|
|
197
|
-
routedThrough: 'MagicMail',
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
} catch (err) {
|
|
201
|
-
strapi.log.error('[magic-mail] [ERROR] Strapi Email Service test failed:', err);
|
|
202
|
-
ctx.body = {
|
|
203
|
-
success: false,
|
|
204
|
-
message: 'Failed to send test email',
|
|
205
|
-
error: err.message,
|
|
206
|
-
};
|
|
207
|
-
ctx.status = 500;
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Delete email account
|
|
213
|
-
*/
|
|
214
|
-
async delete(ctx) {
|
|
215
|
-
try {
|
|
216
|
-
const { accountId } = ctx.params;
|
|
217
|
-
const accountManager = strapi.plugin('magic-mail').service('account-manager');
|
|
218
|
-
await accountManager.deleteAccount(accountId);
|
|
219
|
-
|
|
220
|
-
ctx.body = {
|
|
221
|
-
message: 'Email account deleted successfully',
|
|
222
|
-
};
|
|
223
|
-
} catch (err) {
|
|
224
|
-
strapi.log.error('[magic-mail] Error deleting account:', err);
|
|
225
|
-
ctx.throw(500, 'Error deleting email account');
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
|