shuttlepro-shared 1.3.23 → 1.3.24
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.
|
@@ -2,7 +2,7 @@ const { UserRole } = require("../../models/UserRole");
|
|
|
2
2
|
const { getRedisData, setRedisData } = require("../../config/redis");
|
|
3
3
|
|
|
4
4
|
const defaultSelect =
|
|
5
|
-
"iconUrl thumbUrl name productsCount ordersCount contact email address websiteUrl facebookUrl twitterUrl instagramUrl members defaultModule
|
|
5
|
+
"iconUrl thumbUrl name productsCount ordersCount contact email address websiteUrl facebookUrl twitterUrl instagramUrl members defaultModule";
|
|
6
6
|
|
|
7
7
|
// Cache keys
|
|
8
8
|
const MEMBERS = "members";
|
|
@@ -35,7 +35,6 @@ const updateCachedMembers = async (workspaceId) => {
|
|
|
35
35
|
|
|
36
36
|
const getMembers = async (workspaceId) => {
|
|
37
37
|
let members = await getRedisData(workspaceId, MEMBERS);
|
|
38
|
-
console.log(members, "inside members");
|
|
39
38
|
if (!members || members?.length === 0) {
|
|
40
39
|
members = await UserRole.find({ workspaceId })
|
|
41
40
|
.select("userId role userShift roleId isOwner workspaceId")
|
|
@@ -54,7 +53,6 @@ const getMembers = async (workspaceId) => {
|
|
|
54
53
|
.exec();
|
|
55
54
|
await setRedisData(workspaceId, members, MEMBERS, 3600);
|
|
56
55
|
}
|
|
57
|
-
console.log(members, "inside after members");
|
|
58
56
|
return members;
|
|
59
57
|
};
|
|
60
58
|
|
|
@@ -63,8 +61,7 @@ const getMemberByWorkspaceIdAndUserId = async (workspaceId, userId) => {
|
|
|
63
61
|
return (
|
|
64
62
|
members?.find(
|
|
65
63
|
(member) =>
|
|
66
|
-
member?.workspaceId
|
|
67
|
-
member?.userId?._id?.toString() === userId?.toString()
|
|
64
|
+
member?.workspaceId === workspaceId && member?.userId?._id === userId
|
|
68
65
|
) || null
|
|
69
66
|
);
|
|
70
67
|
};
|
|
@@ -31,42 +31,29 @@ exports.checkPermission = async (req, res, next, values) => {
|
|
|
31
31
|
const accessToken = token.split(" ")[1];
|
|
32
32
|
const body = getBodyFromDecodeToken(accessToken);
|
|
33
33
|
if (body) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// isVerified: body.isVerified,
|
|
58
|
-
// role: body.role,
|
|
59
|
-
// isMember: body.isMember,
|
|
60
|
-
// uuid: body.uuid,
|
|
61
|
-
// };
|
|
62
|
-
// req.currentModulePermission = moduleObj;
|
|
63
|
-
// return next();
|
|
64
|
-
// } else {
|
|
65
|
-
// return res.status(HttpStatusCode.UNAUTHORIZED).json({
|
|
66
|
-
// code: HttpStatusCode.UNAUTHORIZED,
|
|
67
|
-
// message: GenericMessages.PERMISSION_DENIED,
|
|
68
|
-
// });
|
|
69
|
-
// }
|
|
34
|
+
const { module, action } = values;
|
|
35
|
+
const moduleObj = getModule(body, module);
|
|
36
|
+
if (moduleObj && moduleObj.includes(action)) {
|
|
37
|
+
req.user = {
|
|
38
|
+
id: body.id,
|
|
39
|
+
type: body.type,
|
|
40
|
+
email: body.email,
|
|
41
|
+
firstName: body.firstName,
|
|
42
|
+
lastName: body.lastName,
|
|
43
|
+
suspended: body.suspended,
|
|
44
|
+
isVerified: body.isVerified,
|
|
45
|
+
role: body.role,
|
|
46
|
+
isMember: body.isMember,
|
|
47
|
+
uuid: body.uuid,
|
|
48
|
+
};
|
|
49
|
+
req.currentModulePermission = moduleObj;
|
|
50
|
+
return next();
|
|
51
|
+
} else {
|
|
52
|
+
return res.status(HttpStatusCode.UNAUTHORIZED).json({
|
|
53
|
+
code: HttpStatusCode.UNAUTHORIZED,
|
|
54
|
+
message: GenericMessages.PERMISSION_DENIED,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
70
57
|
}
|
|
71
58
|
return res.status(HttpStatusCode.UNAUTHORIZED).json({
|
|
72
59
|
code: HttpStatusCode.UNAUTHORIZED,
|
|
@@ -8,6 +8,7 @@ const CustomerProfileSchema = new Schema(
|
|
|
8
8
|
picture: { type: String, default: "" },
|
|
9
9
|
fbId: { type: String, default: "" },
|
|
10
10
|
igId: { type: String, default: "" },
|
|
11
|
+
profiles: [],
|
|
11
12
|
totalOrders: { type: Number, default: 0 },
|
|
12
13
|
totalConversations: { type: Number, default: 0 },
|
|
13
14
|
totalTickets: { type: Number, default: 0 },
|
package/models/Workspace.js
CHANGED
|
@@ -191,6 +191,18 @@ const workspaceSchema = new mongoose.Schema(
|
|
|
191
191
|
facebookUrl: String,
|
|
192
192
|
twitterUrl: String,
|
|
193
193
|
instagramUrl: String,
|
|
194
|
+
highRiskOrderAmount: {
|
|
195
|
+
type: Number,
|
|
196
|
+
default: 100000,
|
|
197
|
+
},
|
|
198
|
+
highRiskOrderQuantity: {
|
|
199
|
+
type: Number,
|
|
200
|
+
default: 15,
|
|
201
|
+
},
|
|
202
|
+
highRiskAcceptanceRatio: {
|
|
203
|
+
type: Number,
|
|
204
|
+
default: 75,
|
|
205
|
+
},
|
|
194
206
|
isDeleted: { type: Boolean, default: false },
|
|
195
207
|
businessHours: {
|
|
196
208
|
startTime: { type: String, default: "" },
|
|
@@ -280,7 +292,6 @@ const workspaceSchema = new mongoose.Schema(
|
|
|
280
292
|
default: "everyone",
|
|
281
293
|
},
|
|
282
294
|
defaultShift: { type: String, default: "" },
|
|
283
|
-
allowedModules: [],
|
|
284
295
|
},
|
|
285
296
|
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
286
297
|
);
|