Browse Source

Merge branch 'mailreply_notif_replyto_references' into replywithmail

Guénaël Muller 7 years ago
parent
commit
10dc9f15f4

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

190
 # notifications generated by a user or another one
190
 # notifications generated by a user or another one
191
 email.notification.from.email = noreply+{user_id}@trac.im
191
 email.notification.from.email = noreply+{user_id}@trac.im
192
 email.notification.from.default_label = Tracim Notifications
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
 email.notification.content_update.template.html = %(here)s/tracim/templates/mail/content_update_body_html.mak
195
 email.notification.content_update.template.html = %(here)s/tracim/templates/mail/content_update_body_html.mak
194
 email.notification.content_update.template.text = %(here)s/tracim/templates/mail/content_update_body_text.mak
196
 email.notification.content_update.template.text = %(here)s/tracim/templates/mail/content_update_body_text.mak
195
 email.notification.created_account.template.html = %(here)s/tracim/templates/mail/created_account_body_html.mak
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

303
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = tg.config.get(
303
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = tg.config.get(
304
             'email.notification.from.default_label'
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
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get(
312
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get(
307
             'email.notification.content_update.template.html',
313
             'email.notification.content_update.template.html',
308
         )
314
         )

+ 18 - 1
tracim/tracim/lib/notifications.py View File

5
 from email.header import Header
5
 from email.header import Header
6
 from email.mime.multipart import MIMEMultipart
6
 from email.mime.multipart import MIMEMultipart
7
 from email.mime.text import MIMEText
7
 from email.mime.text import MIMEText
8
+from email.utils import formataddr
8
 
9
 
9
 from lxml.html.diff import htmldiff
10
 from lxml.html.diff import htmldiff
10
 
11
 
270
         for role in notifiable_roles:
271
         for role in notifiable_roles:
271
             logger.info(self, 'Sending email to {}'.format(role.user.email))
272
             logger.info(self, 'Sending email to {}'.format(role.user.email))
272
             to_addr = '{name} <{email}>'.format(name=role.user.display_name, email=role.user.email)
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
             #  INFO - D.A. - 2014-11-06
285
             #  INFO - D.A. - 2014-11-06
276
             # We do not use .format() here because the subject defined in the .ini file
286
             # We do not use .format() here because the subject defined in the .ini file
287
             message['Subject'] = subject
297
             message['Subject'] = subject
288
             message['From'] = self._get_sender(user)
298
             message['From'] = self._get_sender(user)
289
             message['To'] = to_addr
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
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
308
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
292
 
309
 
293
 
310