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

DEV-4846 Prevent starting a conversation with users in other store gr… #9

Merged
merged 2 commits into from
May 26, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion 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 } });
const newItems = Meteor.users.find({
$and: [
{
Expand All @@ -295,6 +299,11 @@ Template.messagePopupConfig.helpers({
],
},
},
{
'customFields.groupId': {
$in: [groupId, null],
},
},
],
},
{
Expand Down