diff --git a/dnstwister/templates/email/report.html b/dnstwister/templates/email/report.html index c7b45e99..b16f23af 100644 --- a/dnstwister/templates/email/report.html +++ b/dnstwister/templates/email/report.html @@ -59,13 +59,13 @@

dnstwister report for {{ domain | domain_renderer }}

{% endfor %} -{% endif %} +{% endif %}{% if noisy_link %}

These emails exclude domains considered to be "noisy" - those that are either registered and unregistered constantly, or constantly change IP address. You can view a report of these domains at any time.

-

+{% endif %}

Unsubscribe

diff --git a/dnstwister/workers/email.py b/dnstwister/workers/email.py index ccbc4a4f..3b4e97c3 100644 --- a/dnstwister/workers/email.py +++ b/dnstwister/workers/email.py @@ -92,6 +92,10 @@ def process_sub(sub_id, detail): in updated] # Email + noisy_link = None + if feature_flags.enable_noisy_domains(): + noisy_link = 'https://dnstwister.report/email/{}/noisy'.format(sub_id) + body = email_tools.render_email( 'report.html', domain=domain, @@ -99,7 +103,7 @@ def process_sub(sub_id, detail): updated=updated, deleted=deleted, unsubscribe_link='https://dnstwister.report/email/unsubscribe/{}'.format(sub_id), - noisy_link='https://dnstwister.report/email/{}/noisy'.format(sub_id) + noisy_link=noisy_link ) # Mark as emailed to ensure we don't flood if there's an error after the diff --git a/tests/test_worker_emails.py b/tests/test_worker_emails.py index ceebf697..fbdbe567 100644 --- a/tests/test_worker_emails.py +++ b/tests/test_worker_emails.py @@ -292,6 +292,8 @@ def test_send_when_only_noisy_but_noisy_feature_off(capsys, monkeypatch): sub_data = repository.db.data['email_sub:{}'.format(sub_id)] workers.email.process_sub(sub_id, sub_data) - # We've not sent any emails as there were no changes (no IPs resolved at - # all). + # We have an email. assert len(emailer.sent_emails) == 1 + + # And there is no reference to noisy domains in the email. + assert 'noisy' not in emailer.sent_emails[0][2]