shuttlepro-shared 1.2.37 → 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.
|
@@ -123,6 +123,7 @@ const deleteUserRole = async (id) => {
|
|
|
123
123
|
|
|
124
124
|
const findUserWorkspaces = async (userId) => {
|
|
125
125
|
const cacheKey = `${CACHE_KEY_USER_WORKSPACE_PREFIX}${userId}`;
|
|
126
|
+
console.log(cacheKey, "cacheKey");
|
|
126
127
|
let userRoleWithWorkspaces = await getDataFromRedisSet(cacheKey);
|
|
127
128
|
console.log(userRoleWithWorkspaces, "from cache");
|
|
128
129
|
if (!userRoleWithWorkspaces.length) {
|
|
@@ -142,8 +143,16 @@ const findUserWorkspaces = async (userId) => {
|
|
|
142
143
|
})
|
|
143
144
|
.lean()
|
|
144
145
|
.exec();
|
|
145
|
-
|
|
146
|
-
|
|
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) {
|
|
147
156
|
await addArrayToRedisSet(cacheKey, userRoleWithWorkspaces);
|
|
148
157
|
}
|
|
149
158
|
}
|
package/config/redis.js
CHANGED
|
@@ -107,12 +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
|
-
// Convert each item to string (usually JSON)
|
|
111
|
+
console.log(arr, "arr");
|
|
114
112
|
const stringifiedArr = arr.map((item) => JSON.stringify(item));
|
|
115
|
-
|
|
116
113
|
await client.sAdd(key, ...stringifiedArr);
|
|
117
114
|
return true;
|
|
118
115
|
} catch (err) {
|