playov2-js-utilities 0.3.25 → 0.3.27
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/lib/logger.js +2 -2
- package/lib/middleware.js +4 -3
- package/lib/notification-templates.js +9 -1
- package/lib/notification.config.js +21 -6
- package/package.json +1 -1
package/lib/logger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const PLAYO_LOGGER = require("@playo/logger")
|
|
2
2
|
|
|
3
|
-
const LOGGER = new PLAYO_LOGGER("playov2-
|
|
3
|
+
const LOGGER = new PLAYO_LOGGER("playov2-js-utilities")
|
|
4
4
|
|
|
5
5
|
const ENV = process.env.NODE_ENV || 'staging';
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ if (ENV === 'staging' || ENV === 'test') {
|
|
|
10
10
|
|
|
11
11
|
if (ENV === "production") {
|
|
12
12
|
LOGGER.setMailer({
|
|
13
|
-
'receiverEmail': ["saurabh@playo.co", "
|
|
13
|
+
'receiverEmail': ["saurabh@playo.co", "avish@playo.co"], // array of recievers, mandatory
|
|
14
14
|
'senderEmail': "logger@playo.co",// address of sender, mandatory
|
|
15
15
|
'senderName': 'Mail Logger - prod - Utitlies module', // default: Mail Logger, optional
|
|
16
16
|
'replyEmail': 'no-reply@mail.com', // default: no-reply@playo.co, optional
|
package/lib/middleware.js
CHANGED
|
@@ -13,11 +13,12 @@ const playoServiceRequestInterceptor = (req, res, next, service = 'microservice-
|
|
|
13
13
|
Logger.prepareInfoLog(id, { userinfo: req.headers.userinfo }, "Malformed userInfo in headers detected");
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
const url = req.url;
|
|
16
17
|
const requestDetails = {
|
|
17
18
|
method: req.method,
|
|
18
19
|
params: req.params,
|
|
19
20
|
query: req.query,
|
|
20
|
-
url
|
|
21
|
+
url,
|
|
21
22
|
originalUrl: req.originalUrl,
|
|
22
23
|
service
|
|
23
24
|
};
|
|
@@ -30,13 +31,13 @@ const playoServiceRequestInterceptor = (req, res, next, service = 'microservice-
|
|
|
30
31
|
res.on('finish', function () {
|
|
31
32
|
const duration = Date.now() - start;
|
|
32
33
|
const status = res.statusCode;
|
|
33
|
-
Logger.prepareInfoLog(id, { status, duration, service, url
|
|
34
|
+
Logger.prepareInfoLog(id, { status, duration, service, url, userId }, "Outgoing request - finish event");
|
|
34
35
|
});
|
|
35
36
|
|
|
36
37
|
res.on('close', function () {
|
|
37
38
|
const duration = Date.now() - start;
|
|
38
39
|
const status = res.statusCode;
|
|
39
|
-
Logger.prepareInfoLog(id, { status, duration, service, url
|
|
40
|
+
Logger.prepareInfoLog(id, { status, duration, service, url, userId }, "Outgoing request - close event");
|
|
40
41
|
});
|
|
41
42
|
next();
|
|
42
43
|
};
|
|
@@ -230,6 +230,13 @@ const host_booked_venue = {
|
|
|
230
230
|
// ??
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
+
const dm_request = {
|
|
234
|
+
heading: 'Message request',
|
|
235
|
+
text: 'You have a new message request from ${{user_name}}. Tap to reply',
|
|
236
|
+
buttons: [],
|
|
237
|
+
notificationId: ''
|
|
238
|
+
}
|
|
239
|
+
|
|
233
240
|
module.exports = {
|
|
234
241
|
query_from_joinee,
|
|
235
242
|
host_response_to_query,
|
|
@@ -243,5 +250,6 @@ module.exports = {
|
|
|
243
250
|
host_retired_user,
|
|
244
251
|
user_left_game,
|
|
245
252
|
host_cancelled_activity,
|
|
246
|
-
activity_reminder
|
|
253
|
+
activity_reminder,
|
|
254
|
+
dm_request
|
|
247
255
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
//\-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- Private -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\//
|
|
3
|
+
// These categories correspond to notification preferences of the user
|
|
3
4
|
const notificationCategories = {
|
|
4
|
-
GROUP: 'group',
|
|
5
|
-
ACTIVITY: 'activity',
|
|
5
|
+
GROUP: 'group', // group updates
|
|
6
|
+
ACTIVITY: 'activity', // activity updates
|
|
6
7
|
KARMA: 'karma',
|
|
7
|
-
SPLIT_PAYMENTS: 'split_payments'
|
|
8
|
+
SPLIT_PAYMENTS: 'split_payments',
|
|
9
|
+
OFFERS: 'offers',
|
|
10
|
+
PLAYPAL_ACTIVITY: 'playpal-activity', // activity_suggestion_from_playpals
|
|
11
|
+
MESSAGE: 'message'
|
|
8
12
|
};
|
|
9
13
|
|
|
10
14
|
// Android notification channels will be bound to categories
|
|
@@ -49,7 +53,7 @@ const notificationIds = {
|
|
|
49
53
|
NEW_COMMENT: 'new-comment',
|
|
50
54
|
ACTIVITY_INVITATION: 'activity-invitation',
|
|
51
55
|
ACTIVITY_INVITATION_RESPONSE: 'activity-invitation-response',
|
|
52
|
-
ACTIVITY_REQUEST: 'activity-request',
|
|
56
|
+
ACTIVITY_REQUEST: 'activity-request', // deprecated - use ACTIVITY_REQUEST_MANAGE
|
|
53
57
|
ACTIVITY_REQUEST_RESPONSE: 'activity-request-response',
|
|
54
58
|
HOST_RETIRED: 'host-retired',
|
|
55
59
|
JOINEE_RETIRED: 'joinee-retired',
|
|
@@ -80,7 +84,8 @@ const notificationIds = {
|
|
|
80
84
|
HOST_ACTIVITY_PAYOUT: 'host-activity-payout',
|
|
81
85
|
KARMA_CASHBACK: 'karma-cashback',
|
|
82
86
|
ACTIVITY_QUERY_ANSWERED: 'activity-query-answered',
|
|
83
|
-
ACTIVITY_REMINDER: 'activity-reminder'
|
|
87
|
+
ACTIVITY_REMINDER: 'activity-reminder',
|
|
88
|
+
MESSAGE_REQUEST: 'message-request'
|
|
84
89
|
};
|
|
85
90
|
|
|
86
91
|
// TODO - Check targets against current value
|
|
@@ -291,7 +296,7 @@ const config = {
|
|
|
291
296
|
android_channel_id: notificationChannels.activity_updates
|
|
292
297
|
},
|
|
293
298
|
[notificationIds.ACTIVITY_HOSTED]: {
|
|
294
|
-
category:
|
|
299
|
+
category: notificationCategories.PLAYPAL_ACTIVITY,
|
|
295
300
|
target: "match",
|
|
296
301
|
title: "Activity Update",
|
|
297
302
|
type: ["push", "drawer"],
|
|
@@ -443,9 +448,19 @@ const config = {
|
|
|
443
448
|
type: ["push"],
|
|
444
449
|
buttons: [],
|
|
445
450
|
android_channel_id: notificationChannels.activity_reminders
|
|
451
|
+
},
|
|
452
|
+
[notificationIds.MESSAGE_REQUEST]: {
|
|
453
|
+
category: notificationCategories.MESSAGE,
|
|
454
|
+
target: "message",
|
|
455
|
+
title: "Message request",
|
|
456
|
+
type: ["push", "drawer"],
|
|
457
|
+
buttons: [],
|
|
458
|
+
android_channel_id: ''
|
|
446
459
|
}
|
|
447
460
|
};
|
|
448
461
|
|
|
462
|
+
// https://playo.co/${target}/${contentId}${queryUrl} //-> contentId - unique identifier id
|
|
463
|
+
|
|
449
464
|
const notificationButtons = {
|
|
450
465
|
[notificationIds.ACTIVITY_NOTIFY_PUSH]: []
|
|
451
466
|
};
|