summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorQiuyu (QHO) <qho@odoo.com>2021-03-19 14:57:01 +0000
committerQiuyu (QHO) <qho@odoo.com>2021-03-23 15:58:09 +0000
commit1b09aeabe3e75dfd221c3ba089bdf94848c2a507 (patch)
tree40f948e45d611a14e240d68487ced6815ce3d1e8 /addons/mail
parent81a8be7d115ffcfac0126c252811381a482bd6a9 (diff)
[FIX] mail: unfollow only if the partner is in the channel
Before the commit, `_action_unfollow()` can be called by `_message_receive_bounce()` and then multiple leave notifications can be sent even if the partner has been removed from the channel, when the partner is a follower of the channel and without a valid email address. Unfollow action should also remove the partner from the followers, and only be processed if the partner is still a member of the channel. Task id: 2456233 closes odoo/odoo#68154 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/models/mail_channel.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index ab5033c4642..9781823ad20 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -322,6 +322,9 @@ class Channel(models.Model):
return self._action_unfollow(self.env.user.partner_id)
def _action_unfollow(self, partner):
+ self.message_unsubscribe(partner.ids)
+ if partner not in self.with_context(active_test=False).channel_partner_ids:
+ return True
channel_info = self.channel_info('unsubscribe')[0] # must be computed before leaving the channel (access rights)
result = self.write({'channel_partner_ids': [(3, partner.id)]})
# side effect of unsubscribe that wasn't taken into account because