Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Jan 22, 2024
1 parent aa9d791 commit 8278597
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions apps/meteor/app/api/server/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,12 +1261,25 @@ API.v1.addRoute(
{ authRequired: true, validateParams: isUsersGetNamesParamsGETProps },
{
async get() {
const users = await Users.findByUsernames(this.queryParams.usernames, {
projection: {
name: 1,
username: 1,
},
}).toArray();
let users: Pick<IUser, '_id' | 'username' | 'name'>[] = [];

if ('userIds' in this.queryParams) {
users = await Users.findByIds(this.queryParams.userIds, {
projection: {
name: 1,
username: 1,
},
}).toArray();
}

if ('usernames' in this.queryParams) {
users = await Users.findByUsernames(this.queryParams.usernames, {
projection: {
name: 1,
username: 1,
},
}).toArray();
}

return API.v1.success({
users,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const Reaction = ({ hasReacted, counter, name, names, ...props }: ReactionProps)
}

const users: string[] = showRealName
? (await getNames({ usernames: names }))?.users?.map((user) => user.name) || []
? (await getNames({ usernames: names }))?.users?.map((user) => user.name) || names.map((name) => `@${name}`)
: names.map((name) => `@${name}`);

return users;
Expand Down

0 comments on commit 8278597

Please sign in to comment.