@nocobase/plugin-notification-email 1.4.0-alpha.20241024151311 → 1.4.0-alpha.20241027230531
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare const ContentConfigForm: ({ variableOptions }: {
|
|
11
|
+
variableOptions: any;
|
|
12
|
+
}) => React.JSX.Element;
|
package/dist/client/index.js
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(e,
|
|
10
|
+
(function(e,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@nocobase/client"),require("@nocobase/plugin-notification-manager/client"),require("@nocobase/utils/client"),require("react/jsx-runtime"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-notification-manager/client","@nocobase/utils/client","react/jsx-runtime","react-i18next"],o):(e=typeof globalThis!="undefined"?globalThis:e||self,o(e["@nocobase/plugin-notification-email"]={},e["@nocobase/client"],e["@nocobase/plugin-notification-manager"],e["@nocobase/utils"],e.jsxRuntime,e["react-i18next"]))})(this,function(e,o,n,m,p,d){"use strict";var a=(e,o,n)=>new Promise((m,p)=>{var d=r=>{try{i(n.next(r))}catch(c){p(c)}},l=r=>{try{i(n.throw(r))}catch(c){p(c)}},i=r=>r.done?m(r.value):Promise.resolve(r.value).then(d,l);i((n=n.apply(e,o)).next())});const l="email",i="@nocobase/plugin-notification-email";function r(){return d.useTranslation([i,"client"],{nsMode:"fallback"})}const c=()=>{const{t}=r();return p.jsx(o.SchemaComponent,{scope:{t},schema:{type:"object",properties:{transport:{"x-decorator":"FormItem",type:"string",title:'{{t("Transport")}}',"x-component":"Select",enum:[{value:"smtp",label:"SMTP"}],default:"smtp",required:!0},server:{type:"void","x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{col1:{type:"void","x-component":"Grid.Col","x-component-props":{width:50},properties:{host:{"x-decorator":"FormItem",type:"string",title:'{{t("Host")}}',description:'{{t("SMTP server host")}}',"x-component":"Input","x-component-props":{placeholder:"smtp.example.com"},required:!0}}},col2:{type:"void","x-component":"Grid.Col","x-component-props":{width:16},properties:{port:{"x-decorator":"FormItem",type:"number",title:'{{t("Port")}}',"x-component":"InputNumber","x-component-props":{min:1,max:65535,step:1},default:465,required:!0}}},col3:{type:"void","x-component":"Grid.Col","x-component-props":{width:16},properties:{secure:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Secure")}}',"x-component":"Checkbox",default:!0}}}}}}},auth:{type:"void","x-component":"Grid",properties:{row1:{type:"void","x-component":"Grid.Row",properties:{col1:{type:"void","x-component":"Grid.Col","x-component-props":{},properties:{account:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Account")}}',"x-component":"Input","x-component-props":{placeholder:"example@domain.com"},required:!0}}},col2:{type:"void","x-component":"Grid.Col","x-component-props":{},properties:{password:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Password")}}',"x-component":"Password",required:!0}}}}},row2:{type:"void","x-component":"Grid.Row",properties:{col1:{type:"void","x-component":"Grid.Col","x-component-props":{width:50,flex:"none"},properties:{from:{type:"string",required:!0,title:'{{t("From")}}',description:'{{t("The email address that will be used as the sender")}}',"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"noreply <example@domain.com>"}}}},col2:{type:"void","x-component":"Grid.Col","x-component-props":{width:50,flex:"none"}}}}}}}}})},x=o.css`
|
|
11
11
|
width: 100%;
|
|
12
12
|
|
|
13
13
|
.ant-space-item:nth-child(2) {
|
|
14
14
|
flex-grow: 1;
|
|
15
15
|
}
|
|
16
|
-
`,y=({variableOptions:
|
|
16
|
+
`,y=({variableOptions:t})=>{const{t:s}=r();return p.jsx(o.SchemaComponent,{scope:{t:s},schema:{type:"void",properties:{to:{type:"array",required:!0,title:'{{t("To")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"void","x-component":"Space","x-component-props":{className:x},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:t,useTypedConstant:["string"],placeholder:'{{t("Email address")}}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:'{{t("Add email address")}}',"x-component":"ArrayItems.Addition"}}},cc:{type:"array",title:'{{t("CC")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"void","x-component":"Space","x-component-props":{className:x},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:t,useTypedConstant:["string"],placeholder:'{{t("Email address")}}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:'{{t("Add email address")}}',"x-component":"ArrayItems.Addition"}}},bcc:{type:"array",title:'{{t("BCC")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"void","x-component":"Space","x-component-props":{className:x},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:t,useTypedConstant:["string"],placeholder:'{{t("Email address")}}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:'{{t("Add email address")}}',"x-component":"ArrayItems.Addition"}}},subject:{type:"string",required:!0,title:'{{t("Subject")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:t}},contentType:{type:"string",title:'{{t("Content type")}}',"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"HTML",value:"html"},{label:'{{t("Plain text")}}',value:"text"}],default:"html"},html:{type:"string",required:!0,title:'{{t("Content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:t,placeholder:"Hi,",autoSize:{minRows:10}},"x-reactions":[{dependencies:["contentType"],fulfill:{state:{visible:'{{$deps[0] === "html"}}'}}}]},text:{type:"string",required:!0,title:'{{t("Content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:t,placeholder:"Hi,",autoSize:{minRows:10}},"x-reactions":[{dependencies:["contentType"],fulfill:{state:{visible:'{{$deps[0] === "text"}}'}}}]}}}})},f=({variableOptions:t})=>{const{t:s}=r();return p.jsx(o.SchemaComponent,{scope:{t:s},schema:{type:"void",properties:{subject:{type:"string",required:!0,title:'{{t("Subject")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:t}},contentType:{type:"string",title:'{{t("Content type")}}',"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"HTML",value:"html"},{label:'{{t("Plain text")}}',value:"text"}],default:"html"},html:{type:"string",required:!0,title:'{{t("Content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:t,placeholder:"Hi,",autoSize:{minRows:10}},"x-reactions":[{dependencies:["contentType"],fulfill:{state:{visible:'{{$deps[0] === "html"}}'}}}]},text:{type:"string",required:!0,title:'{{t("Content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:t,placeholder:"Hi,",autoSize:{minRows:10}},"x-reactions":[{dependencies:["contentType"],fulfill:{state:{visible:'{{$deps[0] === "text"}}'}}}]}}}})};class u extends o.Plugin{afterAdd(){return a(this,null,function*(){})}beforeLoad(){return a(this,null,function*(){})}load(){return a(this,null,function*(){this.pm.get(n).registerChannelType({title:m.tval("Email",{ns:i}),type:l,components:{ChannelConfigForm:c,MessageConfigForm:y,ContentConfigForm:f}})})}}e.PluginNotificationMailClient=u,e.default=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.4.0-alpha.
|
|
11
|
+
"@nocobase/client": "1.4.0-alpha.20241027230531",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/plugin-notification-manager": "1.4.0-alpha.
|
|
14
|
-
"@nocobase/utils": "1.4.0-alpha.
|
|
15
|
-
"@nocobase/server": "1.4.0-alpha.
|
|
13
|
+
"@nocobase/plugin-notification-manager": "1.4.0-alpha.20241027230531",
|
|
14
|
+
"@nocobase/utils": "1.4.0-alpha.20241027230531",
|
|
15
|
+
"@nocobase/server": "1.4.0-alpha.20241027230531",
|
|
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":"2024-10-
|
|
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":"2024-10-27T23:20:39.209Z"}
|
|
@@ -44,8 +44,9 @@ var nodemailer = __toESM(require("nodemailer"));
|
|
|
44
44
|
class MailNotificationChannel extends import_plugin_notification_manager.BaseNotificationChannel {
|
|
45
45
|
transpoter;
|
|
46
46
|
async send(args) {
|
|
47
|
-
const { message, channel } = args;
|
|
47
|
+
const { message, channel, receivers } = args;
|
|
48
48
|
const { host, port, secure, account, password, from } = channel.options;
|
|
49
|
+
const userRepo = this.app.db.getRepository("users");
|
|
49
50
|
try {
|
|
50
51
|
const transpoter = nodemailer.createTransport({
|
|
51
52
|
host,
|
|
@@ -57,16 +58,32 @@ class MailNotificationChannel extends import_plugin_notification_manager.BaseNot
|
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
60
|
const { subject, cc, bcc, to, contentType } = message;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
if ((receivers == null ? void 0 : receivers.type) === "userId") {
|
|
62
|
+
const users = await userRepo.find({
|
|
63
|
+
filter: {
|
|
64
|
+
$in: receivers.value
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const usersEmail = users.map((user) => user.email).filter(Boolean);
|
|
68
|
+
const payload = {
|
|
69
|
+
to: usersEmail,
|
|
70
|
+
from,
|
|
71
|
+
...contentType === "html" ? { html: message.html } : { text: message.text }
|
|
72
|
+
};
|
|
73
|
+
const result = await transpoter.sendMail(payload);
|
|
74
|
+
return { status: "success", message };
|
|
75
|
+
} else {
|
|
76
|
+
const payload = {
|
|
77
|
+
to: to.map((item) => item == null ? void 0 : item.trim()).filter(Boolean),
|
|
78
|
+
cc: cc ? cc.flat().map((item) => item == null ? void 0 : item.trim()).filter(Boolean) : void 0,
|
|
79
|
+
bcc: bcc ? bcc.flat().map((item) => item == null ? void 0 : item.trim()).filter(Boolean) : void 0,
|
|
80
|
+
subject,
|
|
81
|
+
from,
|
|
82
|
+
...contentType === "html" ? { html: message.html } : { text: message.text }
|
|
83
|
+
};
|
|
84
|
+
const result = await transpoter.sendMail(payload);
|
|
85
|
+
return { status: "success", message };
|
|
86
|
+
}
|
|
70
87
|
} catch (error) {
|
|
71
88
|
throw { status: "failure", reason: error.message, message };
|
|
72
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-notification-email",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.20241027230531",
|
|
4
4
|
"displayName": "Notification: Email",
|
|
5
5
|
"displayName.zh-CN": "通知:电子邮件",
|
|
6
6
|
"description": "Used for sending email notifications with built-in SMTP transport.",
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"keywords": [
|
|
20
20
|
"Notification"
|
|
21
21
|
],
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "6f363bf299af23580d68c8b0659e4d31d70f4687"
|
|
23
23
|
}
|