@abtnode/blocklet-services 1.16.8-beta-186fd5aa → 1.16.8-beta-81db8efa
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/api/emails/components/asset.js +3 -1
- package/api/emails/components/attachments.js +4 -4
- package/api/emails/components/content.js +2 -2
- package/api/emails/components/footer.js +3 -2
- package/api/emails/components/header.js +4 -2
- package/api/emails/components/layout.js +2 -2
- package/api/emails/components/token.js +3 -1
- package/api/emails/components/transaction.js +3 -1
- package/api/emails/libs/context.js +43 -0
- package/api/emails/libs/highlight.js +3 -3
- package/api/emails/pages/notification.js +8 -4
- package/api/emails/test.js +8 -8
- package/api/libs/email.js +6 -19
- package/api/services/studio/index.js +2 -12
- package/api/socket/channel/did.js +4 -8
- package/build/asset-manifest.json +7 -7
- package/build/index.html +1 -1
- package/build/static/js/{343.6fc2089d.chunk.js → 343.6b05b9c8.chunk.js} +2 -2
- package/build/static/js/460.3181ba2e.chunk.js +2 -0
- package/build/static/js/{main.94c49b7d.js → main.4c0f9347.js} +3 -3
- package/package.json +17 -17
- package/build/static/js/460.df719a3e.chunk.js +0 -2
- /package/build/static/js/{main.94c49b7d.js.LICENSE.txt → main.4c0f9347.js.LICENSE.txt} +0 -0
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const components_1 = require("@react-email/components");
|
|
5
|
-
|
|
5
|
+
const context_1 = require("../libs/context");
|
|
6
|
+
function Asset({ data, }) {
|
|
7
|
+
const { locale } = (0, context_1.useGlobalContext)();
|
|
6
8
|
const title = { zh: '接收', en: 'Received' }[locale] || 'Received';
|
|
7
9
|
return ((0, jsx_runtime_1.jsxs)(components_1.Section, Object.assign({ style: assetStyle }, { children: [(0, jsx_runtime_1.jsxs)(components_1.Row, Object.assign({ style: titleStyle }, { children: [(0, jsx_runtime_1.jsx)(components_1.Column, { children: title }), (0, jsx_runtime_1.jsxs)(components_1.Column, Object.assign({ align: "right", style: summaryStyle }, { children: ["+", data.amount || 1, " Asset"] }))] })), (0, jsx_runtime_1.jsx)(components_1.Text, Object.assign({ style: remarkStyle }, { children: data.address }))] })));
|
|
8
10
|
}
|
|
@@ -11,7 +11,7 @@ const compose_1 = __importDefault(require("./compose"));
|
|
|
11
11
|
const transaction_1 = __importDefault(require("./transaction"));
|
|
12
12
|
const dapp_1 = __importDefault(require("./dapp"));
|
|
13
13
|
const article_1 = __importDefault(require("./article"));
|
|
14
|
-
function Attachments({
|
|
14
|
+
function Attachments({ severity = 'normal', attachments = [], }) {
|
|
15
15
|
const attachmentList = attachments.map((item) => {
|
|
16
16
|
switch (item.type) {
|
|
17
17
|
case 'text':
|
|
@@ -22,9 +22,9 @@ function Attachments({ locale, severity = 'normal', attachments = [], }) {
|
|
|
22
22
|
case 'image':
|
|
23
23
|
return ((0, jsx_runtime_1.jsx)(components_1.Img, { src: item.data.url, alt: item.data.alt, style: { width: '100%', height: '150px', objectFit: 'contain', objectPosition: 'left center' } }));
|
|
24
24
|
case 'token':
|
|
25
|
-
return (0, jsx_runtime_1.jsx)(token_1.default, { data: item.data
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(token_1.default, { data: item.data });
|
|
26
26
|
case 'transaction':
|
|
27
|
-
return (0, jsx_runtime_1.jsx)(transaction_1.default, { data: item.data
|
|
27
|
+
return (0, jsx_runtime_1.jsx)(transaction_1.default, { data: item.data });
|
|
28
28
|
case 'dapp':
|
|
29
29
|
return (0, jsx_runtime_1.jsx)(dapp_1.default, { data: item.data });
|
|
30
30
|
case 'link':
|
|
@@ -33,7 +33,7 @@ function Attachments({ locale, severity = 'normal', attachments = [], }) {
|
|
|
33
33
|
return (0, jsx_runtime_1.jsx)(components_1.Hr, {});
|
|
34
34
|
// case 'vc':
|
|
35
35
|
case 'nft':
|
|
36
|
-
return (0, jsx_runtime_1.jsx)(asset_1.default, { data: { address: item.data.did }
|
|
36
|
+
return (0, jsx_runtime_1.jsx)(asset_1.default, { data: { address: item.data.did } });
|
|
37
37
|
case 'section':
|
|
38
38
|
return (0, jsx_runtime_1.jsx)(compose_1.default, { data: item.fileds });
|
|
39
39
|
default:
|
|
@@ -8,8 +8,8 @@ const components_1 = require("@react-email/components");
|
|
|
8
8
|
const attachments_1 = __importDefault(require("./attachments"));
|
|
9
9
|
const actions_1 = __importDefault(require("./actions"));
|
|
10
10
|
const highlight_1 = require("../libs/highlight");
|
|
11
|
-
function Content({ title, content, attachments = [], actions = [], style = {},
|
|
12
|
-
return ((0, jsx_runtime_1.jsxs)(components_1.Section, Object.assign({ style: style }, { children: [(0, jsx_runtime_1.jsx)(components_1.Heading, Object.assign({ style: h1 }, { children: title })), content && (0, jsx_runtime_1.jsx)(components_1.Text, {
|
|
11
|
+
function Content({ title, content, attachments = [], actions = [], style = {}, }) {
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.Section, Object.assign({ style: style }, { children: [(0, jsx_runtime_1.jsx)(components_1.Heading, Object.assign({ style: h1 }, { children: title })), content && (0, jsx_runtime_1.jsx)(components_1.Text, { children: (0, highlight_1.toClickableSpan)(content) }), (0, jsx_runtime_1.jsx)(attachments_1.default, { severity: "success", attachments: attachments }), (0, jsx_runtime_1.jsx)(actions_1.default, { actions: actions })] })));
|
|
13
13
|
}
|
|
14
14
|
exports.default = Content;
|
|
15
15
|
const h1 = {
|
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const components_1 = require("@react-email/components");
|
|
8
8
|
const copyright_1 = __importDefault(require("./copyright"));
|
|
9
|
-
|
|
9
|
+
const context_1 = require("../libs/context");
|
|
10
|
+
function Footer({ showLogo = false, showCopyright = false, showBlocklet = true, }) {
|
|
11
|
+
const { appInfo } = (0, context_1.useGlobalContext)();
|
|
10
12
|
return ((0, jsx_runtime_1.jsxs)(components_1.Section, { children: [showLogo && (0, jsx_runtime_1.jsx)(components_1.Img, { src: appInfo.logo, width: "32", height: "32", alt: appInfo.title }), showBlocklet && ((0, jsx_runtime_1.jsxs)(components_1.Text, Object.assign({ style: footer }, { children: [(0, jsx_runtime_1.jsx)(components_1.Link, Object.assign({ href: appInfo.url, target: "_blank", style: Object.assign(Object.assign({}, link), { color: '#898989' }) }, { children: appInfo.title })), (0, jsx_runtime_1.jsx)("br", {}), appInfo.description] }))), showCopyright && (0, jsx_runtime_1.jsx)(copyright_1.default, {})] }));
|
|
11
13
|
}
|
|
12
14
|
exports.default = Footer;
|
|
@@ -15,7 +17,6 @@ const footer = {
|
|
|
15
17
|
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
16
18
|
fontSize: '12px',
|
|
17
19
|
lineHeight: '22px',
|
|
18
|
-
margin: 0,
|
|
19
20
|
};
|
|
20
21
|
const link = {
|
|
21
22
|
color: '#2754C5',
|
|
@@ -13,8 +13,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
15
|
const components_1 = require("@react-email/components");
|
|
16
|
+
const context_1 = require("../libs/context");
|
|
16
17
|
function Header(_a) {
|
|
17
|
-
var
|
|
18
|
-
|
|
18
|
+
var props = __rest(_a, []);
|
|
19
|
+
const { appInfo } = (0, context_1.useGlobalContext)();
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(components_1.Section, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(components_1.Img, { src: appInfo.logo, height: "80", alt: appInfo.title }) })));
|
|
19
21
|
}
|
|
20
22
|
exports.default = Header;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const components_1 = require("@react-email/components");
|
|
5
|
-
function Layout({ children, mainStyle = {}, containerStyle = {},
|
|
6
|
-
return ((0, jsx_runtime_1.jsxs)(components_1.Html, { children: [(0, jsx_runtime_1.jsx)(components_1.Head, { children:
|
|
5
|
+
function Layout({ children, mainStyle = {}, containerStyle = {}, }) {
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.Html, { children: [(0, jsx_runtime_1.jsx)(components_1.Head, { children: (0, jsx_runtime_1.jsx)("title", { children: "My email title" }) }), (0, jsx_runtime_1.jsx)(components_1.Body, Object.assign({ style: Object.assign(Object.assign({}, main), mainStyle) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ style: Object.assign(Object.assign({}, main), mainStyle) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ style: { padding: '20px' } }, { children: (0, jsx_runtime_1.jsx)(components_1.Container, Object.assign({ style: Object.assign(Object.assign({}, container), containerStyle) }, { children: (0, jsx_runtime_1.jsx)("div", { children: children }) })) })) })) }))] }));
|
|
7
7
|
}
|
|
8
8
|
exports.default = Layout;
|
|
9
9
|
const main = {
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const components_1 = require("@react-email/components");
|
|
5
|
-
|
|
5
|
+
const context_1 = require("../libs/context");
|
|
6
|
+
function Token({ data, }) {
|
|
7
|
+
const { locale } = (0, context_1.useGlobalContext)();
|
|
6
8
|
const showAddress = data.address.slice(0, 4) + '...' + data.address.slice(-4);
|
|
7
9
|
const title = { zh: '接收', en: 'Received' }[locale] || 'Received';
|
|
8
10
|
return ((0, jsx_runtime_1.jsxs)(components_1.Section, Object.assign({ style: assetStyle }, { children: [(0, jsx_runtime_1.jsxs)(components_1.Row, Object.assign({ style: titleStyle }, { children: [(0, jsx_runtime_1.jsx)(components_1.Column, { children: title }), (0, jsx_runtime_1.jsxs)(components_1.Column, Object.assign({ align: "right", style: summaryStyle }, { children: ["+", data.amount, " ", data.symbol] }))] })), (0, jsx_runtime_1.jsxs)(components_1.Text, Object.assign({ style: remarkStyle }, { children: ["from ", showAddress] }))] })));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
|
|
4
|
+
const context_1 = require("../libs/context");
|
|
5
|
+
function Transaction({ data, }) {
|
|
5
6
|
const chainMap = {
|
|
6
7
|
beta: 'beta.abtnetwork.io',
|
|
7
8
|
main: 'main.abtnetwork.io',
|
|
@@ -9,6 +10,7 @@ function Transaction({ locale, data, }) {
|
|
|
9
10
|
const host = 'explorer.arcblockio.cn';
|
|
10
11
|
const chianHost = chainMap[data.chainId] || host;
|
|
11
12
|
const url = `https://${chianHost}/explorer/txs/${data.hash}`;
|
|
13
|
+
const { locale } = (0, context_1.useGlobalContext)();
|
|
12
14
|
const title = { zh: '交易详情', en: 'Transaction Details' }[locale] || 'Transaction Details';
|
|
13
15
|
const subTitle = { zh: '交易哈希', en: 'Transaction Hash' }[locale] || 'Transaction Hash';
|
|
14
16
|
return ((0, jsx_runtime_1.jsxs)("a", Object.assign({ href: url, target: "_blank", style: { margin: '1em 0', textDecoration: 'none', color: 'initial' } }, { children: [(0, jsx_runtime_1.jsx)("h6", Object.assign({ style: { color: '#a5a5a5', margin: 0 } }, { children: host })), (0, jsx_runtime_1.jsx)("p", Object.assign({ style: { color: '#4598fa', margin: '6px 0' } }, { children: title })), (0, jsx_runtime_1.jsxs)("div", { children: [subTitle, ": ", data.hash] })] })));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.useGlobalContext = exports.GlobalProvider = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const GlobalContext = React.createContext({
|
|
29
|
+
locale: 'en',
|
|
30
|
+
appInfo: {
|
|
31
|
+
version: '1.0.0',
|
|
32
|
+
title: 'ArcBlock',
|
|
33
|
+
description: 'ArcBlock DApp Platform',
|
|
34
|
+
url: 'https://www.arcblock.io',
|
|
35
|
+
logo: 'https://new.arcblock.io/blog/uploads/1671422131542-0dDNjXhEl_1yBIm8h7vC-Gnm.png',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const GlobalProvider = GlobalContext.Provider;
|
|
39
|
+
exports.GlobalProvider = GlobalProvider;
|
|
40
|
+
function useGlobalContext() {
|
|
41
|
+
return React.useContext(GlobalContext);
|
|
42
|
+
}
|
|
43
|
+
exports.useGlobalContext = useGlobalContext;
|
|
@@ -42,13 +42,13 @@ const toClickableSpan = (str, isHighLight = true) => {
|
|
|
42
42
|
}
|
|
43
43
|
// HACK: 邮件中无法支持 dapp 的展示,缺少 dapp 链接,只能作为加粗展示
|
|
44
44
|
if ((0, func_1.isSameAddr)(type, 'dapp')) {
|
|
45
|
-
return `<em
|
|
45
|
+
return `<em data-type="${type}" data-chain-id="${chainId}" data-did="${did}">${item.text}</em>`;
|
|
46
46
|
}
|
|
47
47
|
if (url) {
|
|
48
|
-
return `<a target="_blank"
|
|
48
|
+
return `<a target="_blank" href="${url}">${item.text}</a>`;
|
|
49
49
|
}
|
|
50
50
|
// 默认展示为加粗
|
|
51
|
-
return `<em
|
|
51
|
+
return `<em data-type="${type}" data-chain-id="${chainId}" data-did="${did}">${item.text}</em>`;
|
|
52
52
|
}
|
|
53
53
|
return item.text;
|
|
54
54
|
}
|
|
@@ -10,8 +10,12 @@ const footer_1 = __importDefault(require("../components/footer"));
|
|
|
10
10
|
const content_1 = __importDefault(require("../components/content"));
|
|
11
11
|
const layout_1 = __importDefault(require("../components/layout"));
|
|
12
12
|
const header_1 = __importDefault(require("../components/header"));
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const context_1 = require("../libs/context");
|
|
14
|
+
const NotificationEmail = ({ title, body = '', attachments = [], actions = [], appInfo, locale = 'en', }) => {
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(context_1.GlobalProvider, Object.assign({ value: {
|
|
16
|
+
appInfo,
|
|
17
|
+
locale,
|
|
18
|
+
} }, { children: (0, jsx_runtime_1.jsxs)(layout_1.default, Object.assign({ mainStyle: main }, { children: [(0, jsx_runtime_1.jsx)(components_1.Preview, { children: title }), (0, jsx_runtime_1.jsx)(header_1.default, {}), (0, jsx_runtime_1.jsx)(content_1.default, { style: container, title: title, content: body, attachments: attachments, actions: actions }), (0, jsx_runtime_1.jsx)(footer_1.default, { showCopyright: false, showBlocklet: true })] })) })));
|
|
15
19
|
};
|
|
16
20
|
exports.NotificationEmail = NotificationEmail;
|
|
17
21
|
exports.default = exports.NotificationEmail;
|
|
@@ -20,7 +24,7 @@ const main = {
|
|
|
20
24
|
fontFamily,
|
|
21
25
|
};
|
|
22
26
|
const container = {
|
|
23
|
-
margin: '
|
|
27
|
+
margin: '30px auto',
|
|
24
28
|
backgroundColor: '#ffffff',
|
|
25
|
-
padding: '5px 50px
|
|
29
|
+
padding: '5px 50px 10px 60px',
|
|
26
30
|
};
|
package/api/emails/test.js
CHANGED
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const notification_1 = __importDefault(require("./pages/notification"));
|
|
8
8
|
function Test() {
|
|
9
|
-
const title = '
|
|
10
|
-
const body = '
|
|
9
|
+
const title = 'Blocklet Server is about to expire';
|
|
10
|
+
const body = 'Your Blocklet Server ArcBlock Blog(zNKjA8gAQStdSwW2xz9ARdabz3TZgb6nne4G) will expire after 23h 59m 59.8s (i.e.2023-04-17T00:00:00Z). Data will be retained for 7 days after the instance expires. Please click on the Renew button to renew.';
|
|
11
11
|
const attachments = [
|
|
12
12
|
{
|
|
13
13
|
type: 'token',
|
|
14
14
|
data: {
|
|
15
|
-
address: '
|
|
15
|
+
address: 'abcdefghjikl',
|
|
16
16
|
decimal: 18,
|
|
17
17
|
amount: 10000,
|
|
18
18
|
chianHost: 'beta',
|
|
@@ -23,7 +23,7 @@ function Test() {
|
|
|
23
23
|
type: 'nft',
|
|
24
24
|
data: {
|
|
25
25
|
chianHost: 'beta',
|
|
26
|
-
did: '
|
|
26
|
+
did: 'abcdefghijkl',
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
// {
|
|
@@ -155,12 +155,12 @@ function Test() {
|
|
|
155
155
|
},
|
|
156
156
|
];
|
|
157
157
|
const appInfo = {
|
|
158
|
-
title: 'Blocklet Email
|
|
159
|
-
logo: 'https://picsum.photos/200
|
|
158
|
+
title: 'Blocklet Email Test',
|
|
159
|
+
logo: 'https://picsum.photos/100/200',
|
|
160
160
|
url: 'https://www.arcblock.io',
|
|
161
|
-
description: 'This is a
|
|
161
|
+
description: 'This is a test blocklet for email test only',
|
|
162
162
|
version: '1.0.0',
|
|
163
163
|
};
|
|
164
|
-
return (
|
|
164
|
+
return (0, jsx_runtime_1.jsx)(notification_1.default, { title: title, body: body, attachments: attachments, actions: actions, appInfo: appInfo });
|
|
165
165
|
}
|
|
166
166
|
exports.default = Test;
|
package/api/libs/email.js
CHANGED
|
@@ -3,8 +3,6 @@ const { render } = require('@react-email/components');
|
|
|
3
3
|
const { getSafeEnv } = require('@abtnode/core/lib/util');
|
|
4
4
|
const { getRuntimeEnvironments } = require('@abtnode/core/lib/util/blocklet');
|
|
5
5
|
const { emailConfigSchema } = require('@blocklet/sdk/lib/validators/email');
|
|
6
|
-
const logger = require('@abtnode/logger')('blocklet-services:notification');
|
|
7
|
-
const omit = require('lodash/omit');
|
|
8
6
|
|
|
9
7
|
const { NotificationEmail } = require('../emails/pages/notification');
|
|
10
8
|
const cache = require('../cache');
|
|
@@ -22,18 +20,16 @@ async function sendEmail(receiver, notification, { teamDid, node }) {
|
|
|
22
20
|
throw new Error('notification is required');
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
const blocklet = await node.getBlocklet({ did: teamDid,
|
|
26
|
-
|
|
27
|
-
logger.warn(`Failed to get blocklet: ${teamDid}`);
|
|
28
|
-
}
|
|
29
|
-
const config = blocklet?.settings?.notification?.email || {};
|
|
23
|
+
const blocklet = await node.getBlocklet({ did: teamDid, attachRuntimeInfo: false });
|
|
24
|
+
const config = blocklet.settings?.notification?.email || {};
|
|
30
25
|
|
|
31
26
|
if (!config.enabled) {
|
|
32
27
|
// skip send email
|
|
33
28
|
return;
|
|
34
29
|
}
|
|
30
|
+
delete config.enabled;
|
|
35
31
|
|
|
36
|
-
const { error, value: emailConfig } = emailConfigSchema.validate(
|
|
32
|
+
const { error, value: emailConfig } = emailConfigSchema.validate(config);
|
|
37
33
|
if (error) {
|
|
38
34
|
throw new Error(error.message);
|
|
39
35
|
}
|
|
@@ -54,21 +50,12 @@ async function sendEmail(receiver, notification, { teamDid, node }) {
|
|
|
54
50
|
url,
|
|
55
51
|
};
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
const subject = `[${appInfo.title}] ${notification.title || 'You have received a notification'}`;
|
|
59
|
-
|
|
60
|
-
const html = render(
|
|
61
|
-
NotificationEmail({
|
|
62
|
-
subject,
|
|
63
|
-
...notification,
|
|
64
|
-
appInfo,
|
|
65
|
-
})
|
|
66
|
-
);
|
|
53
|
+
const html = render(NotificationEmail({ ...notification, appInfo }));
|
|
67
54
|
const emailData = {
|
|
68
55
|
from: emailConfig.from,
|
|
69
56
|
to: receiver,
|
|
70
57
|
title: notification.title,
|
|
71
|
-
subject,
|
|
58
|
+
subject: notification.title,
|
|
72
59
|
html,
|
|
73
60
|
};
|
|
74
61
|
const transporter = cache.getTransport({ did: teamDid, config: emailConfig });
|
|
@@ -22,12 +22,7 @@ module.exports = {
|
|
|
22
22
|
return res.status(400).json({ error: 'Blocklet Studio can only be used for blocklets in development mode' });
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
if (!component || !component.deployedFrom) {
|
|
27
|
-
return res.status(400).json({ error: 'Can not find current component' });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const schemaFile = path.join(component.deployedFrom, BLOCKLET_PREFERENCE_FILE);
|
|
25
|
+
const schemaFile = path.join(blocklet.env.appDir, BLOCKLET_PREFERENCE_FILE);
|
|
31
26
|
if (fs.existsSync(schemaFile)) {
|
|
32
27
|
try {
|
|
33
28
|
const schema = JSON.parse(fs.readFileSync(schemaFile, 'utf8'));
|
|
@@ -46,12 +41,7 @@ module.exports = {
|
|
|
46
41
|
return res.status(400).json({ error: 'Blocklet Studio can only be used for blocklets in development mode' });
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
const
|
|
50
|
-
if (!component || !component.deployedFrom) {
|
|
51
|
-
return res.status(400).json({ error: 'Can not find current component' });
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const schemaFile = path.join(component.deployedFrom, BLOCKLET_PREFERENCE_FILE);
|
|
44
|
+
const schemaFile = path.join(blocklet.env.appDir, BLOCKLET_PREFERENCE_FILE);
|
|
55
45
|
fs.writeFileSync(schemaFile, JSON.stringify(req.body, null, 2));
|
|
56
46
|
return res.json(req.body);
|
|
57
47
|
});
|
|
@@ -2,7 +2,6 @@ const {
|
|
|
2
2
|
validateReceiver,
|
|
3
3
|
validateNotification,
|
|
4
4
|
validateMessage,
|
|
5
|
-
NOTIFICATION_TYPES,
|
|
6
5
|
} = require('@blocklet/sdk/lib/validators/notification');
|
|
7
6
|
const { NODE_MODES } = require('@abtnode/constant');
|
|
8
7
|
const { getWalletDid } = require('@blocklet/sdk/lib/did');
|
|
@@ -91,13 +90,10 @@ const sendToDid = async ({ sender, receiver: rawDid, notification, options, node
|
|
|
91
90
|
}
|
|
92
91
|
});
|
|
93
92
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
logger.error('Failed to send email', { error });
|
|
99
|
-
});
|
|
100
|
-
}
|
|
93
|
+
for (const receiverEmail of receiverEmailList) {
|
|
94
|
+
sendEmail(receiverEmail, data, { teamDid: sender.appDid, node }).catch((error) => {
|
|
95
|
+
logger.error('Failed to send email', { error });
|
|
96
|
+
});
|
|
101
97
|
}
|
|
102
98
|
});
|
|
103
99
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/.blocklet/proxy/blocklet-service/static/css/main.632501d5.css",
|
|
4
|
-
"main.js": "/.blocklet/proxy/blocklet-service/static/js/main.
|
|
4
|
+
"main.js": "/.blocklet/proxy/blocklet-service/static/js/main.4c0f9347.js",
|
|
5
5
|
"static/js/716.0d2a2d32.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/716.0d2a2d32.chunk.js",
|
|
6
6
|
"static/js/359.c47779c2.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/359.c47779c2.chunk.js",
|
|
7
7
|
"static/js/255.279b1bca.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/255.279b1bca.chunk.js",
|
|
8
8
|
"static/js/371.f67a06b4.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/371.f67a06b4.chunk.js",
|
|
9
9
|
"static/js/737.15a41e1c.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/737.15a41e1c.chunk.js",
|
|
10
|
-
"static/js/460.
|
|
10
|
+
"static/js/460.3181ba2e.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/460.3181ba2e.chunk.js",
|
|
11
11
|
"static/js/868.ac8df3a0.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/868.ac8df3a0.chunk.js",
|
|
12
12
|
"static/js/547.03d5d719.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/547.03d5d719.chunk.js",
|
|
13
|
-
"static/js/343.
|
|
13
|
+
"static/js/343.6b05b9c8.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/343.6b05b9c8.chunk.js",
|
|
14
14
|
"static/js/682.a8bf723a.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/682.a8bf723a.chunk.js",
|
|
15
15
|
"static/js/711.56427a24.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/711.56427a24.chunk.js",
|
|
16
16
|
"static/js/437.075e8453.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/437.075e8453.chunk.js",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"router-template-styles/styles.css": "/.blocklet/proxy/blocklet-service/router-template-styles/styles.css",
|
|
46
46
|
"index.html": "/.blocklet/proxy/blocklet-service/index.html",
|
|
47
47
|
"main.632501d5.css.map": "/.blocklet/proxy/blocklet-service/static/css/main.632501d5.css.map",
|
|
48
|
-
"main.
|
|
48
|
+
"main.4c0f9347.js.map": "/.blocklet/proxy/blocklet-service/static/js/main.4c0f9347.js.map",
|
|
49
49
|
"716.0d2a2d32.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/716.0d2a2d32.chunk.js.map",
|
|
50
50
|
"359.c47779c2.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/359.c47779c2.chunk.js.map",
|
|
51
51
|
"255.279b1bca.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/255.279b1bca.chunk.js.map",
|
|
52
52
|
"371.f67a06b4.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/371.f67a06b4.chunk.js.map",
|
|
53
53
|
"737.15a41e1c.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/737.15a41e1c.chunk.js.map",
|
|
54
|
-
"460.
|
|
54
|
+
"460.3181ba2e.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/460.3181ba2e.chunk.js.map",
|
|
55
55
|
"868.ac8df3a0.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/868.ac8df3a0.chunk.js.map",
|
|
56
56
|
"547.03d5d719.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/547.03d5d719.chunk.js.map",
|
|
57
|
-
"343.
|
|
57
|
+
"343.6b05b9c8.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/343.6b05b9c8.chunk.js.map",
|
|
58
58
|
"682.a8bf723a.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/682.a8bf723a.chunk.js.map",
|
|
59
59
|
"711.56427a24.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/711.56427a24.chunk.js.map",
|
|
60
60
|
"437.075e8453.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/437.075e8453.chunk.js.map",
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
},
|
|
71
71
|
"entrypoints": [
|
|
72
72
|
"static/css/main.632501d5.css",
|
|
73
|
-
"static/js/main.
|
|
73
|
+
"static/js/main.4c0f9347.js"
|
|
74
74
|
]
|
|
75
75
|
}
|
package/build/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/><meta name="theme-color" content="#000000"/><title>Blocklet Service</title><script src=".well-known/service/api/env"></script><script src="/__blocklet__.js"></script><script defer="defer" src="/.blocklet/proxy/blocklet-service/static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/><meta name="theme-color" content="#000000"/><title>Blocklet Service</title><script src=".well-known/service/api/env"></script><script src="/__blocklet__.js"></script><script defer="defer" src="/.blocklet/proxy/blocklet-service/static/js/main.4c0f9347.js"></script><link href="/.blocklet/proxy/blocklet-service/static/css/main.632501d5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|