Projet

Général

Profil

0001-add-unsubscription-link-in-mail-headers-19579.patch

Serghei Mihai (congés, retour 15/05), 27 octobre 2017 14:12

Télécharger (1,82 ko)

Voir les différences:

Subject: [PATCH] add unsubscription link in mail headers (#19579)

 corbo/utils.py         | 1 +
 tests/test_emailing.py | 1 +
 2 files changed, 2 insertions(+)
corbo/utils.py
60 60
                                           'identifier': dest})
61 61
        unsubscribe_link = urlparse.urljoin(settings.SITE_BASE_URL, reverse(
62 62
            'unsubscribe', kwargs={'unsubscription_token': unsubscribe_token}))
63
        message.set_headers({'List-Unsubscribe': '<%s>' % unsubscribe_link})
63 64
        message.html = orig_html.replace(UNSUBSCRIBE_LINK_PLACEHOLDER, unsubscribe_link)
64 65
        message.text = orig_text.replace(UNSUBSCRIBE_LINK_PLACEHOLDER, unsubscribe_link)
65 66

  
tests/test_emailing.py
135 135
                index = i*subscriptions_number+counter
136 136
                signature = urllib.unquote(re.findall('/unsubscribe/(.*)"', mail.outbox[index].html)[0])
137 137
                unsubscription_link = reverse('unsubscribe', kwargs={'unsubscription_token': signature})
138
                assert mail.outbox[index]._headers['List-Unsubscribe'] == '<http://localhost%s>' % unsubscription_link
138 139
                assert unsubscription_link in mail.outbox[index].html
139 140
                assert unsubscription_link in mail.outbox[index].text
140 141
                assert unsubscription_link_sentinel != unsubscription_link
141
-