Skip to content

Commit

Permalink
fix: request members by userIds
Browse files Browse the repository at this point in the history
  • Loading branch information
maxceem committed Mar 19, 2020
1 parent c72387f commit 496e4ac
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/events/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/admin/project-index-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/projectMemberInvites/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 496e4ac

Please sign in to comment.