@nocobase/plugin-notification-email 2.0.0-alpha.51 → 2.0.0-alpha.53
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/externalVersion.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.0.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.0.0-alpha.53",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/plugin-notification-manager": "2.0.0-alpha.
|
|
14
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
15
|
-
"@nocobase/server": "2.0.0-alpha.
|
|
13
|
+
"@nocobase/plugin-notification-manager": "2.0.0-alpha.53",
|
|
14
|
+
"@nocobase/utils": "2.0.0-alpha.53",
|
|
15
|
+
"@nocobase/server": "2.0.0-alpha.53",
|
|
16
16
|
"react-i18next": "11.18.6"
|
|
17
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"nodemailer","version":"6.9.7","description":"Easy as cake e-mail sending from your Node.js applications","main":"lib/nodemailer.js","scripts":{"test":"grunt --trace-warnings","update":"rm -rf node_modules/ package-lock.json && ncu -u && npm install"},"repository":{"type":"git","url":"https://github.com/nodemailer/nodemailer.git"},"keywords":["Nodemailer"],"author":"Andris Reinman","license":"MIT-0","bugs":{"url":"https://github.com/nodemailer/nodemailer/issues"},"homepage":"https://nodemailer.com/","devDependencies":{"@aws-sdk/client-ses":"3.433.0","aws-sdk":"2.1478.0","bunyan":"1.8.15","chai":"4.3.10","eslint-config-nodemailer":"1.2.0","eslint-config-prettier":"9.0.0","grunt":"1.6.1","grunt-cli":"1.4.3","grunt-eslint":"24.3.0","grunt-mocha-test":"0.13.3","libbase64":"1.2.1","libmime":"5.2.1","libqp":"2.0.1","mocha":"10.2.0","nodemailer-ntlm-auth":"1.0.4","proxy":"1.0.2","proxy-test-server":"1.0.0","sinon":"17.0.0","smtp-server":"3.13.0"},"engines":{"node":">=6.0.0"},"_lastModified":"2025-12-
|
|
1
|
+
{"name":"nodemailer","version":"6.9.7","description":"Easy as cake e-mail sending from your Node.js applications","main":"lib/nodemailer.js","scripts":{"test":"grunt --trace-warnings","update":"rm -rf node_modules/ package-lock.json && ncu -u && npm install"},"repository":{"type":"git","url":"https://github.com/nodemailer/nodemailer.git"},"keywords":["Nodemailer"],"author":"Andris Reinman","license":"MIT-0","bugs":{"url":"https://github.com/nodemailer/nodemailer/issues"},"homepage":"https://nodemailer.com/","devDependencies":{"@aws-sdk/client-ses":"3.433.0","aws-sdk":"2.1478.0","bunyan":"1.8.15","chai":"4.3.10","eslint-config-nodemailer":"1.2.0","eslint-config-prettier":"9.0.0","grunt":"1.6.1","grunt-cli":"1.4.3","grunt-eslint":"24.3.0","grunt-mocha-test":"0.13.3","libbase64":"1.2.1","libmime":"5.2.1","libqp":"2.0.1","mocha":"10.2.0","nodemailer-ntlm-auth":"1.0.4","proxy":"1.0.2","proxy-test-server":"1.0.0","sinon":"17.0.0","smtp-server":"3.13.0"},"engines":{"node":">=6.0.0"},"_lastModified":"2025-12-12T08:01:49.751Z"}
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { BaseNotificationChannel } from '@nocobase/plugin-notification-manager';
|
|
10
|
-
import { Transporter } from 'nodemailer';
|
|
11
10
|
export declare class MailNotificationChannel extends BaseNotificationChannel {
|
|
12
|
-
|
|
11
|
+
private static transporterMap;
|
|
12
|
+
private static configMap;
|
|
13
|
+
private getTransporterKey;
|
|
14
|
+
private isConfigChanged;
|
|
15
|
+
private createNewTransporter;
|
|
16
|
+
private getTransporter;
|
|
13
17
|
send(args: any): Promise<any>;
|
|
14
18
|
}
|
|
@@ -42,21 +42,55 @@ module.exports = __toCommonJS(mail_server_exports);
|
|
|
42
42
|
var import_plugin_notification_manager = require("@nocobase/plugin-notification-manager");
|
|
43
43
|
var nodemailer = __toESM(require("nodemailer"));
|
|
44
44
|
class MailNotificationChannel extends import_plugin_notification_manager.BaseNotificationChannel {
|
|
45
|
-
transpoter;
|
|
45
|
+
// transpoter: Transporter;
|
|
46
|
+
static transporterMap = /* @__PURE__ */ new Map();
|
|
47
|
+
static configMap = /* @__PURE__ */ new Map();
|
|
48
|
+
getTransporterKey(channel) {
|
|
49
|
+
const { host, port, account } = channel.options;
|
|
50
|
+
return `${host}:${port}:${account}`;
|
|
51
|
+
}
|
|
52
|
+
isConfigChanged(oldConfig, newConfig) {
|
|
53
|
+
const fields = ["host", "port", "secure", "account", "password", "from"];
|
|
54
|
+
return fields.some((key) => oldConfig[key] !== newConfig[key]);
|
|
55
|
+
}
|
|
56
|
+
createNewTransporter(key, config) {
|
|
57
|
+
const { host, port, secure, account, password } = config;
|
|
58
|
+
const transporter = nodemailer.createTransport({
|
|
59
|
+
pool: true,
|
|
60
|
+
host,
|
|
61
|
+
port,
|
|
62
|
+
secure,
|
|
63
|
+
auth: {
|
|
64
|
+
user: account,
|
|
65
|
+
pass: password
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
MailNotificationChannel.transporterMap.set(key, transporter);
|
|
69
|
+
MailNotificationChannel.configMap.set(key, config);
|
|
70
|
+
return transporter;
|
|
71
|
+
}
|
|
72
|
+
getTransporter(channel) {
|
|
73
|
+
const key = this.getTransporterKey(channel);
|
|
74
|
+
const newConfig = channel.options;
|
|
75
|
+
const oldConfig = MailNotificationChannel.configMap.get(key);
|
|
76
|
+
if (!oldConfig) {
|
|
77
|
+
return this.createNewTransporter(key, newConfig);
|
|
78
|
+
}
|
|
79
|
+
if (this.isConfigChanged(oldConfig, newConfig)) {
|
|
80
|
+
const oldTransporter = MailNotificationChannel.transporterMap.get(key);
|
|
81
|
+
if (oldTransporter) {
|
|
82
|
+
oldTransporter.close();
|
|
83
|
+
}
|
|
84
|
+
return this.createNewTransporter(key, newConfig);
|
|
85
|
+
}
|
|
86
|
+
return MailNotificationChannel.transporterMap.get(key);
|
|
87
|
+
}
|
|
46
88
|
async send(args) {
|
|
47
89
|
const { message, channel, receivers } = args;
|
|
48
90
|
const { host, port, secure, account, password, from } = channel.options;
|
|
49
91
|
const userRepo = this.app.db.getRepository("users");
|
|
50
92
|
try {
|
|
51
|
-
const transpoter =
|
|
52
|
-
host,
|
|
53
|
-
port,
|
|
54
|
-
secure,
|
|
55
|
-
auth: {
|
|
56
|
-
user: account,
|
|
57
|
-
pass: password
|
|
58
|
-
}
|
|
59
|
-
});
|
|
93
|
+
const transpoter = this.getTransporter(channel);
|
|
60
94
|
const { subject, cc, bcc, to, contentType } = message;
|
|
61
95
|
if ((receivers == null ? void 0 : receivers.type) === "userId") {
|
|
62
96
|
const users = await userRepo.find({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-notification-email",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.53",
|
|
4
4
|
"displayName": "Notification: Email",
|
|
5
5
|
"displayName.ru-RU": "Уведомления: Электронная почта (Email)",
|
|
6
6
|
"displayName.zh-CN": "通知:电子邮件",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"keywords": [
|
|
25
25
|
"Notification"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "ff30cf8261f5a97b3f24c3752af5bbc564167b37"
|
|
28
28
|
}
|