@optimiser/common 1.0.369 → 1.0.371
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/dist/lib/event.js +25 -16
- package/package.json +1 -1
package/dist/lib/event.js
CHANGED
|
@@ -76,11 +76,11 @@ var Event = /** @class */ (function () {
|
|
|
76
76
|
var _this = this;
|
|
77
77
|
return __generator(this, function (_a) {
|
|
78
78
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
79
|
-
var notificationDataObj, userObj, userDeviceInfoObj, message, response, error_1, uniqueID, params;
|
|
79
|
+
var notificationDataObj, userObj, userDeviceInfoObj, notificationCount, message, response, error_1, uniqueID, params;
|
|
80
80
|
return __generator(this, function (_a) {
|
|
81
81
|
switch (_a.label) {
|
|
82
82
|
case 0:
|
|
83
|
-
if (!(db && userId && data && data.PushNotificationObj && !data.PushNotificationObj["endpoint"])) return [3 /*break*/,
|
|
83
|
+
if (!(db && userId && data && data.PushNotificationObj && !data.PushNotificationObj["endpoint"])) return [3 /*break*/, 9];
|
|
84
84
|
notificationDataObj = data.PushNotificationObj;
|
|
85
85
|
return [4 /*yield*/, db.collection('UserNotification').findOne({ UserID: new mongodb_1.ObjectId(userId) })];
|
|
86
86
|
case 1:
|
|
@@ -93,12 +93,16 @@ var Event = /** @class */ (function () {
|
|
|
93
93
|
delete data.PushNotificationObj;
|
|
94
94
|
}
|
|
95
95
|
console.log("notificationDataObj Before calling fcm send--------", notificationDataObj);
|
|
96
|
-
if (!this.FCMMobileServiceAccountKey) return [3 /*break*/,
|
|
96
|
+
if (!this.FCMMobileServiceAccountKey) return [3 /*break*/, 8];
|
|
97
97
|
return [4 /*yield*/, db.collection('UserMobileNotification').findOne({ UserID: new mongodb_1.ObjectId(userId) })];
|
|
98
98
|
case 2:
|
|
99
99
|
userDeviceInfoObj = _a.sent();
|
|
100
100
|
console.log("userDeviceInfoObj", userDeviceInfoObj);
|
|
101
|
-
if (!(userDeviceInfoObj && userDeviceInfoObj.deviceToken && notificationDataObj)) return [3 /*break*/,
|
|
101
|
+
if (!(userDeviceInfoObj && userDeviceInfoObj.deviceToken && notificationDataObj)) return [3 /*break*/, 7];
|
|
102
|
+
return [4 /*yield*/, db.collection('Notification').countDocuments({ 'Users.UserID': new mongodb_1.ObjectId(userId), 'IsActive': true, "Users.IsNew": true })];
|
|
103
|
+
case 3:
|
|
104
|
+
notificationCount = _a.sent();
|
|
105
|
+
notificationDataObj['notificationCount'] = notificationCount;
|
|
102
106
|
message = {
|
|
103
107
|
token: userDeviceInfoObj.deviceToken,
|
|
104
108
|
notification: {
|
|
@@ -119,27 +123,32 @@ var Event = /** @class */ (function () {
|
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
125
|
},
|
|
122
|
-
data: JSON.stringify(notificationDataObj) // changes done by komal, to get data attr val in notification
|
|
126
|
+
data: { data: JSON.stringify(notificationDataObj) } // changes done by komal, to get data attr val in notification
|
|
123
127
|
};
|
|
128
|
+
//changes by sunny ,send background notifcation
|
|
129
|
+
if (notificationDataObj && (notificationDataObj === null || notificationDataObj === void 0 ? void 0 : notificationDataObj.isBackgroundPushnotification) == true) {
|
|
130
|
+
delete message.notification;
|
|
131
|
+
console.log("message.notification deleted");
|
|
132
|
+
}
|
|
124
133
|
console.log("FCM message payload------>", message);
|
|
125
134
|
console.log("notificationDataObj inside if condition------>", JSON.stringify(notificationDataObj));
|
|
126
|
-
_a.label =
|
|
127
|
-
case 3:
|
|
128
|
-
_a.trys.push([3, 5, , 6]);
|
|
129
|
-
return [4 /*yield*/, admin.messaging().send(message)];
|
|
135
|
+
_a.label = 4;
|
|
130
136
|
case 4:
|
|
137
|
+
_a.trys.push([4, 6, , 7]);
|
|
138
|
+
return [4 /*yield*/, admin.messaging().send(message)];
|
|
139
|
+
case 5:
|
|
131
140
|
response = _a.sent();
|
|
132
141
|
console.log('Successfully sent FCM notify(Mobile) message:', response);
|
|
133
|
-
return [3 /*break*/,
|
|
134
|
-
case
|
|
142
|
+
return [3 /*break*/, 7];
|
|
143
|
+
case 6:
|
|
135
144
|
error_1 = _a.sent();
|
|
136
145
|
console.log('ERROR WHILE sent FCM notify(Mobile) message:', error_1.stack);
|
|
137
|
-
return [3 /*break*/,
|
|
138
|
-
case
|
|
139
|
-
case 7:
|
|
140
|
-
console.log('Attention!!-- We are not sending mobile notifications due to lack of FIREBASE ADMIN APP configurations.\n Please provide firebaseSet-up.JSON file.');
|
|
141
|
-
_a.label = 8;
|
|
146
|
+
return [3 /*break*/, 7];
|
|
147
|
+
case 7: return [3 /*break*/, 9];
|
|
142
148
|
case 8:
|
|
149
|
+
console.log('Attention!!-- We are not sending mobile notifications due to lack of FIREBASE ADMIN APP configurations.\n Please provide firebaseSet-up.JSON file.');
|
|
150
|
+
_a.label = 9;
|
|
151
|
+
case 9:
|
|
143
152
|
// if (userId && data.SocketObj && !data.SocketObj.userId) {
|
|
144
153
|
//QPC-7064, Ankush changes added
|
|
145
154
|
if (userId && data.SocketObj && data.SocketObj.userId != userId) {
|