@nocobase/plugin-notification-in-app-message 1.9.0-alpha.9 → 1.9.0-beta.10

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.
@@ -9,15 +9,15 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "1.9.0-alpha.9",
13
- "@nocobase/plugin-notification-manager": "1.9.0-alpha.9",
14
- "@nocobase/plugin-mobile": "1.9.0-alpha.9",
15
- "@nocobase/utils": "1.9.0-alpha.9",
12
+ "@nocobase/client": "1.9.0-beta.10",
13
+ "@nocobase/plugin-notification-manager": "1.9.0-beta.10",
14
+ "@nocobase/plugin-mobile": "1.9.0-beta.10",
15
+ "@nocobase/utils": "1.9.0-beta.10",
16
16
  "react-i18next": "11.18.6",
17
- "@nocobase/server": "1.9.0-alpha.9",
17
+ "@nocobase/server": "1.9.0-beta.10",
18
18
  "sequelize": "6.35.2",
19
- "@nocobase/actions": "1.9.0-alpha.9",
20
- "@nocobase/database": "1.9.0-alpha.9",
19
+ "@nocobase/actions": "1.9.0-beta.10",
20
+ "@nocobase/database": "1.9.0-beta.10",
21
21
  "antd": "5.24.2",
22
22
  "@formily/reactive-react": "2.3.0",
23
23
  "antd-style": "3.7.1",
@@ -26,7 +26,7 @@ module.exports = {
26
26
  "react-router-dom": "6.28.1",
27
27
  "@formily/core": "2.3.0",
28
28
  "@ant-design/icons": "5.6.1",
29
- "@nocobase/plugin-workflow": "1.9.0-alpha.9",
29
+ "@nocobase/plugin-workflow": "1.9.0-beta.10",
30
30
  "@formily/reactive": "2.3.0",
31
31
  "@formily/shared": "2.3.2"
32
32
  };
@@ -22,12 +22,14 @@
22
22
  "Plain text": "纯文本",
23
23
  "detail URL": "详情链接",
24
24
  "Details page for desktop": "桌面端详情页",
25
- "Support two types of links: internal links and external links. If using an internal link, the link starts with\"/\", for example, \"/admin\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "支持两种链接类型:内部链接和外部链接。如果使用内部链接,链接以“/”开头,例如“/admin”。如果使用外部链接,链接以“http”开头,例如“https://example.com”。",
25
+ "Support two types of links: internal links and external links. If using an internal link, the link starts with \"/\", for example, \"/admin\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "支持两种链接类型:内部链接和外部链接。如果使用内部链接,链接以“/”开头,例如“/admin”。如果使用外部链接,链接以“http”开头,例如“https://example.com”。",
26
26
  "Mark as read": "标为已读",
27
27
  "Mark as unread": "标为未读",
28
28
  "Mark all as read": "全部标为已读",
29
- "Support two types of links: internal links and external links. If using an internal link, the link starts with\"/\", for example, \"/m\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "支持两种链接类型:内部链接和外部链接。如果使用内部链接,链接以“/”开头,例如“/m”。如果使用外部链接,链接以“http”开头,例如“https://example.com”。",
29
+ "Support two types of links: internal links and external links. If using an internal link, the link starts with \"/\", for example, \"/m\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "支持两种链接类型:内部链接和外部链接。如果使用内部链接,链接以“/”开头,例如“/m”。如果使用外部链接,链接以“http”开头,例如“https://example.com”。",
30
30
  "Details page for mobile": "移动端详情页",
31
31
  "The message page has already been created.": "站内信页面已创建。",
32
- "When select receivers from node result, only support ID of user (or IDs array of users). Others will not match any user.": "从节点结果中选择接收者时,仅支持用户ID(或用户ID数组)。其他将不匹配任何用户。"
32
+ "When select receivers from node result, only support ID of user (or IDs array of users). Others will not match any user.": "从节点结果中选择接收者时,仅支持用户ID(或用户ID数组)。其他将不匹配任何用户。",
33
+ "Close after": "关闭延时",
34
+ "Unit is second. Will not close automatically when set to empty.": "单位为秒。设置为空则不自动关闭。"
33
35
  }
@@ -10,7 +10,8 @@ import { SendFnType, BaseNotificationChannel } from '@nocobase/plugin-notificati
10
10
  import { InAppMessageFormValues } from '../types';
11
11
  export default class InAppNotificationChannel extends BaseNotificationChannel {
12
12
  load(): Promise<void>;
13
- onMessageCreatedOrUpdated: (model: any, options: any) => Promise<void>;
13
+ onMessageCreated: (model: any, options: any) => Promise<void>;
14
+ onMessageUpdated: (model: any, options: any) => Promise<void>;
14
15
  saveMessageToDB: ({ content, status, userId, title, channelName, receiveTimestamp, options, }: {
15
16
  content: string;
16
17
  userId: number;
@@ -51,10 +51,22 @@ class InAppNotificationChannel extends import_plugin_notification_manager.BaseNo
51
51
  // this.userClientsMap = {};
52
52
  // }
53
53
  async load() {
54
- this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterSave`, this.onMessageCreatedOrUpdated);
54
+ this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterCreate`, this.onMessageCreated);
55
+ this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterUpdate`, this.onMessageUpdated);
55
56
  this.defineActions();
56
57
  }
57
- onMessageCreatedOrUpdated = async (model, options) => {
58
+ onMessageCreated = async (model, options) => {
59
+ const userId = model.userId;
60
+ this.app.emit("ws:sendToTag", {
61
+ tagKey: "userId",
62
+ tagValue: userId,
63
+ message: {
64
+ type: "in-app-message:created",
65
+ payload: model.toJSON()
66
+ }
67
+ });
68
+ };
69
+ onMessageUpdated = async (model, options) => {
58
70
  const userId = model.userId;
59
71
  this.app.emit("ws:sendToTag", {
60
72
  tagKey: "userId",
@@ -97,7 +97,6 @@ function defineMyInAppChannels(app) {
97
97
  const channelsRepo = app.db.getRepository(import_plugin_notification_manager.ChannelsCollectionDefinition.name);
98
98
  try {
99
99
  const channelsRes = channelsRepo.find({
100
- logging: console.log,
101
100
  limit,
102
101
  attributes: {
103
102
  include: [
@@ -52,7 +52,6 @@ function defineMyInAppMessages(app) {
52
52
  name: channelsCollection.getRealFieldName(import_plugin_notification_manager.ChannelsCollectionDefinition.fieldNameMap.name, true)
53
53
  };
54
54
  const count = await messagesRepo.count({
55
- logging: console.log,
56
55
  // @ts-ignore
57
56
  where: {
58
57
  userId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-notification-in-app-message",
3
- "version": "1.9.0-alpha.9",
3
+ "version": "1.9.0-beta.10",
4
4
  "displayName": "Notification: In-app message",
5
5
  "displayName.zh-CN": "通知:站内信",
6
6
  "description": "It supports users in receiving real-time message notifications within the NocoBase application.",
@@ -26,5 +26,5 @@
26
26
  "@nocobase/test": "1.x",
27
27
  "react-router-dom": "^6.x"
28
28
  },
29
- "gitHead": "b2527eb4d2543e211af1bbdc835740fc94338420"
29
+ "gitHead": "a4a5180d8e9b6bebe9df1a931c2c0f8b5c5d26e6"
30
30
  }