@nocobase/plugin-notification-in-app-message 2.0.0-beta.8 → 2.0.0
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/dist/externalVersion.js
CHANGED
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
|
-
"@nocobase/client": "2.0.0
|
|
13
|
-
"@nocobase/plugin-notification-manager": "2.0.0
|
|
14
|
-
"@nocobase/plugin-mobile": "2.0.0
|
|
15
|
-
"@nocobase/utils": "2.0.0
|
|
12
|
+
"@nocobase/client": "2.0.0",
|
|
13
|
+
"@nocobase/plugin-notification-manager": "2.0.0",
|
|
14
|
+
"@nocobase/plugin-mobile": "2.0.0",
|
|
15
|
+
"@nocobase/utils": "2.0.0",
|
|
16
16
|
"react-i18next": "11.18.6",
|
|
17
|
-
"@nocobase/server": "2.0.0
|
|
17
|
+
"@nocobase/server": "2.0.0",
|
|
18
18
|
"sequelize": "6.35.2",
|
|
19
|
-
"@nocobase/actions": "2.0.0
|
|
20
|
-
"@nocobase/database": "2.0.0
|
|
19
|
+
"@nocobase/actions": "2.0.0",
|
|
20
|
+
"@nocobase/database": "2.0.0",
|
|
21
21
|
"antd": "5.24.2",
|
|
22
|
-
"@nocobase/flow-engine": "2.0.0
|
|
22
|
+
"@nocobase/flow-engine": "2.0.0",
|
|
23
23
|
"antd-style": "3.7.1",
|
|
24
24
|
"@emotion/css": "11.13.0",
|
|
25
25
|
"@formily/react": "2.3.7",
|
|
26
26
|
"react-router-dom": "6.30.1",
|
|
27
27
|
"@formily/core": "2.3.7",
|
|
28
28
|
"@ant-design/icons": "5.6.1",
|
|
29
|
-
"@nocobase/plugin-workflow": "2.0.0
|
|
29
|
+
"@nocobase/plugin-workflow": "2.0.0",
|
|
30
30
|
"@formily/reactive": "2.3.7",
|
|
31
31
|
"@formily/shared": "2.3.7"
|
|
32
32
|
};
|
|
@@ -12,15 +12,6 @@ export default class InAppNotificationChannel extends BaseNotificationChannel {
|
|
|
12
12
|
load(): Promise<void>;
|
|
13
13
|
onMessageCreated: (model: any, options: any) => Promise<void>;
|
|
14
14
|
onMessageUpdated: (model: any, options: any) => Promise<void>;
|
|
15
|
-
saveMessageToDB: ({ content, status, userId, title, channelName, receiveTimestamp, options, }: {
|
|
16
|
-
content: string;
|
|
17
|
-
userId: number;
|
|
18
|
-
title: string;
|
|
19
|
-
channelName: string;
|
|
20
|
-
status: 'read' | 'unread';
|
|
21
|
-
receiveTimestamp?: number;
|
|
22
|
-
options?: Record<string, any>;
|
|
23
|
-
}) => Promise<any>;
|
|
24
15
|
send: SendFnType<InAppMessageFormValues>;
|
|
25
16
|
defineActions(): void;
|
|
26
17
|
}
|
|
@@ -45,60 +45,38 @@ var import_parseUserSelectionConf = require("./parseUserSelectionConf");
|
|
|
45
45
|
var import_defineMyInAppMessages = __toESM(require("./defineMyInAppMessages"));
|
|
46
46
|
var import_defineMyInAppChannels = __toESM(require("./defineMyInAppChannels"));
|
|
47
47
|
class InAppNotificationChannel extends import_plugin_notification_manager.BaseNotificationChannel {
|
|
48
|
-
// userClientsMap: Record<UserID, Record<ClientID, PassThrough>>;
|
|
49
|
-
// constructor(protected app: Application) {
|
|
50
|
-
// super(app);
|
|
51
|
-
// this.userClientsMap = {};
|
|
52
|
-
// }
|
|
53
48
|
async load() {
|
|
54
49
|
this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterCreate`, this.onMessageCreated);
|
|
50
|
+
this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterBulkCreate`, this.onMessageCreated);
|
|
55
51
|
this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterUpdate`, this.onMessageUpdated);
|
|
52
|
+
this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterBulkUpdate`, this.onMessageUpdated);
|
|
56
53
|
this.defineActions();
|
|
57
54
|
}
|
|
58
55
|
onMessageCreated = async (model, options) => {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
const models = Array.isArray(model) ? model : [model];
|
|
57
|
+
for (const m of models) {
|
|
58
|
+
const userId = m.userId;
|
|
59
|
+
this.app.emit("ws:sendToUser", {
|
|
60
|
+
userId,
|
|
61
|
+
message: {
|
|
62
|
+
type: "in-app-message:created",
|
|
63
|
+
payload: m.toJSON()
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
68
67
|
};
|
|
69
68
|
onMessageUpdated = async (model, options) => {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
message: {
|
|
75
|
-
type: "in-app-message:updated",
|
|
76
|
-
payload: model.toJSON()
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
saveMessageToDB = async ({
|
|
81
|
-
content,
|
|
82
|
-
status,
|
|
83
|
-
userId,
|
|
84
|
-
title,
|
|
85
|
-
channelName,
|
|
86
|
-
receiveTimestamp,
|
|
87
|
-
options = {}
|
|
88
|
-
}) => {
|
|
89
|
-
const messagesRepo = this.app.db.getRepository(import_types2.InAppMessagesDefinition.name);
|
|
90
|
-
const message = await messagesRepo.create({
|
|
91
|
-
values: {
|
|
92
|
-
content,
|
|
93
|
-
title,
|
|
94
|
-
channelName,
|
|
95
|
-
status,
|
|
69
|
+
const models = Array.isArray(model) ? model : [model];
|
|
70
|
+
for (const m of models) {
|
|
71
|
+
const userId = m.userId;
|
|
72
|
+
this.app.emit("ws:sendToUser", {
|
|
96
73
|
userId,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
74
|
+
message: {
|
|
75
|
+
type: "in-app-message:updated",
|
|
76
|
+
payload: m.toJSON()
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
102
80
|
};
|
|
103
81
|
send = async (params) => {
|
|
104
82
|
const { channel, message, receivers } = params;
|
|
@@ -110,17 +88,17 @@ class InAppNotificationChannel extends import_plugin_notification_manager.BaseNo
|
|
|
110
88
|
} else {
|
|
111
89
|
userIds = (await (0, import_parseUserSelectionConf.parseUserSelectionConf)(message.receivers, userRepo)).map((i) => parseInt(i));
|
|
112
90
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
})
|
|
91
|
+
const MessageModel = this.app.db.getModel(import_types2.InAppMessagesDefinition.name);
|
|
92
|
+
await MessageModel.bulkCreate(
|
|
93
|
+
userIds.map((userId) => ({
|
|
94
|
+
title,
|
|
95
|
+
content,
|
|
96
|
+
status: "unread",
|
|
97
|
+
userId,
|
|
98
|
+
channelName: channel.name,
|
|
99
|
+
receiveTimestamp: Date.now(),
|
|
100
|
+
options
|
|
101
|
+
}))
|
|
124
102
|
);
|
|
125
103
|
return { status: "success", message };
|
|
126
104
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-notification-in-app-message",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"displayName": "Notification: In-app message",
|
|
5
5
|
"displayName.ru-RU": "Уведомления: Всплывающие сообщения внутри приложения",
|
|
6
6
|
"displayName.zh-CN": "通知:站内信",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"@nocobase/test": "2.x",
|
|
30
30
|
"react-router-dom": "^6.x"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "3590c0087a56f0f285a5357f43a80bdc62b11bec"
|
|
33
33
|
}
|