Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 3d35f48

Browse files
Use id instead of groupId
1 parent 20740ae commit 3d35f48

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

update-groups-v2.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ async function updateGroupsForUser (userId, groups) {
222222
})
223223

224224
const propertyName = config.get('ES.USER_GROUP_PROPERTY_NAME')
225-
if (!user[propertyName]) {
226-
user[propertyName] = []
227-
}
225+
// if (!user[propertyName]) {
226+
// user[propertyName] = []
227+
// }
228228

229-
let groupsTotal = user[propertyName].concat(groups)
229+
// let groupsTotal = user[propertyName].concat(groups)
230230

231-
groupsTotal = _.uniqBy(groupsTotal, (g) => g.groupId)
231+
// groupsTotal = _.uniqBy(groupsTotal, (g) => g.id)
232232

233-
user[propertyName] = groupsTotal
233+
user[propertyName] = _.uniqBy(groups, (g) => g.id)
234234

235235
await client.index({
236236
index: config.get('ES.USER_INDEX'),
@@ -265,7 +265,7 @@ async function start () {
265265
const memberId = externalProfiles[j].externalId
266266
console.log(`Getting groups of user with id ${memberId}`)
267267
let groups = await getGroupsOfUser(memberId)
268-
groups = groups.map(g => ({ groupId: g.id, name: g.name }))
268+
groups = groups.map(g => ({ id: g.id, name: g.name }))
269269

270270
if (groups.length > 0) {
271271
if (!final[userId]) {

update-groups.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ async function updateGroupsForUser (userId, groups) {
256256
})
257257

258258
const propertyName = config.get('ES.USER_GROUP_PROPERTY_NAME')
259-
if (!user[propertyName]) {
260-
user[propertyName] = []
261-
}
259+
// if (!user[propertyName]) {
260+
// user[propertyName] = []
261+
// }
262262

263-
let groupsTotal = user[propertyName].concat(groups)
263+
// let groupsTotal = user[propertyName].concat(groups)
264264

265-
groupsTotal = _.uniqBy(groupsTotal, (g) => g.groupId)
265+
// groupsTotal = _.uniqBy(groupsTotal, (g) => g.id)
266266

267-
user[propertyName] = groupsTotal
267+
user[propertyName] = _.uniqBy(groups, (g) => g.id)
268268

269269
await client.index({
270270
index: config.get('ES.USER_INDEX'),
@@ -317,7 +317,7 @@ async function start () {
317317
}
318318

319319
final[ubahnuser[0].id].push({
320-
groupId: groups[i].id,
320+
id: groups[i].id,
321321
name: groups[i].name
322322
})
323323
}

0 commit comments

Comments
 (0)