@nocobase/plugin-notification-in-app-message 1.8.14 → 1.8.16

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.8.14",
13
- "@nocobase/plugin-notification-manager": "1.8.14",
14
- "@nocobase/plugin-mobile": "1.8.14",
15
- "@nocobase/utils": "1.8.14",
12
+ "@nocobase/client": "1.8.16",
13
+ "@nocobase/plugin-notification-manager": "1.8.16",
14
+ "@nocobase/plugin-mobile": "1.8.16",
15
+ "@nocobase/utils": "1.8.16",
16
16
  "react-i18next": "11.18.6",
17
- "@nocobase/server": "1.8.14",
17
+ "@nocobase/server": "1.8.16",
18
18
  "sequelize": "6.35.2",
19
- "@nocobase/actions": "1.8.14",
20
- "@nocobase/database": "1.8.14",
19
+ "@nocobase/actions": "1.8.16",
20
+ "@nocobase/database": "1.8.16",
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.8.14",
29
+ "@nocobase/plugin-workflow": "1.8.16",
30
30
  "@formily/reactive": "2.3.0",
31
31
  "@formily/shared": "2.3.2"
32
32
  };
@@ -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.8.14",
3
+ "version": "1.8.16",
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": "16a9193a22b9a5c5ebb588727153583da8edb92e"
29
+ "gitHead": "3fc4fcf3f7205dece49356a4f1442c6707d509a1"
30
30
  }