[IMP] mail: chatter channel notification

Ability to notify the channel but do not add the channel as a follower.
Faster than mentioning every member of the channel.

Also, clean the rendering of the mention suggestions name to avoid
having escaped char in the UI.

Task id : 1859802
Closes #25887
This commit is contained in:
Demaret Rivarola Johan
2019-01-21 13:00:10 +00:00
committed by David Beguin
parent a3daff6bc1
commit e2f20ffa93
3 changed files with 13 additions and 7 deletions
@@ -416,6 +416,7 @@ var BasicComposer = Widget.extend({
attachment_ids: _.pluck(this.get('attachment_ids'), 'id'),
partner_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelection('@'), 'id')),
canned_response_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelections()[':'], 'id')),
channel_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelection('#'), 'id')),
command: commands.length > 0 ? commands[0].name : undefined,
});
},
@@ -52,10 +52,8 @@ var MentionManager = Widget.extend({
getListenerSelection: function (delimiter) {
var listener = _.findWhere(this._listeners, { delimiter: delimiter });
if (listener) {
var inputMentions = this._composer
.$input
.val()
.match(new RegExp(delimiter+'[^ ]+(?= | )', 'g'));
var escapedVal = _.escape(this._composer.$input.val());
var inputMentions = escapedVal.match(new RegExp(delimiter+'[^ ]+(?= | )', 'g'));
return this._validateSelection(listener.selection, inputMentions);
}
return [];
@@ -315,7 +313,10 @@ var MentionManager = Widget.extend({
}
if (suggestions.length) {
this.$el.html(QWeb.render(this._activeListener.suggestionTemplate, {
suggestions: suggestions,
suggestions: _.map(suggestions, function (suggestion) {
// mention manager stores escaped suggestion names
return _.extend({}, suggestion, { name: _.unescape(suggestion.name) });
})
}));
this.$el
.addClass('show')
@@ -384,8 +385,9 @@ var MentionManager = Widget.extend({
if (!substitution) {
// no substitution string given, so use the mention name instead
// replace white spaces with non-breaking spaces to facilitate
// mentions detection in text
selectedSuggestion.name = selectedSuggestion.name.replace(/ /g, NON_BREAKING_SPACE);
// mentions detection in text.
// mention manager stores escaped suggestion names
selectedSuggestion.name = _.unescape(selectedSuggestion.name.replace(/ /g, NON_BREAKING_SPACE));
substitution = this._activeListener.delimiter + selectedSuggestion.name;
}
var getMentionIndex = function (matches, cursorPosition) {
@@ -344,6 +344,9 @@ var Thread = AbstractThread.extend(ServicesMixin, {
body = this._generateEmojis(body);
var messageData = {
partner_ids: data.partner_ids,
channel_ids: _.map(data.channel_ids, function (channelID) {
return [4, channelID, false];
}),
body: body,
attachment_ids: data.attachment_ids,
canned_response_ids: data.canned_response_ids,