playov2-js-utilities 0.3.1 → 0.3.5
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/notification-templates.js +30 -19
- package/lib/notification.config.js +12 -2
- package/lib/util.js +4 -1
- package/package.json +1 -1
|
@@ -39,10 +39,10 @@ const host_response_to_query = {
|
|
|
39
39
|
* @param {String} date - Activity's date
|
|
40
40
|
*/
|
|
41
41
|
const activity_join_request = {
|
|
42
|
-
heading: '
|
|
42
|
+
heading: 'New game request! 🙌',
|
|
43
43
|
text: '{{user_first_name}} has requested to join your {{sport_name}} game happening on {{date}}.',
|
|
44
44
|
additional_message_text: {
|
|
45
|
-
text: 'They have a message for you! Tap to read',
|
|
45
|
+
text: 'They have a message for you! Tap to read.',
|
|
46
46
|
default: 'Let them know if you\'re game.'
|
|
47
47
|
},
|
|
48
48
|
buttons: [],
|
|
@@ -58,7 +58,7 @@ const activity_join_request = {
|
|
|
58
58
|
* @param {String} date - Activity's date
|
|
59
59
|
*/
|
|
60
60
|
const activity_request_accepted = {
|
|
61
|
-
heading: '
|
|
61
|
+
heading: 'Request accepted! 🥳',
|
|
62
62
|
text: 'You\'re on for the {{sport_name}} game on {{date}}. You can now chat with your game squad.',
|
|
63
63
|
buttons: [],
|
|
64
64
|
notificationId: notificationIds.ACTIVITY_REQUEST_RESPONSE
|
|
@@ -73,11 +73,11 @@ const activity_request_accepted = {
|
|
|
73
73
|
* @param {String} date - Activity's date
|
|
74
74
|
*/
|
|
75
75
|
const activity_request_declined = {
|
|
76
|
-
heading: '
|
|
76
|
+
heading: 'Request declined. 😟',
|
|
77
77
|
text: '{{host_first_name}} declined your request to join the {{sport_name}} game on {{date}}.',
|
|
78
78
|
additional_message_text: {
|
|
79
|
-
text: 'They have a message for you! Tap to read',
|
|
80
|
-
default: 'No worries, other games are waiting for you
|
|
79
|
+
text: 'They have a message for you! Tap to read.',
|
|
80
|
+
default: 'No worries, other games are waiting for you! Join them now. 😀'
|
|
81
81
|
},
|
|
82
82
|
buttons: [],
|
|
83
83
|
notificationId: notificationIds.HOST_RETIRED
|
|
@@ -92,7 +92,7 @@ const activity_request_declined = {
|
|
|
92
92
|
* @param {String} date - Activity's date
|
|
93
93
|
*/
|
|
94
94
|
const user_invited_by_host = {
|
|
95
|
-
heading: '
|
|
95
|
+
heading: 'New game invite! 📩',
|
|
96
96
|
text: '{{host_first_name}} has invited you to the {{sport_name}} game on {{date}}. Are you game? 💪',
|
|
97
97
|
buttons: [],
|
|
98
98
|
notificationId: notificationIds.ACTIVITY_INVITATION
|
|
@@ -107,8 +107,8 @@ const user_invited_by_host = {
|
|
|
107
107
|
* @param {String} date - Activity's date
|
|
108
108
|
*/
|
|
109
109
|
const user_accepted_invite = {
|
|
110
|
-
heading: '
|
|
111
|
-
text: '{{user_first_name}} has accepted your
|
|
110
|
+
heading: 'Game invite accepted! 🤝',
|
|
111
|
+
text: '{{user_first_name}} has accepted your invite for the {{sport_name}} game on {{date}}.',
|
|
112
112
|
buttons: [],
|
|
113
113
|
notificationId: notificationIds.ACTIVITY_INVITATION_RESPONSE
|
|
114
114
|
};
|
|
@@ -122,11 +122,11 @@ const user_accepted_invite = {
|
|
|
122
122
|
* @param {String} date - Activity's date
|
|
123
123
|
*/
|
|
124
124
|
const user_declined_invite = {
|
|
125
|
-
heading: '
|
|
126
|
-
text: '{{user_first_name}} has declined your
|
|
125
|
+
heading: 'Game invite declined. 😟',
|
|
126
|
+
text: '{{user_first_name}} has declined your invite for the {{sport_name}} game on {{date}}.',
|
|
127
127
|
additional_message_text: {
|
|
128
|
-
text: 'They have a message for you! Tap to read',
|
|
129
|
-
default: ''
|
|
128
|
+
text: 'They have a message for you! Tap to read.',
|
|
129
|
+
default: 'Tap to invite other players.'
|
|
130
130
|
},
|
|
131
131
|
buttons: [],
|
|
132
132
|
notificationId: notificationIds.HOST_RETIRED
|
|
@@ -141,10 +141,10 @@ const user_declined_invite = {
|
|
|
141
141
|
* @param {String} date - Activity's date
|
|
142
142
|
*/
|
|
143
143
|
const host_revoked_invite = {
|
|
144
|
-
heading: '
|
|
144
|
+
heading: 'Game invite cancelled 😕',
|
|
145
145
|
text: '{{host_first_name}} has cancelled your invitation to the {{sport_name}} game on {{date}}.',
|
|
146
146
|
additional_message_text: {
|
|
147
|
-
text: 'They have a message for you! Tap to read',
|
|
147
|
+
text: 'They have a message for you! Tap to read.',
|
|
148
148
|
default: 'But, you can always join another game!'
|
|
149
149
|
},
|
|
150
150
|
buttons: [],
|
|
@@ -160,7 +160,7 @@ const host_revoked_invite = {
|
|
|
160
160
|
* @param {String} date - Activity's date
|
|
161
161
|
*/
|
|
162
162
|
const host_retired_user = {
|
|
163
|
-
heading: 'You have been made to retire
|
|
163
|
+
heading: 'You have been made to retire.😕',
|
|
164
164
|
text: 'You are no longer a part of {{sport_name}} game on {{date}}.',
|
|
165
165
|
additional_message_text: {
|
|
166
166
|
text: '{{host_first_name}} has a message for you! Tap to read',
|
|
@@ -182,8 +182,8 @@ const user_left_game = {
|
|
|
182
182
|
heading: 'Player has left the game.',
|
|
183
183
|
text: '{{user_first_name}} has left {{date}}\'s {{sport_name}} game.',
|
|
184
184
|
additional_message_text: {
|
|
185
|
-
text: '
|
|
186
|
-
default: ''
|
|
185
|
+
text: 'They have a message for you! Tap to read.',
|
|
186
|
+
default: 'Tap to invite other players.'
|
|
187
187
|
},
|
|
188
188
|
buttons: [],
|
|
189
189
|
notificationId: notificationIds.HOST_RETIRED
|
|
@@ -204,6 +204,16 @@ const host_cancelled_activity = {
|
|
|
204
204
|
notificationId: notificationIds.ACTIVITY_CANCEL
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
+
/**
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
const activity_reminder = {
|
|
211
|
+
heading: '⏰, Activity reminder!',
|
|
212
|
+
text: 'You have a {sport_name}} game coming up on {{date}}. Best of luck!',
|
|
213
|
+
buttons: [],
|
|
214
|
+
notificationId: notificationIds.ACTIVITY_REMINDER
|
|
215
|
+
};
|
|
216
|
+
|
|
207
217
|
const host_updated_activity_details = {
|
|
208
218
|
// ??
|
|
209
219
|
};
|
|
@@ -228,5 +238,6 @@ module.exports = {
|
|
|
228
238
|
host_revoked_invite,
|
|
229
239
|
host_retired_user,
|
|
230
240
|
user_left_game,
|
|
231
|
-
host_cancelled_activity
|
|
241
|
+
host_cancelled_activity,
|
|
242
|
+
activity_reminder
|
|
232
243
|
}
|
|
@@ -17,7 +17,8 @@ const notificationChannels = {
|
|
|
17
17
|
'activity_suggestions': '3ab98c37-b93c-4d39-ab55-bb2cc6279cb8', // done - 1 notifications tagged
|
|
18
18
|
'expenses': '1eb30f33-2b3b-40ce-8798-fce55c1275e2', // done - 6 notifications tagged
|
|
19
19
|
'groups_manage_requests': '83c024d1-2cb7-47fa-989d-1d8ef343a51c', // done - 6 notifications tagged
|
|
20
|
-
'group_updates': '9e023a20-deab-4bc4-bd33-08a8d9316322' // done - 3 notifications tagged
|
|
20
|
+
'group_updates': '9e023a20-deab-4bc4-bd33-08a8d9316322', // done - 3 notifications tagged
|
|
21
|
+
'activity_reminders': '53c55399-a73c-4800-b824-3c750ac57b98'
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
// ------------------------------------------ Exported (public) -----------------------------------------//
|
|
@@ -78,7 +79,8 @@ const notificationIds = {
|
|
|
78
79
|
SPLIT_EXPENSE_DELETED: 'split-expense-deleted',
|
|
79
80
|
HOST_ACTIVITY_PAYOUT: 'host-activity-payout',
|
|
80
81
|
KARMA_CASHBACK: 'karma-cashback',
|
|
81
|
-
ACTIVITY_QUERY_ANSWERED: 'activity-query-answered'
|
|
82
|
+
ACTIVITY_QUERY_ANSWERED: 'activity-query-answered',
|
|
83
|
+
ACTIVITY_REMINDER: 'activity-reminder'
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
// TODO - Check targets against current value
|
|
@@ -432,6 +434,14 @@ const config = {
|
|
|
432
434
|
type: ["push", "drawer"],
|
|
433
435
|
buttons: [],
|
|
434
436
|
android_channel_id: notificationChannels.activity_query
|
|
437
|
+
},
|
|
438
|
+
[notificationIds.ACTIVITY_REMINDER] : {
|
|
439
|
+
category: notificationCategories.ACTIVITY,
|
|
440
|
+
target: "match",
|
|
441
|
+
title: "Activity Reminder",
|
|
442
|
+
type: ["push", "drawer"],
|
|
443
|
+
buttons: [],
|
|
444
|
+
android_channel_id: notificationChannels.activity_reminders
|
|
435
445
|
}
|
|
436
446
|
};
|
|
437
447
|
|
package/lib/util.js
CHANGED
|
@@ -70,6 +70,9 @@ const getRecentRatingDictOfPals = (postActivityDocs) => {
|
|
|
70
70
|
// pals array contains ratings object as per given by other playpals for a particular activity, check schema for further details
|
|
71
71
|
const { pals = [] } = postActivityDoc;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Description for code below we are try to get a dictionary of latest non-zero rating the user has received to be processed later
|
|
75
|
+
*/
|
|
73
76
|
if (Array.isArray(pals)) {
|
|
74
77
|
pals.forEach((palRating) => {
|
|
75
78
|
const { palId = '', rating = 0, timestamp } = palRating;
|
|
@@ -78,7 +81,7 @@ const getRecentRatingDictOfPals = (postActivityDocs) => {
|
|
|
78
81
|
rating: rating,
|
|
79
82
|
timestamp: timestamp
|
|
80
83
|
}
|
|
81
|
-
} else if (palRatingDict[palId] && timestamp >= palRatingDict[palId]["timestamp"]) {
|
|
84
|
+
} else if (palRatingDict[palId] && timestamp >= palRatingDict[palId]["timestamp"] && rating > 0) {
|
|
82
85
|
// If user received any rating more recent then consider that instead
|
|
83
86
|
palRatingDict[palId]["rating"] = rating;
|
|
84
87
|
}
|