shuttlepro-shared 1.2.75 → 1.2.76
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.
|
@@ -11,10 +11,11 @@ const MEMBERS = "members";
|
|
|
11
11
|
const updateCachedMembers = async (workspaceId) => {
|
|
12
12
|
try {
|
|
13
13
|
const members = await UserRole.find({ workspaceId })
|
|
14
|
-
.select("userId role userShift roleId")
|
|
14
|
+
.select("userId role userShift roleId isOwner workspaceId")
|
|
15
15
|
.populate({
|
|
16
16
|
path: "roleId",
|
|
17
|
-
select:
|
|
17
|
+
select:
|
|
18
|
+
"id name userId userShift permissionId modulePermissions workspaceId",
|
|
18
19
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
19
20
|
})
|
|
20
21
|
.populate({
|
|
@@ -36,10 +37,11 @@ const getMembers = async (workspaceId) => {
|
|
|
36
37
|
let members = await getRedisData(workspaceId, MEMBERS);
|
|
37
38
|
if (!members || members?.length === 0) {
|
|
38
39
|
members = await UserRole.find({ workspaceId })
|
|
39
|
-
.select("userId role userShift roleId")
|
|
40
|
+
.select("userId role userShift roleId isOwner workspaceId")
|
|
40
41
|
.populate({
|
|
41
42
|
path: "roleId",
|
|
42
|
-
select:
|
|
43
|
+
select:
|
|
44
|
+
"id name userId userShift permissionId modulePermissions workspaceId",
|
|
43
45
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
44
46
|
})
|
|
45
47
|
.populate({
|
|
@@ -69,6 +71,10 @@ const findSingleUserRoleByFilter = async ({ workspaceId, userId }) => {
|
|
|
69
71
|
return await getMemberByWorkspaceIdAndUserId(workspaceId, userId);
|
|
70
72
|
};
|
|
71
73
|
|
|
74
|
+
const findUserRole = async ({ workspaceId, userId }) => {
|
|
75
|
+
return await getMemberByWorkspaceIdAndUserId(workspaceId, userId);
|
|
76
|
+
};
|
|
77
|
+
|
|
72
78
|
const createUserRole = async (data) => {
|
|
73
79
|
const savedRole = await UserRole.create(data);
|
|
74
80
|
return await updateCachedMembers(savedRole?.workspaceId?.toString());
|
|
@@ -214,8 +220,8 @@ const findUserWorkspaces = async (userId) => {
|
|
|
214
220
|
|
|
215
221
|
module.exports = {
|
|
216
222
|
createUserRole,
|
|
217
|
-
findUserRole,
|
|
218
223
|
updateUserRole,
|
|
224
|
+
findUserRole,
|
|
219
225
|
deleteUserRoleByFilter,
|
|
220
226
|
findUserWorkspaces,
|
|
221
227
|
getUserRoleWithPermissions,
|