@otters.ai/common-backend 1.0.95 → 1.0.96
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {*} req Express req Object
|
|
3
|
+
* @param {*} res Express res Object
|
|
4
|
+
* @param {*} next Express next Function
|
|
5
|
+
*/
|
|
6
|
+
declare const checkCategory: (req: any, res: any, next: any, filters: {
|
|
7
|
+
mapService: any;
|
|
8
|
+
goalService: any;
|
|
9
|
+
activityService: any;
|
|
10
|
+
}) => Promise<any>;
|
|
11
|
+
export default checkCategory;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const functions_1 = require("../functions");
|
|
13
|
+
const enum_1 = require("../enum");
|
|
14
|
+
/**
|
|
15
|
+
* @param {*} req Express req Object
|
|
16
|
+
* @param {*} res Express res Object
|
|
17
|
+
* @param {*} next Express next Function
|
|
18
|
+
*/
|
|
19
|
+
const checkCategory = (req, res, next, filters) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
const obj = (0, functions_1.getCOFiltersByCompanyAdmin)({
|
|
22
|
+
id: req.body['referenceId'],
|
|
23
|
+
userId: req['userId'],
|
|
24
|
+
companyAdmin: req['userDetails']['companyAdmin'],
|
|
25
|
+
companyId: req['userDetails']['companyDetails']['id']
|
|
26
|
+
});
|
|
27
|
+
let flag = false;
|
|
28
|
+
switch (req.body.type.toString()) {
|
|
29
|
+
case enum_1.BaseCategory.MAP: {
|
|
30
|
+
obj['mapId'] = obj['_id'];
|
|
31
|
+
delete obj['_id'];
|
|
32
|
+
const getDetails = yield filters.mapService
|
|
33
|
+
.getSingleEntryBasedOnFilter(obj);
|
|
34
|
+
flag = getDetails.flag;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case enum_1.BaseCategory.GOAL: {
|
|
38
|
+
obj['goalId'] = obj['_id'];
|
|
39
|
+
delete obj['_id'];
|
|
40
|
+
const getDetails = yield filters.goalService
|
|
41
|
+
.getSingleEntryBasedOnFilter(obj);
|
|
42
|
+
flag = getDetails.flag;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case enum_1.BaseCategory.ACTIVITY: {
|
|
46
|
+
obj['activityId'] = obj['_id'];
|
|
47
|
+
delete obj['_id'];
|
|
48
|
+
const getDetails = yield filters.activityService
|
|
49
|
+
.getSingleEntryBasedOnFilter(obj);
|
|
50
|
+
flag = getDetails.flag;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (flag) {
|
|
55
|
+
next();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return res.status(200).json({ success: false, message: "User not allowed to add comment." });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
return next(e);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
exports.default = checkCategory;
|
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./checkToken"), exports);
|
|
18
18
|
__exportStar(require("./checkIsAdmin"), exports);
|
|
19
19
|
__exportStar(require("./getUserDetails"), exports);
|
|
20
|
+
__exportStar(require("./checkCategory"), exports);
|