@live-change/notification-service 0.2.33 → 0.2.34
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/notification.js +49 -7
- package/package.json +2 -2
package/notification.js
CHANGED
|
@@ -68,11 +68,21 @@ definition.event({
|
|
|
68
68
|
definition.event({
|
|
69
69
|
name: "marked",
|
|
70
70
|
async execute({ notification, state }) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
await Notification.update(notification, { state })
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
definition.event({
|
|
76
|
+
name: "markedRead",
|
|
77
|
+
async execute({ notification }) {
|
|
78
|
+
await Notification.update(notification, { readState: 'read' })
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
definition.event({
|
|
83
|
+
name: "markedUnread",
|
|
84
|
+
async execute({ notification }) {
|
|
85
|
+
await Notification.update(notification, { readState: 'new' })
|
|
76
86
|
}
|
|
77
87
|
})
|
|
78
88
|
|
|
@@ -203,11 +213,11 @@ definition.trigger({
|
|
|
203
213
|
...config.fields
|
|
204
214
|
},
|
|
205
215
|
async execute(params , { service }, emit) {
|
|
206
|
-
const { sessionOrUserType, sessionOrUser } = params
|
|
216
|
+
const { sessionOrUserType, sessionOrUser, notificationType } = params
|
|
207
217
|
if(!sessionOrUserType || !sessionOrUser) throw new Error("session or user required")
|
|
208
218
|
const notification = app.generateUid()
|
|
209
219
|
const time = new Date()
|
|
210
|
-
let data = {}
|
|
220
|
+
let data = { notificationType }
|
|
211
221
|
for(const key in config.fields) data[key] = params[key]
|
|
212
222
|
emit({
|
|
213
223
|
type: "created",
|
|
@@ -252,6 +262,38 @@ definition.action({
|
|
|
252
262
|
}
|
|
253
263
|
})
|
|
254
264
|
|
|
265
|
+
definition.action({
|
|
266
|
+
name: "markRead",
|
|
267
|
+
properties: {
|
|
268
|
+
notification: {
|
|
269
|
+
type: Notification
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
access: notificationAccess,
|
|
273
|
+
async execute({notification, state}, {client, service}, emit) {
|
|
274
|
+
emit({
|
|
275
|
+
type: "markedRead",
|
|
276
|
+
notification
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
definition.action({
|
|
282
|
+
name: "markUnread",
|
|
283
|
+
properties: {
|
|
284
|
+
notification: {
|
|
285
|
+
type: Notification
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
access: notificationAccess,
|
|
289
|
+
async execute({notification, state}, {client, service}, emit) {
|
|
290
|
+
emit({
|
|
291
|
+
type: "markedUnread",
|
|
292
|
+
notification
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
|
|
255
297
|
definition.action({
|
|
256
298
|
name: "toggleReadStatus",
|
|
257
299
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/notification-service",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.34",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@live-change/framework": "0.6.5"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "45f52d6c7586d0eaa51b3205c6635a33e32eef6b"
|
|
27
27
|
}
|