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 ef1e0b3 commit ef83e40
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/publications/spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ 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 ef83e40

Please sign in to comment.