From fc42880da276736992d9cbc20fb423edb16a7d21 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 21 Jan 2016 16:00:12 +0100 Subject: [PATCH] [FIX] mail: restrict mention suggestions to channel members Problem is that when someone is mentionned in a channel he doesn't belong to (public, private or DM whatever), the message only appears in its Inbox and he can't know where it comes from nor reply. This is thus very confusing. With this rev., in Discuss, one can only mention members of the channels. In the chatter, anyone can be mentionned like before, as when the message arrives in the Inbox, there is a link to the associated document. --- addons/mail/static/src/js/chat_manager.js | 2 +- addons/mail/static/src/js/client_action.js | 4 ++-- addons/mail/static/src/js/composer.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 82299475db1..f425a4718f9 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -791,7 +791,7 @@ var chat_manager = { })); }); - return [members].concat(suggestions); + return [members]; }); } return channel.members_deferred; diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index e091590faa1..82b36f3425d 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -171,8 +171,8 @@ var ChatAction = Widget.extend(ControlPanelMixin, { this.searchview = new SearchView(this, dataset, view_id, {}, options); this.searchview.on('search_data', this, this.on_search); - this.basic_composer = new composer.BasicComposer(this); - this.extended_composer = new composer.ExtendedComposer(this); + this.basic_composer = new composer.BasicComposer(this, {mention_partners_restricted: true}); + this.extended_composer = new composer.ExtendedComposer(this, {mention_partners_restricted: true}); this.thread = new ChatThread(this, { display_help: true, shorten_messages: false, diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index dae8cdc4241..5d6de2bad50 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -331,6 +331,7 @@ var BasicComposer = Widget.extend({ input_max_height: 150, input_min_height: 28, mention_fetch_limit: 8, + mention_partners_restricted: false, // set to true to only suggest prefetched partners send_text: _('Send'), }); this.context = this.options.context; @@ -620,7 +621,7 @@ var BasicComposer = Widget.extend({ } } }); - if (!suggestions.length) { + if (!suggestions.length && !self.options.mention_partners_restricted) { // no result found among prefetched partners, fetch other suggestions var kwargs = { limit: limit,