@rpcbase/server 0.352.0 → 0.353.0-notifications.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.352.0",
3
+ "version": "0.353.0-notifications.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "scripts": {
package/rts/index.js CHANGED
@@ -273,10 +273,7 @@ const run_query = async(mongoose, socket_id, {model_name, query, query_key, opti
273
273
 
274
274
  // log("initial run_query AUTH", ctx.req.session.user_id)
275
275
  if (!ctx.req.session.user_id) {
276
- // TODO: retry in node16! why is the throw not caught in try catch block
277
- // throw new Error("no user ID for client query")
278
- console.log("no user ID for client query")
279
- // TODO: this happens right after sign in, investigate
276
+ console.warn("no user ID for client query")
280
277
  s.emit("query_payload", {model_name, query_key, error: "error no user id"})
281
278
  return
282
279
  }
@@ -0,0 +1,44 @@
1
+ /* @flow */
2
+ const mongoose = require("../../mongoose")
3
+
4
+ const NOTIFICATIONS_TYPES = {
5
+ new_message: "new_message",
6
+ }
7
+
8
+ const NotificationSchema = new mongoose.Schema(
9
+ {
10
+ type: {
11
+ type: String,
12
+ enum: Object.keys(NOTIFICATIONS_TYPES),
13
+ },
14
+ notification: {
15
+ title: String,
16
+ body: String,
17
+ icon: String,
18
+ },
19
+ action_url: String,
20
+ ack_at_ms: {
21
+ type: Number,
22
+ default: null,
23
+ },
24
+ server_timestamp_ms: {
25
+ type: Number,
26
+ required: true,
27
+ },
28
+ context: mongoose.Schema.Types.Mixed,
29
+ push_sent: {
30
+ type: Array,
31
+ default: [],
32
+ },
33
+ },
34
+ {
35
+ strict: false,
36
+ versionKey: false,
37
+ },
38
+ )
39
+
40
+ const model = mongoose.model("Notification", NotificationSchema)
41
+
42
+ model.NOTIFICATIONS_TYPES = NOTIFICATIONS_TYPES
43
+
44
+ module.exports = model
@@ -1,5 +1,5 @@
1
- /* @flow */
2
1
  require("./Invite")
2
+ require("./Notification")
3
3
  require("./ResetPasswordToken")
4
4
  require("./User")
5
5
  require("./UserStoredValues")