From e5e549a4cf12e62fc72c846dc32828182fae37e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 20 Mar 2017 16:12:18 +0100 Subject: [PATCH] [IMP] mail: make channels check their members instead of followers for alias This commit makes channel use 'followers' based alias security use members instead. Indeed channels do not use followers anymore. Instead channels have members, and alias security of followers should use members instead. --- addons/mail/models/mail_channel.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index 69031688c94..29f0e927978 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -232,6 +232,16 @@ class Channel(models.Model): message = super(Channel, self.with_context(mail_create_nosubscribe=True)).message_post(body=body, subject=subject, message_type=message_type, subtype=subtype, parent_id=parent_id, attachments=attachments, content_subtype=content_subtype, **kwargs) return message + def _alias_check_contact(self, message, message_dict, alias): + if alias.alias_contact == 'followers' and self.ids: + author = self.env['res.partner'].browse(message_dict.get('author_id', False)) + if not author or author not in self.channel_partner_ids: + return { + 'error_mesage': _('restricted to channel members'), + } + return True + return super(Channel, self)._alias_check_contact(message, message_dict, alias) + @api.model_cr def init(self): self._cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('mail_channel_partner_seen_message_id_idx',))