Skip to content

Commit

Permalink
[FIX] Spotlight search when view-outside-room is false (RocketChat#14930
Browse files Browse the repository at this point in the history
)
  • Loading branch information
TheoKouzelis committed Mar 16, 2020
1 parent 6914d11 commit 3f4d085
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/publications/spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ Meteor.methods({
fields: userOptions.fields,
sort: userOptions.sort,
}).fetch();
} else if (type.users === true) {
const userSubscriptions = Subscriptions.findByUserId(userId, { rid: true })
.fetch()
.map((x) => x.rid);

const usersWithSameSubscriptions = Subscriptions.find({
rid: { $in: userSubscriptions },
'u._id': { $ne: userId },
})
.fetch()
.map(({ u }) => u._id);

result.users = Users.find({
active: true,
_id: { $in: usersWithSameSubscriptions },
username: { $regex: regex },
}, {
fields: userOptions.fields,
sort: userOptions.sort,
limit: userOptions.limit,
}).fetch();
}

return result;
Expand Down

0 comments on commit 3f4d085

Please sign in to comment.