@live-change/notification-service 0.2.33 → 0.2.37
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 -8
- 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
|
|
|
@@ -155,7 +165,6 @@ definition.view({
|
|
|
155
165
|
}
|
|
156
166
|
},
|
|
157
167
|
autoSlice: true,
|
|
158
|
-
access: (params, { client }) => !!client.user, // only for logged in
|
|
159
168
|
async daoPath(range, {client, service}, method) {
|
|
160
169
|
const prefix = client.user
|
|
161
170
|
? ["user_User", client.user]
|
|
@@ -203,11 +212,11 @@ definition.trigger({
|
|
|
203
212
|
...config.fields
|
|
204
213
|
},
|
|
205
214
|
async execute(params , { service }, emit) {
|
|
206
|
-
const { sessionOrUserType, sessionOrUser } = params
|
|
215
|
+
const { sessionOrUserType, sessionOrUser, notificationType } = params
|
|
207
216
|
if(!sessionOrUserType || !sessionOrUser) throw new Error("session or user required")
|
|
208
217
|
const notification = app.generateUid()
|
|
209
218
|
const time = new Date()
|
|
210
|
-
let data = {}
|
|
219
|
+
let data = { notificationType }
|
|
211
220
|
for(const key in config.fields) data[key] = params[key]
|
|
212
221
|
emit({
|
|
213
222
|
type: "created",
|
|
@@ -252,6 +261,38 @@ definition.action({
|
|
|
252
261
|
}
|
|
253
262
|
})
|
|
254
263
|
|
|
264
|
+
definition.action({
|
|
265
|
+
name: "markRead",
|
|
266
|
+
properties: {
|
|
267
|
+
notification: {
|
|
268
|
+
type: Notification
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
access: notificationAccess,
|
|
272
|
+
async execute({notification, state}, {client, service}, emit) {
|
|
273
|
+
emit({
|
|
274
|
+
type: "markedRead",
|
|
275
|
+
notification
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
definition.action({
|
|
281
|
+
name: "markUnread",
|
|
282
|
+
properties: {
|
|
283
|
+
notification: {
|
|
284
|
+
type: Notification
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
access: notificationAccess,
|
|
288
|
+
async execute({notification, state}, {client, service}, emit) {
|
|
289
|
+
emit({
|
|
290
|
+
type: "markedUnread",
|
|
291
|
+
notification
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
|
|
255
296
|
definition.action({
|
|
256
297
|
name: "toggleReadStatus",
|
|
257
298
|
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.37",
|
|
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": "f3bc615d20a0112c7cc76d55ba1cbefb53b84f01"
|
|
27
27
|
}
|