Parcourir la source

Merge branch 'mailreply_notif_replyto_references' into replywithmail

Guénaël Muller il y a 7 ans
Parent
révision
10dc9f15f4

+ 2 - 0
tracim/development.ini.base Voir le fichier

@@ -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 Voir le fichier

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

+ 18 - 1
tracim/tracim/lib/notifications.py Voir le fichier

@@ -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,16 @@ 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)
274
+            #
275
+            # INFO - G.M - 2017-11-15 - set content_id in header to permit reply
276
+            # references can have multiple values, but only one in this case.
277
+            replyto_addr = self._global_config.EMAIL_NOTIFICATION_REPLY_TO_EMAIL.replace( # nopep8
278
+                '{content_id}',str(content.content_id)
279
+            )
273 280
 
281
+            reference_addr = self._global_config.EMAIL_NOTIFICATION_REFERENCES_EMAIL.replace( #nopep8
282
+                '{content_id}',str(content.content_id)
283
+             )
274 284
             #
275 285
             #  INFO - D.A. - 2014-11-06
276 286
             # We do not use .format() here because the subject defined in the .ini file
@@ -287,7 +297,14 @@ class EmailNotifier(object):
287 297
             message['Subject'] = subject
288 298
             message['From'] = self._get_sender(user)
289 299
             message['To'] = to_addr
290
-
300
+            message['Reply-to'] = formataddr(('',replyto_addr))
301
+            # INFO - G.M - 2017-11-15
302
+            # References can theorically have label, but in pratice, references
303
+            # contains only message_id from parents post in thread.
304
+            # To link this email to a content we create a virtual parent
305
+            # in reference who contain the content_id.
306
+            message['References'] = formataddr(('',reference_addr))
307
+            # TODO: add correct header to allow reply
291 308
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
292 309
 
293 310