Browse Source

WIP reply-to/references header in notif mail to allow reply mail

Guénaël Muller 7 years ago
parent
commit
54dac658c6
3 changed files with 18 additions and 2 deletions
  1. 2 0
      tracim/development.ini.base
  2. 6 0
      tracim/tracim/config/app_cfg.py
  3. 10 2
      tracim/tracim/lib/notifications.py

+ 2 - 0
tracim/development.ini.base View File

@@ -190,6 +190,8 @@ email.notification.activated = False
190 190
 # notifications generated by a user or another one
191 191
 email.notification.from.email = noreply+{user_id}@trac.im
192 192
 email.notification.from.default_label = Tracim Notifications
193
+email.notification.reply_to.email = reply+{content_id}@trac.im
194
+email.notification.references.email = thread+{content_id}@trac.im
193 195
 email.notification.content_update.template.html = %(here)s/tracim/templates/mail/content_update_body_html.mak
194 196
 email.notification.content_update.template.text = %(here)s/tracim/templates/mail/content_update_body_text.mak
195 197
 email.notification.created_account.template.html = %(here)s/tracim/templates/mail/created_account_body_html.mak

+ 6 - 0
tracim/tracim/config/app_cfg.py View File

@@ -299,6 +299,12 @@ class CFG(object):
299 299
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = tg.config.get(
300 300
             'email.notification.from.default_label'
301 301
         )
302
+        self.EMAIL_NOTIFICATION_REPLY_TO_EMAIL = tg.config.get(
303
+            'email.notification.reply_to.email',
304
+        )
305
+        self.EMAIL_NOTIFICATION_REFERENCES_EMAIL = tg.config.get(
306
+            'email.notification.references.email'
307
+        )
302 308
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get(
303 309
             'email.notification.content_update.template.html',
304 310
         )

+ 10 - 2
tracim/tracim/lib/notifications.py View File

@@ -5,6 +5,7 @@ import typing
5 5
 from email.header import Header
6 6
 from email.mime.multipart import MIMEMultipart
7 7
 from email.mime.text import MIMEText
8
+from email.utils import formataddr
8 9
 
9 10
 from lxml.html.diff import htmldiff
10 11
 
@@ -270,7 +271,12 @@ class EmailNotifier(object):
270 271
         for role in notifiable_roles:
271 272
             logger.info(self, 'Sending email to {}'.format(role.user.email))
272 273
             to_addr = '{name} <{email}>'.format(name=role.user.display_name, email=role.user.email)
273
-
274
+            replyto_addr = self._global_config.EMAIL_NOTIFICATION_REPLY_TO_EMAIL.replace( # nopep8
275
+                '{content_id}',str(content.content_id)
276
+            )
277
+            reference_addr = self._global_config.EMAIL_NOTIFICATION_REFERENCES_EMAIL.replace( #nopep8
278
+                '{content_id}',str(content.content_id)
279
+             )
274 280
             #
275 281
             #  INFO - D.A. - 2014-11-06
276 282
             # We do not use .format() here because the subject defined in the .ini file
@@ -287,7 +293,9 @@ class EmailNotifier(object):
287 293
             message['Subject'] = subject
288 294
             message['From'] = self._get_sender(user)
289 295
             message['To'] = to_addr
290
-
296
+            message['Reply-to'] = formataddr(('',replyto_addr))
297
+            message['References'] = formataddr(('',reference_addr))
298
+            # TODO: add correct header to allow reply
291 299
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
292 300
 
293 301