@plusscommunities/pluss-core-aws 1.4.16-beta.0 → 1.4.19-beta.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.
|
@@ -21,14 +21,14 @@ const saveNotification = (receiver, notification) => {
|
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
module.exports = (
|
|
24
|
+
module.exports = async (
|
|
25
25
|
receivers,
|
|
26
26
|
type,
|
|
27
27
|
site,
|
|
28
28
|
id,
|
|
29
29
|
data,
|
|
30
30
|
sendPush,
|
|
31
|
-
config = { type: "app", id: null, ignoreMute: false }
|
|
31
|
+
config = { type: "app", id: null, ignoreMute: false, raiseError: false }
|
|
32
32
|
) => {
|
|
33
33
|
const notification = {};
|
|
34
34
|
notification.Timestamp = moment.utc().valueOf();
|
|
@@ -42,6 +42,13 @@ module.exports = (
|
|
|
42
42
|
});
|
|
43
43
|
if (sendPush) {
|
|
44
44
|
const notiData = prepNotification(notification);
|
|
45
|
-
sendNotifications(
|
|
45
|
+
await sendNotifications(
|
|
46
|
+
receivers,
|
|
47
|
+
notiData.Text,
|
|
48
|
+
type,
|
|
49
|
+
id,
|
|
50
|
+
notiData,
|
|
51
|
+
config
|
|
52
|
+
);
|
|
46
53
|
}
|
|
47
54
|
};
|
|
@@ -5,7 +5,7 @@ const getUser = require("../db/users/getUser");
|
|
|
5
5
|
const getNotificationSetting = require("../db/notifications/getNotificationSetting");
|
|
6
6
|
const { log } = require("../helper");
|
|
7
7
|
|
|
8
|
-
const SendNotification = (tokens, message, type, key, params, config) => {
|
|
8
|
+
const SendNotification = async (tokens, message, type, key, params, config) => {
|
|
9
9
|
const logId = log("SendNotification", "input", {
|
|
10
10
|
tokens,
|
|
11
11
|
message,
|
|
@@ -49,6 +49,7 @@ const SendNotification = (tokens, message, type, key, params, config) => {
|
|
|
49
49
|
`Push token ${token} is not a valid Expo push token`,
|
|
50
50
|
logId
|
|
51
51
|
);
|
|
52
|
+
if (config.raiseError) throw error;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -74,6 +75,7 @@ const SendNotification = (tokens, message, type, key, params, config) => {
|
|
|
74
75
|
});
|
|
75
76
|
} else {
|
|
76
77
|
log("SendNotification", "SendError", error, logId);
|
|
78
|
+
if (config.raiseError) throw error;
|
|
77
79
|
}
|
|
78
80
|
});
|
|
79
81
|
}
|
|
@@ -104,13 +106,13 @@ const checkMuted = async (userId, config) => {
|
|
|
104
106
|
return false;
|
|
105
107
|
};
|
|
106
108
|
|
|
107
|
-
module.exports = (
|
|
109
|
+
module.exports = async (
|
|
108
110
|
receiverKeys,
|
|
109
111
|
message,
|
|
110
112
|
type,
|
|
111
113
|
key,
|
|
112
114
|
value,
|
|
113
|
-
config = { type: "app", id: null, ignoreMute: false }
|
|
115
|
+
config = { type: "app", id: null, ignoreMute: false, raiseError: false }
|
|
114
116
|
) => {
|
|
115
117
|
const logId = log("sendNotifications", "input", {
|
|
116
118
|
receiverKeys,
|
|
@@ -142,6 +144,7 @@ module.exports = (
|
|
|
142
144
|
}
|
|
143
145
|
} catch (error) {
|
|
144
146
|
log("sendNotifications", "error", error.toString());
|
|
147
|
+
if (config.raiseError) reject(error);
|
|
145
148
|
}
|
|
146
149
|
resolve();
|
|
147
150
|
})
|
|
@@ -151,7 +154,6 @@ module.exports = (
|
|
|
151
154
|
})
|
|
152
155
|
);
|
|
153
156
|
});
|
|
154
|
-
Promise.all(promises)
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
+
await Promise.all(promises);
|
|
158
|
+
await SendNotification(tokens, message, type, key, value, config);
|
|
157
159
|
};
|
package/package.json
CHANGED