[FIX] mail_group: add missing SMTP headers

Bug
===
Since 2d359b909b we moved the mailing
list feature of the <mail.channel> in a different model, <mail.group>.

During this split, some SMTP headers have been forgotten.

Task-2721009

closes odoo/odoo#81887

X-original-commit: daf9c0300fb042891c019e4f2a8c5395de388e1c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
std-odoo
2021-12-24 09:52:42 +00:00
parent ff4ac9075b
commit efc407fe03
2 changed files with 9 additions and 15 deletions
-15
View File
@@ -532,21 +532,6 @@ class Channel(models.Model):
groups[index] = (group_name, lambda partner: False, group_data)
return groups
def _notify_email_header_dict(self):
headers = super(Channel, self)._notify_email_header_dict()
headers['Precedence'] = 'list'
# avoid out-of-office replies from MS Exchange
# http://blogs.technet.com/b/exchange/archive/2006/10/06/3395024.aspx
headers['X-Auto-Response-Suppress'] = 'OOF'
if self.alias_domain and self.alias_name:
headers['List-Id'] = '<%s.%s>' % (self.alias_name, self.alias_domain)
headers['List-Post'] = '<mailto:%s@%s>' % (self.alias_name, self.alias_domain)
# Avoid users thinking it was a personal message
# X-Forge-To: will replace To: after SMTP envelope is determined by ir.mail.server
list_to = '"%s" <%s@%s>' % (self.name, self.alias_name, self.alias_domain)
headers['X-Forge-To'] = list_to
return headers
def _notify_thread(self, message, msg_vals=False, **kwargs):
# link message to channel
rdata = super(Channel, self)._notify_thread(message, msg_vals=msg_vals, **kwargs)
+9
View File
@@ -424,10 +424,19 @@ class MailGroup(models.Model):
# SMTP headers related to the subscription
email_url_encoded = urls.url_quote(email_member)
headers = {
** self._notify_email_header_dict(),
'List-Archive': f'<{base_url}/groups/{slug(self)}>',
'List-Subscribe': f'<{base_url}/groups?email={email_url_encoded}>',
'List-Unsubscribe': f'<{base_url}/groups?unsubscribe&email={email_url_encoded}>',
'Precedence': 'list',
'X-Auto-Response-Suppress': 'OOF', # avoid out-of-office replies from MS Exchange
}
if self.alias_name and self.alias_domain:
headers.update({
'List-Id': f'<{self.alias_name}.{self.alias_domain}>',
'List-Post': f'<mailto:{self.alias_name}@{self.alias_domain}>',
'X-Forge-To': f'"{self.name}" <{self.alias_name}@{self.alias_domain}>',
})
if message.mail_message_id.parent_id:
headers['In-Reply-To'] = message.mail_message_id.parent_id.message_id