Skip to content

Commit

Permalink
Noisy link in email conditional on the feature being enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismyrobot committed Jan 20, 2018
1 parent e75e3a5 commit f7ccd92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dnstwister/templates/email/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ <h1>dnstwister report for <strong>{{ domain | domain_renderer }}</strong></h1>
</td>
</tr>{% endfor %}
</tbody>
</table>{% endif %}
</table>{% endif %}{% if noisy_link %}
<p>
These emails <strong>exclude</strong> domains considered to be "noisy" -
those that are either registered and unregistered constantly, or
constantly change IP address. <a href="{{ noisy_link }}">You can view a
report of these domains at any time.</a>
</p>
<p>
{% endif %}<p>
<a href="{{ unsubscribe_link }}">Unsubscribe</a>
</p>
6 changes: 5 additions & 1 deletion dnstwister/workers/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,18 @@ 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,
new=new,
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
Expand Down
6 changes: 4 additions & 2 deletions tests/test_worker_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit f7ccd92

Please sign in to comment.