@abtnode/blocklet-services 1.16.15-beta-89b542d3 → 1.16.15-beta-e143b1cf

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.
Files changed (2) hide show
  1. package/api/libs/email.js +15 -18
  2. package/package.json +18 -18
package/api/libs/email.js CHANGED
@@ -1,8 +1,7 @@
1
1
  const { Joi } = require('@arcblock/validator');
2
2
  const { render } = require('@react-email/components');
3
- const { getSafeEnv } = require('@abtnode/core/lib/util');
4
- const { getRuntimeEnvironments } = require('@abtnode/core/lib/util/blocklet');
5
3
  const { emailConfigSchema } = require('@blocklet/sdk/lib/validators/email');
4
+ const getBlockletInfo = require('@blocklet/meta/lib/info');
6
5
  const logger = require('@abtnode/logger')('blocklet-services:notification');
7
6
  const omit = require('lodash/omit');
8
7
 
@@ -26,35 +25,33 @@ async function sendEmail(receiver, notification, { teamDid, node, locale }) {
26
25
  if (!blocklet) {
27
26
  logger.warn(`Failed to get blocklet: ${teamDid}`);
28
27
  }
29
- const config = blocklet?.settings?.notification?.email || {};
28
+ const config = blocklet.settings?.notification?.email || {};
30
29
 
31
30
  if (!config.enabled) {
32
31
  // skip send email
33
32
  return;
34
33
  }
35
34
 
36
- const { error, value: emailConfig } = emailConfigSchema.validate(omit(config, 'enabled'));
35
+ const { error, value } = emailConfigSchema.validate(omit(config, 'enabled'));
37
36
  if (error) {
38
37
  throw new Error(error.message);
39
38
  }
40
39
 
41
- const nodeEnvironments = await node.states.node.getEnvironments();
42
- const env = getSafeEnv(getRuntimeEnvironments(blocklet, nodeEnvironments));
43
-
44
- const url = env?.BLOCKLET_APP_URL;
45
- // logo 采用顺序:横板 logo -> 正方形 logo -> blocklet.yml 指定的 logo
40
+ const info = getBlockletInfo(blocklet);
41
+ // logo 采用顺序:横板 logo -> 正方形 logo
46
42
  const logo =
47
- env?.BLOCKLET_APP_LOGO_RECT || env?.BLOCKLET_APP_LOGO_SQUARE || `${url}/.well-known/service/blocklet/logo/`;
43
+ blocklet.environmentObj?.BLOCKLET_APP_LOGO_RECT ||
44
+ `${info.appUrl}/.well-known/service/blocklet/logo?imageFilter=resize&h=80`;
48
45
 
49
46
  const appInfo = {
50
47
  logo,
51
- description: blocklet?.meta?.description,
52
- title: blocklet?.meta?.title || blocklet?.meta?.name,
53
- version: blocklet?.meta?.version,
54
- url,
48
+ description: info.description,
49
+ title: info.name,
50
+ version: info.version,
51
+ url: info.appUrl,
55
52
  };
56
53
 
57
- const subject = `[${appInfo.title}] ${
54
+ const subject = `${
58
55
  notification.title ||
59
56
  { zh: '您收到了一个通知', en: 'You have received a notification' }[locale] ||
60
57
  'You have received a notification'
@@ -69,14 +66,14 @@ async function sendEmail(receiver, notification, { teamDid, node, locale }) {
69
66
  })
70
67
  );
71
68
  const emailData = {
72
- from: emailConfig.user,
69
+ from: `"${info.name}" <${value.user}>`,
73
70
  to: receiver,
74
71
  title: notification.title,
75
72
  subject,
76
73
  html,
77
- replyTo: emailConfig.from,
74
+ replyTo: value.from,
78
75
  };
79
- const transporter = cache.getTransport({ did: teamDid, config: emailConfig });
76
+ const transporter = cache.getTransport({ did: teamDid, config: value });
80
77
  await transporter.sendMail(emailData);
81
78
  }
82
79
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.15-beta-89b542d3",
6
+ "version": "1.16.15-beta-e143b1cf",
7
7
  "description": "Provide unified services for every blocklet",
8
8
  "main": "api/index.js",
9
9
  "files": [
@@ -33,17 +33,17 @@
33
33
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
34
34
  "license": "Apache-2.0",
35
35
  "dependencies": {
36
- "@abtnode/analytics": "1.16.15-beta-89b542d3",
37
- "@abtnode/auth": "1.16.15-beta-89b542d3",
38
- "@abtnode/client": "1.16.15-beta-89b542d3",
39
- "@abtnode/connect-storage": "1.16.15-beta-89b542d3",
40
- "@abtnode/constant": "1.16.15-beta-89b542d3",
41
- "@abtnode/core": "1.16.15-beta-89b542d3",
42
- "@abtnode/cron": "1.16.15-beta-89b542d3",
43
- "@abtnode/logger": "1.16.15-beta-89b542d3",
44
- "@abtnode/models": "1.16.15-beta-89b542d3",
45
- "@abtnode/router-templates": "1.16.15-beta-89b542d3",
46
- "@abtnode/util": "1.16.15-beta-89b542d3",
36
+ "@abtnode/analytics": "1.16.15-beta-e143b1cf",
37
+ "@abtnode/auth": "1.16.15-beta-e143b1cf",
38
+ "@abtnode/client": "1.16.15-beta-e143b1cf",
39
+ "@abtnode/connect-storage": "1.16.15-beta-e143b1cf",
40
+ "@abtnode/constant": "1.16.15-beta-e143b1cf",
41
+ "@abtnode/core": "1.16.15-beta-e143b1cf",
42
+ "@abtnode/cron": "1.16.15-beta-e143b1cf",
43
+ "@abtnode/logger": "1.16.15-beta-e143b1cf",
44
+ "@abtnode/models": "1.16.15-beta-e143b1cf",
45
+ "@abtnode/router-templates": "1.16.15-beta-e143b1cf",
46
+ "@abtnode/util": "1.16.15-beta-e143b1cf",
47
47
  "@arcblock/did": "^1.18.89",
48
48
  "@arcblock/did-auth": "1.18.89",
49
49
  "@arcblock/did-ext": "^1.18.89",
@@ -52,11 +52,11 @@
52
52
  "@arcblock/jwt": "1.18.89",
53
53
  "@arcblock/validator": "^1.18.89",
54
54
  "@arcblock/ws": "1.18.89",
55
- "@blocklet/constant": "1.16.15-beta-89b542d3",
55
+ "@blocklet/constant": "1.16.15-beta-e143b1cf",
56
56
  "@blocklet/form-builder": "^0.1.11",
57
57
  "@blocklet/form-collector": "^0.1.6",
58
- "@blocklet/meta": "1.16.15-beta-89b542d3",
59
- "@blocklet/sdk": "1.16.15-beta-89b542d3",
58
+ "@blocklet/meta": "1.16.15-beta-e143b1cf",
59
+ "@blocklet/sdk": "1.16.15-beta-e143b1cf",
60
60
  "@did-connect/authenticator": "^2.2.0",
61
61
  "@did-connect/relay-adapter-express": "^2.2.0",
62
62
  "@did-connect/storage-nedb": "^2.2.0",
@@ -97,12 +97,12 @@
97
97
  "@nedb/core": "^2.1.2"
98
98
  },
99
99
  "devDependencies": {
100
- "@abtnode/ux": "1.16.15-beta-89b542d3",
100
+ "@abtnode/ux": "1.16.15-beta-e143b1cf",
101
101
  "@arcblock/did-connect": "^2.7.9",
102
102
  "@arcblock/icons": "^2.7.9",
103
103
  "@arcblock/ux": "^2.7.9",
104
104
  "@blocklet/launcher-layout": "2.1.101",
105
- "@blocklet/tracker": "1.16.15-beta-89b542d3",
105
+ "@blocklet/tracker": "1.16.15-beta-e143b1cf",
106
106
  "@blocklet/ui-react": "^2.7.9",
107
107
  "@emotion/react": "^11.10.4",
108
108
  "@emotion/styled": "^11.10.4",
@@ -173,5 +173,5 @@
173
173
  "url": "https://github.com/ArcBlock/blocklet-server/issues",
174
174
  "email": "shijun@arcblock.io"
175
175
  },
176
- "gitHead": "a5302e43c87e7f33a35b1293d7b55579cc36fcc8"
176
+ "gitHead": "86dcc908f3cb7259d1ca92b9ae75160a6e43509a"
177
177
  }