[FIX] mail: don't notify 'join/left' messages

Messages of type 'notification' and whose model is 'mail.channel' are
considered as 'system notifications'. This is the case of 'join/left' messages.
They aren't taken into account when computing unread messages anymore.

Also use the same heuristic to decide whether or not to display the message's
star, so from now on pure notifications (not system notifications), like status
change on a document, can be starred.
This commit is contained in:
Aaron Bohy
2016-02-01 11:31:09 +01:00
parent ef77e6821a
commit 4bab99bdaf
4 changed files with 7 additions and 5 deletions
+2 -1
View File
@@ -177,7 +177,8 @@ class MailThread(models.AbstractModel):
ON rel.mail_message_id = msg.id
RIGHT JOIN mail_channel_partner cp
ON (cp.channel_id = rel.mail_channel_id AND cp.partner_id = %s AND (cp.seen_message_id < msg.id))
WHERE msg.model = %s AND msg.res_id in %s AND msg.author_id != %s""",
WHERE msg.model = %s AND msg.res_id in %s AND msg.author_id != %s AND
(msg.message_type != 'notification' OR msg.model != 'mail.channel')""",
(partner_id, self._name, tuple(self.ids), partner_id,))
for result in self._cr.fetchall():
res[result[0]] += 1
+3 -2
View File
@@ -147,7 +147,7 @@ function add_message (data, options) {
channel.hidden = false;
chat_manager.bus.trigger('new_channel', channel);
}
if (channel.type !== 'static' && !msg.is_author) {
if (channel.type !== 'static' && !msg.is_author && !msg.is_system_notification) {
if (options.increment_unread) {
update_channel_unread_counter(channel, channel.unread_counter+1);
}
@@ -179,6 +179,7 @@ function make_message (data) {
subtype_description: data.subtype_description,
is_author: data.author_id && data.author_id[0] === session.partner_id,
is_note: data.is_note,
is_system_notification: data.message_type === 'notification' && data.model === 'mail.channel',
attachment_ids: data.attachment_ids,
subject: data.subject,
email_from: data.email_from,
@@ -820,7 +821,7 @@ var chat_manager = {
var msg = _.findWhere(messages, {id: channel.last_seen_message_id});
if (msg) {
var i = _.sortedIndex(messages, msg, 'id') + 1;
while (i < messages.length && messages[i].is_author) {
while (i < messages.length && (messages[i].is_author || messages[i].is_system_notification)) {
msg = messages[i];
i++;
}
+1 -1
View File
@@ -132,7 +132,7 @@ var Thread = Widget.extend({
msg.hour = msg.date.format('LT');
}
msg.display_subject = message.subject && message.message_type !== 'notification' && !(message.model && (message.model !== 'mail.channel'));
msg.display_subject = message.subject && !message.is_system_notification;
return msg;
},
+1 -1
View File
@@ -97,7 +97,7 @@
(from <a t-att-data-oe-id="message.origin_id" href="#">#<t t-esc="message.origin_name"/></a>)
</t>
<span>
<i t-if="options.display_stars &amp;&amp; message.message_type != 'notification'"
<i t-if="options.display_stars &amp;&amp; !message.is_system_notification"
t-att-class="'fa fa-lg o_thread_message_star ' + (message.is_starred ? 'fa-star' : 'fa-star-o')"
t-att-data-message-id="message.id" title="Mark as Todo"/>
<i t-if="message.is_needaction &amp;&amp; options.display_needactions"