Browse Source

fix(digests): Add List-ID header to digest emails. (#6215)

ted kaemming 7 years ago
parent
commit
57be0aebba
3 changed files with 11 additions and 4 deletions
  1. 1 0
      CHANGES
  2. 1 0
      src/sentry/plugins/sentry_mail/models.py
  3. 9 4
      tests/sentry/plugins/mail/tests.py

+ 1 - 0
CHANGES

@@ -4,6 +4,7 @@ Version 8.21 (Unreleased)
 - Ignore querystrings when looking up release artifacts
 - Add Visual Studio authentication provider for plugins.
 - Add "team" parameter to the project details API.
+- Added mailing list support (via ``List-Id`` header) to digest emails.
 
 Schema Changes
 ~~~~~~~~~~~~~~

+ 1 - 0
src/sentry/plugins/sentry_mail/models.py

@@ -249,6 +249,7 @@ class MailPlugin(NotificationPlugin):
                 template='sentry/emails/digests/body.txt',
                 html_template='sentry/emails/digests/body.html',
                 project=project,
+                reference=project,
                 type='notify.digest',
                 context=context,
                 send_to=[user_id],

+ 9 - 4
tests/sentry/plugins/mail/tests.py

@@ -247,8 +247,7 @@ class MailPluginTest(TestCase):
         ) == '[Rick & Morty] 1 new alert since Sept. 19, 2016, 1:02 a.m. UTC'
 
     @mock.patch.object(MailPlugin, 'notify', side_effect=MailPlugin.notify, autospec=True)
-    @mock.patch.object(MessageBuilder, 'send_async', autospec=True)
-    def test_notify_digest(self, send_async, notify):
+    def test_notify_digest(self, notify):
         project = self.event.project
         rule = project.rule_set.all()[0]
         digest = build_digest(
@@ -258,9 +257,15 @@ class MailPluginTest(TestCase):
                 event_to_record(self.event, (rule, )),
             ),
         )
-        self.plugin.notify_digest(project, digest)
-        assert send_async.call_count is 1
+
+        with self.tasks():
+            self.plugin.notify_digest(project, digest)
+
         assert notify.call_count is 0
+        assert len(mail.outbox) == 1
+
+        message = mail.outbox[0]
+        assert 'List-ID' in message.message()
 
     @mock.patch.object(MailPlugin, 'notify', side_effect=MailPlugin.notify, autospec=True)
     @mock.patch.object(MessageBuilder, 'send_async', autospec=True)