@optimiser/common 1.0.373 → 1.0.375

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 CHANGED
@@ -76,16 +76,15 @@ 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, notificationCount, message, response, error_1, uniqueID, params;
80
- var _a, _b;
81
- return __generator(this, function (_c) {
82
- switch (_c.label) {
79
+ var notificationDataObj, userObj, userDeviceInfoObj, message, response, error_1, uniqueID, params;
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
83
82
  case 0:
84
- if (!(db && userId && data && data.PushNotificationObj && !data.PushNotificationObj["endpoint"])) return [3 /*break*/, 9];
83
+ if (!(db && userId && data && data.PushNotificationObj && !data.PushNotificationObj["endpoint"])) return [3 /*break*/, 8];
85
84
  notificationDataObj = data.PushNotificationObj;
86
85
  return [4 /*yield*/, db.collection('UserNotification').findOne({ UserID: new mongodb_1.ObjectId(userId) })];
87
86
  case 1:
88
- userObj = _c.sent();
87
+ userObj = _a.sent();
89
88
  if (userObj && userObj.endpoint && userObj.keys && data.PushNotificationObj) {
90
89
  data.PushNotificationObj["endpoint"] = userObj.endpoint;
91
90
  data.PushNotificationObj["keys"] = userObj.keys;
@@ -94,34 +93,12 @@ var Event = /** @class */ (function () {
94
93
  delete data.PushNotificationObj;
95
94
  }
96
95
  console.log("notificationDataObj Before calling fcm send--------", notificationDataObj);
97
- if (!this.FCMMobileServiceAccountKey) return [3 /*break*/, 8];
96
+ if (!this.FCMMobileServiceAccountKey) return [3 /*break*/, 7];
98
97
  return [4 /*yield*/, db.collection('UserMobileNotification').findOne({ UserID: new mongodb_1.ObjectId(userId) })];
99
98
  case 2:
100
- userDeviceInfoObj = _c.sent();
99
+ userDeviceInfoObj = _a.sent();
101
100
  console.log("userDeviceInfoObj", userDeviceInfoObj);
102
- if (!(userDeviceInfoObj && userDeviceInfoObj.deviceToken && notificationDataObj)) return [3 /*break*/, 7];
103
- return [4 /*yield*/, db.collection('Notification').aggregate([{
104
- $match: {
105
- 'Users': { $elemMatch: { 'UserID': new mongodb_1.ObjectId(userId) } },
106
- 'IsActive': true
107
- }
108
- }, {
109
- $facet: {
110
- TotalUnseenNoti: [{
111
- $unwind: "$Users"
112
- }, {
113
- $match: { "Users.UserID": new mongodb_1.ObjectId(userId), "Users.IsNew": true }
114
- }, {
115
- $count: 'count'
116
- }]
117
- }
118
- }]).toArray()];
119
- case 3:
120
- notificationCount = _c.sent();
121
- if ((notificationDataObj === null || notificationDataObj === void 0 ? void 0 : notificationDataObj.isBackgroundPushnotification) != true) {
122
- console.log("notificationCount", (_a = notificationCount[0].TotalUnseenNoti[0]) === null || _a === void 0 ? void 0 : _a.count);
123
- notificationDataObj['notificationCount'] = (_b = notificationCount[0].TotalUnseenNoti[0]) === null || _b === void 0 ? void 0 : _b.count;
124
- }
101
+ if (!(userDeviceInfoObj && userDeviceInfoObj.deviceToken && notificationDataObj)) return [3 /*break*/, 6];
125
102
  message = {
126
103
  token: userDeviceInfoObj.deviceToken,
127
104
  notification: {
@@ -146,28 +123,28 @@ var Event = /** @class */ (function () {
146
123
  };
147
124
  //changes by sunny ,send background notifcation
148
125
  if (notificationDataObj && (notificationDataObj === null || notificationDataObj === void 0 ? void 0 : notificationDataObj.isBackgroundPushnotification) == true) {
149
- delete message.notification;
126
+ delete message.notification && delete message.android.notification; // added by komal, notifications under android has been deleted for backgorund notifications
150
127
  console.log("message.notification deleted");
151
128
  }
152
129
  console.log("FCM message payload------>", message);
153
130
  console.log("notificationDataObj inside if condition------>", JSON.stringify(notificationDataObj));
154
- _c.label = 4;
155
- case 4:
156
- _c.trys.push([4, 6, , 7]);
131
+ _a.label = 3;
132
+ case 3:
133
+ _a.trys.push([3, 5, , 6]);
157
134
  return [4 /*yield*/, admin.messaging().send(message)];
158
- case 5:
159
- response = _c.sent();
135
+ case 4:
136
+ response = _a.sent();
160
137
  console.log('Successfully sent FCM notify(Mobile) message:', response);
161
- return [3 /*break*/, 7];
162
- case 6:
163
- error_1 = _c.sent();
138
+ return [3 /*break*/, 6];
139
+ case 5:
140
+ error_1 = _a.sent();
164
141
  console.log('ERROR WHILE sent FCM notify(Mobile) message:', error_1.stack);
165
- return [3 /*break*/, 7];
166
- case 7: return [3 /*break*/, 9];
167
- case 8:
142
+ return [3 /*break*/, 6];
143
+ case 6: return [3 /*break*/, 8];
144
+ case 7:
168
145
  console.log('Attention!!-- We are not sending mobile notifications due to lack of FIREBASE ADMIN APP configurations.\n Please provide firebaseSet-up.JSON file.');
169
- _c.label = 9;
170
- case 9:
146
+ _a.label = 8;
147
+ case 8:
171
148
  // if (userId && data.SocketObj && !data.SocketObj.userId) {
172
149
  //QPC-7064, Ankush changes added
173
150
  if (userId && data.SocketObj && data.SocketObj.userId != userId) {
@@ -3351,11 +3351,11 @@ exports.ConvertJsonToXLXS = ConvertJsonToXLXS;
3351
3351
  function SendResetPasswordMail(db, userDetails, type) {
3352
3352
  if (type === void 0) { type = "newUser"; }
3353
3353
  return __awaiter(this, void 0, void 0, function () {
3354
- var Email, FirstName, Phone, LastName, Mobile, UserStatus, _id, companyId, CreatedBy, dbObj, hash, SetSessionObject, imagepath, mailObj;
3354
+ var Email, FirstName, Phone, LastName, Mobile, UserStatus, _id, companyId, CreatedBy, userName, dbObj, hash, SetSessionObject, imagepath, mailObj;
3355
3355
  return __generator(this, function (_a) {
3356
3356
  switch (_a.label) {
3357
3357
  case 0:
3358
- Email = userDetails.Email, FirstName = userDetails.FirstName, Phone = userDetails.Phone, LastName = userDetails.LastName, Mobile = userDetails.Mobile, UserStatus = userDetails.UserStatus, _id = userDetails._id, companyId = userDetails.companyId, CreatedBy = userDetails.CreatedBy;
3358
+ Email = userDetails.Email, FirstName = userDetails.FirstName, Phone = userDetails.Phone, LastName = userDetails.LastName, Mobile = userDetails.Mobile, UserStatus = userDetails.UserStatus, _id = userDetails._id, companyId = userDetails.companyId, CreatedBy = userDetails.CreatedBy, userName = userDetails.userName;
3359
3359
  dbObj = {
3360
3360
  FirstName: FirstName,
3361
3361
  Mobile: Mobile,
@@ -3386,7 +3386,7 @@ function SendResetPasswordMail(db, userDetails, type) {
3386
3386
  else {
3387
3387
  mailObj.subject = "Welcome to ".concat(constants_1.default.ProjectName, ": Please activate your account");
3388
3388
  //QPC-7971: called MailTemplateStructure for email body. and updated the link
3389
- mailObj.html = MailTemplateStructure("<p style=\"margin-top: 1em;\">Dear User,</p>\n <p>Congratulations! We are pleased to advise that your user profile has been created and is ready to use. Just click on the link below to set up your password then you\u2019ll be ready to go.</p>\n <br>\n <p style=\"word-break: break-all;\">\n <a href='".concat(constants_1.default.ProjectDomain, "?page=SetPassword&uid=").concat(hash, "'>").concat(constants_1.default.ProjectDomain, "?page=SetPassword&uid=").concat(hash, "</a>\n </p>\n <br>\n <p>We hope that you enjoy your Optimiser platform; if you ever require assistance, our Support Team will be happy to help.</p>\n <p>Email : <a href=\"mailto:support@optimiser.com\">support@optimiser.com</a>, Phone : +44 (0)203 972 1666</p>\n <br>"));
3389
+ mailObj.html = MailTemplateStructure("<p style=\"margin-top: 1em;\">Dear User,</p>\n <p>Congratulations! We are pleased to advise that your user profile has been created and is ready to use. Here's your unique Username: ".concat(userName, ". Just click on the link below to set up your password then you\u2019ll be ready to go.</p>\n <br>\n <p style=\"word-break: break-all;\">\n <a href='").concat(constants_1.default.ProjectDomain, "?page=SetPassword&uid=").concat(hash, "'>").concat(constants_1.default.ProjectDomain, "?page=SetPassword&uid=").concat(hash, "</a>\n </p>\n <br>\n <p>We hope that you enjoy your Optimiser platform; if you ever require assistance, our Support Team will be happy to help.</p>\n <p>Email : <a href=\"mailto:support@optimiser.com\">support@optimiser.com</a>, Phone : +44 (0)203 972 1666</p>\n <br>"));
3390
3390
  }
3391
3391
  return [2 /*return*/, new Promise(function (resolve, reject) {
3392
3392
  (0, mail_1.SendMail)(mailObj).then(function (status) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.373",
3
+ "version": "1.0.375",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {