shuttlepro-shared 1.2.38 → 1.2.39
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.
|
@@ -143,16 +143,17 @@ const findUserWorkspaces = async (userId) => {
|
|
|
143
143
|
})
|
|
144
144
|
.lean()
|
|
145
145
|
.exec();
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
userRoleWithWorkspaces = userRoleWithWorkspaces.map((ur) => {
|
|
147
|
+
return {
|
|
148
|
+
...ur?.workspaceId,
|
|
149
|
+
id: ur?.workspaceId?._id?.toString(),
|
|
150
|
+
_id: ur?.workspaceId?._id?.toString(),
|
|
151
|
+
role: ur?.roleId?.name || "",
|
|
152
|
+
permissions: ur?.roleId?.modulePermissions?.modules || [],
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
if (userRoleWithWorkspaces.length) {
|
|
156
|
+
await addArrayToRedisSet(cacheKey, userRoleWithWorkspaces);
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
return userRoleWithWorkspaces;
|
package/config/redis.js
CHANGED
|
@@ -107,16 +107,9 @@ const addDataToRedisSet = async (key, value) => {
|
|
|
107
107
|
const addArrayToRedisSet = async (key, value) => {
|
|
108
108
|
try {
|
|
109
109
|
await connectRedis();
|
|
110
|
-
|
|
111
110
|
const arr = Array.isArray(value) ? value : [value];
|
|
112
|
-
|
|
113
111
|
console.log(arr, "arr");
|
|
114
|
-
|
|
115
|
-
// Convert each item to string (usually JSON)
|
|
116
112
|
const stringifiedArr = arr.map((item) => JSON.stringify(item));
|
|
117
|
-
|
|
118
|
-
console.log(stringifiedArr, "stringifiedArr");
|
|
119
|
-
|
|
120
113
|
await client.sAdd(key, ...stringifiedArr);
|
|
121
114
|
return true;
|
|
122
115
|
} catch (err) {
|