Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
DEV-4846 Prevent starting a conversation with users in other store gr…
Browse files Browse the repository at this point in the history
…oups (#9)
  • Loading branch information
Sergey-Volkov authored May 26, 2020
1 parent ef7ffb6 commit 4dbb9f1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/ui-message/client/popup/messagePopupConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ Template.messagePopupConfig.helpers({

// If needed, add to list the online users
if (items.length < 5 && filterRegex) {
const user = Meteor.users.findOne(Meteor.userId(), { fields: { username: 1, 'customFields.groupId': 1 } });
const { customFields: { groupId } = {} } = user || {};
const usernamesAlreadyFetched = items.map(({ username }) => username);
if (!hasAllPermission('view-outside-room')) {
const usernamesFromDMs = Subscriptions
Expand Down Expand Up @@ -255,6 +257,9 @@ Template.messagePopupConfig.helpers({
username: {
$in: usernamesFromDMs,
},
'customFields.groupId': {
$in: [groupId, null],
},
},
{
fields: {
Expand All @@ -276,7 +281,6 @@ Template.messagePopupConfig.helpers({

items.push(...newItems);
} else {
const user = Meteor.users.findOne(Meteor.userId(), { fields: { username: 1, 'customFields.groupId': 1 } });
const newItems = Meteor.users.find({
$and: [
{
Expand All @@ -296,7 +300,9 @@ Template.messagePopupConfig.helpers({
},
},
{
groupId: { $in: [user && user.customFields && user.customFields.groupId, null] },
'customFields.groupId': {
$in: [groupId, null],
},
},
],
},
Expand Down

0 comments on commit 4dbb9f1

Please sign in to comment.