payment-kit 1.19.21 → 1.19.22

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.
@@ -208,7 +208,7 @@ export async function createMeteringSubscriptionDetection() {
208
208
  const context = await template.getContext();
209
209
  const notification = await template.getTemplate();
210
210
 
211
- await Notification.sendToUser(context.userDid, notification as any);
211
+ await Notification.sendToUser(context.userDid, notification as any, { allowUnsubscribe: false });
212
212
  logger.info('Metering subscription detection created', context);
213
213
  } catch (error) {
214
214
  logger.error('Failed to create metering subscription detection', error);
@@ -63,16 +63,18 @@ export async function sendNotification({
63
63
  message,
64
64
  actions,
65
65
  attachments = [],
66
+ allowUnsubscribe = false, // 是否允许用户取消订阅,如果为false,则用户无法取消订阅,用户总会收到邮件
66
67
  }: {
67
68
  to: string;
68
69
  title: string;
69
70
  message: string;
70
71
  actions: any[];
71
72
  attachments: any[];
73
+ allowUnsubscribe?: boolean;
72
74
  }) {
73
75
  try {
74
76
  const payload = { title, body: message, actions: actions || [], attachments: [...attachments] };
75
- await Notification.sendToUser(to, payload);
77
+ await Notification.sendToUser(to, payload, { allowUnsubscribe });
76
78
  logger.info('text message was sent', { to, payload: JSON.stringify(payload, null, 2) });
77
79
  } catch (error) {
78
80
  logger.error('send text message failed', { error, to, message, actions, attachments });
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
 
3
3
  import AuthStorage from '@arcblock/did-connect-storage-nedb';
4
- import AuthService from '@blocklet/sdk/lib/service/auth';
4
+ import AuthService from '@blocklet/sdk/service/auth';
5
5
  import getWallet from '@blocklet/sdk/lib/wallet';
6
6
  import WalletAuthenticator from '@blocklet/sdk/lib/wallet-authenticator';
7
7
  import WalletHandler from '@blocklet/sdk/lib/wallet-handler';
@@ -17,7 +17,7 @@ export class Notification {
17
17
  }
18
18
  }
19
19
 
20
- async send() {
20
+ async send(allowUnsubscribe: boolean = false) {
21
21
  const template: BaseEmailTemplateType | null = await this.template.getTemplate();
22
22
 
23
23
  if (!template) {
@@ -62,7 +62,8 @@ export class Notification {
62
62
  } catch (error) {
63
63
  logger.error('Check notification settings error', error);
64
64
  }
65
- await BlockletNotification.sendToUser(userDid, template as any);
65
+
66
+ await BlockletNotification.sendToUser(userDid, template as any, { allowUnsubscribe });
66
67
  }
67
68
  private async getEntityFromOptions(options: Record<string, any>) {
68
69
  if (options.subscriptionId) {
@@ -436,7 +436,7 @@ export async function getDidListByRole(role: string | string[]) {
436
436
  await Promise.all(
437
437
  role.map(async (r: string) => {
438
438
  const { users } = await blocklet.getUsers({ query: { role: r } });
439
- users.forEach((u) => didSet.add(u.did));
439
+ users.forEach((u: any) => didSet.add(u.did));
440
440
  })
441
441
  );
442
442
  return Array.from(didSet);
package/api/third.d.ts CHANGED
@@ -2,6 +2,8 @@ declare module 'vite-plugin-blocklet';
2
2
 
3
3
  declare module '@blocklet/sdk/service/notification';
4
4
 
5
+ declare module '@blocklet/sdk/service/auth';
6
+
5
7
  declare module 'express-history-api-fallback';
6
8
 
7
9
  declare module 'express-async-errors';
package/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.19.21
17
+ version: 1.19.22
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.19.21",
3
+ "version": "1.19.22",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
@@ -55,7 +55,7 @@
55
55
  "@blocklet/error": "^0.2.5",
56
56
  "@blocklet/js-sdk": "^1.16.48",
57
57
  "@blocklet/logger": "^1.16.48",
58
- "@blocklet/payment-react": "1.19.21",
58
+ "@blocklet/payment-react": "1.19.22",
59
59
  "@blocklet/sdk": "^1.16.48",
60
60
  "@blocklet/ui-react": "^3.1.32",
61
61
  "@blocklet/uploader": "^0.2.7",
@@ -124,7 +124,7 @@
124
124
  "devDependencies": {
125
125
  "@abtnode/types": "^1.16.48",
126
126
  "@arcblock/eslint-config-ts": "^0.3.3",
127
- "@blocklet/payment-types": "1.19.21",
127
+ "@blocklet/payment-types": "1.19.22",
128
128
  "@types/cookie-parser": "^1.4.9",
129
129
  "@types/cors": "^2.8.19",
130
130
  "@types/debug": "^4.1.12",
@@ -171,5 +171,5 @@
171
171
  "parser": "typescript"
172
172
  }
173
173
  },
174
- "gitHead": "66941895c869b90d0635b9d2a56593b2c85a3e3e"
174
+ "gitHead": "53d092fa1c88542b297c6333b810ba29751eef19"
175
175
  }