Browse Source

Add List-Unsubscribe-Post email header

pull/313/head
Pēteris Caune 5 years ago
parent
commit
f7496fb8cf
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 12 additions and 2 deletions
  1. +5
    -1
      hc/accounts/models.py
  2. +1
    -0
      hc/api/tests/test_notify.py
  3. +1
    -0
      hc/api/tests/test_sendreports.py
  4. +5
    -1
      hc/api/transports.py

+ 5
- 1
hc/accounts/models.py View File

@ -174,7 +174,11 @@ class Profile(models.Model):
unsub_url = self.reports_unsub_url() unsub_url = self.reports_unsub_url()
headers = {"List-Unsubscribe": "<%s>" % unsub_url, "X-Bounce-Url": unsub_url}
headers = {
"List-Unsubscribe": "<%s>" % unsub_url,
"X-Bounce-Url": unsub_url,
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
}
ctx = { ctx = {
"checks": checks, "checks": checks,


+ 1
- 0
hc/api/tests/test_notify.py View File

@ -274,6 +274,7 @@ class NotifyTestCase(BaseTestCase):
self.assertEqual(email.to[0], "[email protected]") self.assertEqual(email.to[0], "[email protected]")
self.assertTrue("X-Bounce-Url" in email.extra_headers) self.assertTrue("X-Bounce-Url" in email.extra_headers)
self.assertTrue("List-Unsubscribe" in email.extra_headers) self.assertTrue("List-Unsubscribe" in email.extra_headers)
self.assertTrue("List-Unsubscribe-Post" in email.extra_headers)
def test_email_transport_handles_json_value(self): def test_email_transport_handles_json_value(self):
payload = {"value": "[email protected]", "up": True, "down": True} payload = {"value": "[email protected]", "up": True, "down": True}


+ 1
- 0
hc/api/tests/test_sendreports.py View File

@ -46,6 +46,7 @@ class SendReportsTestCase(BaseTestCase):
email = mail.outbox[0] email = mail.outbox[0]
self.assertTrue("List-Unsubscribe" in email.extra_headers) self.assertTrue("List-Unsubscribe" in email.extra_headers)
self.assertTrue("List-Unsubscribe-Post" in email.extra_headers)
def test_it_obeys_next_report_date(self): def test_it_obeys_next_report_date(self):
self.profile.next_report_date = now() + td(days=1) self.profile.next_report_date = now() + td(days=1)


+ 5
- 1
hc/api/transports.py View File

@ -61,7 +61,11 @@ class Email(Transport):
unsub_link = self.channel.get_unsub_link() unsub_link = self.channel.get_unsub_link()
headers = {"X-Bounce-Url": bounce_url, "List-Unsubscribe": "<%s>" % unsub_link}
headers = {
"X-Bounce-Url": bounce_url,
"List-Unsubscribe": "<%s>" % unsub_link,
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
}
try: try:
# Look up the sorting preference for this email address # Look up the sorting preference for this email address


Loading…
Cancel
Save