@optimiser/common 1.0.318 → 1.0.319
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/utility.js +33 -37
- package/package.json +1 -1
package/dist/lib/utility.js
CHANGED
|
@@ -194,7 +194,7 @@ exports.CheckUserProfileField = CheckUserProfileField;
|
|
|
194
194
|
function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
195
195
|
db.collection("Page").findOne({ 'PageName': pageName }, function (err, pageData) {
|
|
196
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
-
var
|
|
197
|
+
var hasAccess;
|
|
198
198
|
return __generator(this, function (_a) {
|
|
199
199
|
switch (_a.label) {
|
|
200
200
|
case 0:
|
|
@@ -205,14 +205,8 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
|
205
205
|
callback(pageData);
|
|
206
206
|
return [2 /*return*/];
|
|
207
207
|
}
|
|
208
|
-
return [4 /*yield*/, GetUserProfile(msp_d, db, mdb, next)];
|
|
209
|
-
case 1:
|
|
210
|
-
response = _a.sent();
|
|
211
|
-
if (response && response.message == 'success') {
|
|
212
|
-
pageData['UserProfile'] = response.data;
|
|
213
|
-
}
|
|
214
208
|
return [4 /*yield*/, CheckPageAuthentication(pageData, msp_d, db, mdb, next)];
|
|
215
|
-
case
|
|
209
|
+
case 1:
|
|
216
210
|
hasAccess = _a.sent();
|
|
217
211
|
if (!hasAccess) {
|
|
218
212
|
callback('Unauthorised');
|
|
@@ -1013,7 +1007,7 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
|
|
|
1013
1007
|
var _this = this;
|
|
1014
1008
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1015
1009
|
return __generator(this, function (_a) {
|
|
1016
|
-
console.log("
|
|
1010
|
+
console.log("success");
|
|
1017
1011
|
try {
|
|
1018
1012
|
db.collection("ObjectSchema").findOne({ 'Name': objectName }, function (err, objectSchema) {
|
|
1019
1013
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3818,20 +3812,30 @@ exports.SyncUserLicenceConsumedCount = SyncUserLicenceConsumedCount;
|
|
|
3818
3812
|
*/
|
|
3819
3813
|
function BroadCastEventToAllCompanyUsers(params) {
|
|
3820
3814
|
try {
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3815
|
+
var aggregateArry = [];
|
|
3816
|
+
aggregateArry.push({
|
|
3817
|
+
$match: {
|
|
3818
|
+
'IsActive': true,
|
|
3819
|
+
'UserStatus': constants_1.default.USER_STATUS.ACTIVE
|
|
3820
|
+
}
|
|
3821
|
+
});
|
|
3822
|
+
if (params.Match != undefined) {
|
|
3823
|
+
aggregateArry.push({
|
|
3824
|
+
$match: params.Match
|
|
3825
|
+
});
|
|
3826
|
+
}
|
|
3827
|
+
aggregateArry.push({
|
|
3828
|
+
$project: { '_id': 1 }
|
|
3829
|
+
});
|
|
3830
|
+
params.db.collection('User').aggregate(aggregateArry, { "allowDiskUse": true }).toArray(function (err, usersData) {
|
|
3827
3831
|
if (err) {
|
|
3828
3832
|
console.log("Error while sending notification " + (params.EventName || "") + " to all company users. ==>", err);
|
|
3829
3833
|
return;
|
|
3830
3834
|
}
|
|
3831
|
-
else if (
|
|
3832
|
-
for (var i = 0; i <
|
|
3835
|
+
else if (usersData && usersData.length > 0) {
|
|
3836
|
+
for (var i = 0; i < usersData.length; i++) {
|
|
3833
3837
|
//not sending notification to sender
|
|
3834
|
-
if (params.UserID && params.UserID.toString() ==
|
|
3838
|
+
if (params.UserID && params.UserID.toString() == usersData[i]._id.toString()) {
|
|
3835
3839
|
continue;
|
|
3836
3840
|
}
|
|
3837
3841
|
//params.userID to handle
|
|
@@ -3843,9 +3847,9 @@ function BroadCastEventToAllCompanyUsers(params) {
|
|
|
3843
3847
|
var socketObjectData = {
|
|
3844
3848
|
eventType: eventItem.EventName,
|
|
3845
3849
|
data: eventItem.EventData,
|
|
3846
|
-
userId:
|
|
3850
|
+
userId: usersData[i]._id.toString()
|
|
3847
3851
|
};
|
|
3848
|
-
//socketUtility.TriggerSockerEvent(req,
|
|
3852
|
+
//socketUtility.TriggerSockerEvent(req, usersData[i]._id.toString(), eventName, data);
|
|
3849
3853
|
params.event.CreateEvent(null, null, { SocketObj: socketObjectData }).then(function (socketResult) {
|
|
3850
3854
|
if (socketResult) {
|
|
3851
3855
|
console.log("Success");
|
|
@@ -4297,26 +4301,19 @@ exports.GetUserProfile = GetUserProfile;
|
|
|
4297
4301
|
function CheckPageAuthentication(pageData, msp_d, db, mdb, next) {
|
|
4298
4302
|
var _a, _b;
|
|
4299
4303
|
return __awaiter(this, void 0, void 0, function () {
|
|
4300
|
-
var hasAccess,
|
|
4304
|
+
var hasAccess, response, userProfile, auth, i, moduleData;
|
|
4301
4305
|
return __generator(this, function (_c) {
|
|
4302
4306
|
switch (_c.label) {
|
|
4303
4307
|
case 0:
|
|
4304
4308
|
hasAccess = false;
|
|
4305
4309
|
if (!(pageData.IsPermissionRequired == false)) return [3 /*break*/, 1];
|
|
4306
4310
|
hasAccess = true;
|
|
4307
|
-
return [3 /*break*/,
|
|
4308
|
-
case 1:
|
|
4309
|
-
|
|
4310
|
-
if (!pageData.UserProfile) return [3 /*break*/, 2];
|
|
4311
|
-
userProfile = pageData.UserProfile;
|
|
4312
|
-
return [3 /*break*/, 4];
|
|
4313
|
-
case 2: return [4 /*yield*/, GetUserProfile(msp_d, db, mdb, next)];
|
|
4314
|
-
case 3:
|
|
4311
|
+
return [3 /*break*/, 3];
|
|
4312
|
+
case 1: return [4 /*yield*/, GetUserProfile(msp_d, db, mdb, next)];
|
|
4313
|
+
case 2:
|
|
4315
4314
|
response = _c.sent();
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
case 4:
|
|
4319
|
-
if (userProfile) {
|
|
4315
|
+
if (response && response.message == 'success') {
|
|
4316
|
+
userProfile = response.data;
|
|
4320
4317
|
auth = userProfile.Permissions;
|
|
4321
4318
|
for (i = 0; i < auth.length; i++) {
|
|
4322
4319
|
moduleData = auth[i].ModuleData;
|
|
@@ -4329,11 +4326,10 @@ function CheckPageAuthentication(pageData, msp_d, db, mdb, next) {
|
|
|
4329
4326
|
}
|
|
4330
4327
|
}
|
|
4331
4328
|
else {
|
|
4332
|
-
console.log(
|
|
4333
|
-
hasAccess = false;
|
|
4329
|
+
console.log(response === null || response === void 0 ? void 0 : response.message);
|
|
4334
4330
|
}
|
|
4335
|
-
_c.label =
|
|
4336
|
-
case
|
|
4331
|
+
_c.label = 3;
|
|
4332
|
+
case 3: return [2 /*return*/, hasAccess];
|
|
4337
4333
|
}
|
|
4338
4334
|
});
|
|
4339
4335
|
});
|