|
@@ -182,6 +182,24 @@ class EmailNotifier(object):
|
182
|
182
|
self._smtp_config = smtp_config
|
183
|
183
|
self._global_config = global_config
|
184
|
184
|
|
|
185
|
+ def _get_sender(self, user: User=None) -> str:
|
|
186
|
+ """
|
|
187
|
+ Return sender string like "Bob Dylan
|
|
188
|
+ (via Tracim) <notification@mail.com>"
|
|
189
|
+ :param user: user to extract display name
|
|
190
|
+ :return: sender string
|
|
191
|
+ """
|
|
192
|
+ if user is None:
|
|
193
|
+ return '{0} <{1}>'.format(
|
|
194
|
+ self._global_config.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL,
|
|
195
|
+ self._global_config.EMAIL_NOTIFICATION_FROM_EMAIL,
|
|
196
|
+ )
|
|
197
|
+
|
|
198
|
+ return '{0} ({1}) <{2}>'.format(
|
|
199
|
+ user.display_name,
|
|
200
|
+ _('via Tracim'),
|
|
201
|
+ self._global_config.EMAIL_NOTIFICATION_FROM_EMAIL,
|
|
202
|
+ )
|
185
|
203
|
|
186
|
204
|
def notify_content_update(self, event_actor_id: int, event_content_id: int):
|
187
|
205
|
"""
|
|
@@ -233,10 +251,7 @@ class EmailNotifier(object):
|
233
|
251
|
|
234
|
252
|
message = MIMEMultipart('alternative')
|
235
|
253
|
message['Subject'] = subject
|
236
|
|
- message['From'] = '{0} <{1}>'.format(
|
237
|
|
- self._global_config.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL,
|
238
|
|
- self._global_config.EMAIL_NOTIFICATION_FROM_EMAIL,
|
239
|
|
- )
|
|
254
|
+ message['From'] = self._get_sender(user)
|
240
|
255
|
message['To'] = to_addr
|
241
|
256
|
|
242
|
257
|
body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
|