From 496e4acba4897fee5f247b5c3bafcdfb9cd2b812 Mon Sep 17 00:00:00 2001 From: Maksym Mykhailenko Date: Thu, 19 Mar 2020 21:02:40 +0800 Subject: [PATCH] fix: request members by userIds --- src/events/projects/index.js | 2 +- src/routes/admin/project-index-create.js | 2 +- src/routes/projectMemberInvites/create.js | 2 +- src/util.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/events/projects/index.js b/src/events/projects/index.js index ab53c704..f11f474f 100644 --- a/src/events/projects/index.js +++ b/src/events/projects/index.js @@ -23,7 +23,7 @@ const eClient = util.getElasticSearchClient(); */ const indexProject = Promise.coroutine(function* (logger, msg) { // eslint-disable-line func-names const data = JSON.parse(msg.content.toString()); - const userIds = data.members ? data.members.map(single => `userId:${single.userId}`) : []; + const userIds = data.members ? _.map(data.members, 'userId') : []; try { // retrieve member details const memberDetails = yield util.getMemberDetailsByUserIds(userIds, logger, msg.properties.correlationId); diff --git a/src/routes/admin/project-index-create.js b/src/routes/admin/project-index-create.js index c5ccc8bb..8662b97e 100644 --- a/src/routes/admin/project-index-create.js +++ b/src/routes/admin/project-index-create.js @@ -69,7 +69,7 @@ module.exports = [ // check context for project members project.members = _.map(currentProjectMembers, m => _.pick(m, fields.project_members)); logger.debug('project.members => ', project.members); - const userIds = project.members ? project.members.map(single => `userId:${single.userId}`) : []; + const userIds = project.members ? _.map(project.members, 'userId') : []; logger.debug('userIds => ', userIds); return util.getMemberDetailsByUserIds(userIds, logger, req.id) .then((memberDetails) => { diff --git a/src/routes/projectMemberInvites/create.js b/src/routes/projectMemberInvites/create.js index ec7a7a6c..d7b3bfbf 100644 --- a/src/routes/projectMemberInvites/create.js +++ b/src/routes/projectMemberInvites/create.js @@ -186,7 +186,7 @@ const sendInviteEmail = (req, projectId, invite) => { where: { id: projectId }, raw: true, }), - util.getMemberDetailsByUserIds([`userId:${req.authUser.userId}`], req.log, req.id), + util.getMemberDetailsByUserIds([req.authUser.userId], req.log, req.id), ]; return Promise.all(promises).then((responses) => { req.log.debug(responses); diff --git a/src/util.js b/src/util.js index dc284fc0..e76e4a9e 100644 --- a/src/util.js +++ b/src/util.js @@ -567,7 +567,7 @@ _.assignIn(util, { } return httpClient.get(`${config.memberServiceEndpoint}/_search`, { params: { - query: `${userIds.join(urlencode(' OR ', 'utf8'))}`, + query: `${_.map(userIds, id => `userId:${id}`).join(urlencode(' OR ', 'utf8'))}`, fields: 'userId,handle,firstName,lastName,email', }, headers: {