summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/models/threads/channel.js
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-10-10 16:23:29 +0000
committerAlexandre Kühn <aku@odoo.com>2018-10-16 07:29:08 +0000
commitd3ceaa3adc82d016ee06d47d97ff61ad745e4072 (patch)
treeaf272ff3864e9a398bd46bc58c8bfbce56dab7a6 /addons/mail/static/src/js/models/threads/channel.js
parent4531348ff08536ce9f1de8fbebbe25f2299965e3 (diff)
[FIX] mail: improved message_fetch for moderated channels
There was two issues with the previous code: 1. It was using a weak heuristic to determine whether the current thread is a channel (ID is a number) 2. For any channel, it was always passing `moderated_channel_ids` with some values to the server, even though the channel is not moderated at all. This commit solves both issues by passing `moderated_channel_ids` only for moderated channel. Also, this logic has been moved from SearchableThread to Channel, since moderation makes only sense for channels and channels are aware of whether they are moderated or not.
Diffstat (limited to 'addons/mail/static/src/js/models/threads/channel.js')
-rw-r--r--addons/mail/static/src/js/models/threads/channel.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/mail/static/src/js/models/threads/channel.js b/addons/mail/static/src/js/models/threads/channel.js
index 2e186bd11e5..3a257eb2272 100644
--- a/addons/mail/static/src/js/models/threads/channel.js
+++ b/addons/mail/static/src/js/models/threads/channel.js
@@ -358,6 +358,23 @@ var Channel = SearchableThread.extend(ThreadTypingMixin, {
});
},
/**
+ * Override so that it tells whether the channel is moderated or not. This
+ * is useful in order to display pending moderation messages when the
+ * current user is either moderator of the channel or has posted some
+ * messages that are pending moderation.
+ *
+ * @override
+ * @private
+ * @returns {Object}
+ */
+ _getFetchMessagesKwargs: function () {
+ var kwargs = this._super.apply(this, arguments);
+ if (this.isModerated()) {
+ kwargs.moderated_channel_ids = [this.getID()];
+ }
+ return kwargs;
+ },
+ /**
* Get the domain to fetch all the messages in the current channel
*
* Note that with moderation, even though some messages are not really