Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Merge pull request #4532 from gratipay/is-suspicious-null
Browse files Browse the repository at this point in the history
Don't send an email when initially setting is_suspicious to false
  • Loading branch information
rohitpaulk authored Jun 24, 2017
2 parents 2e55453 + 144cecb commit f948d15
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions www/~/%username/toggle-is-suspicious.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ to = request.body.get('to')
if not to in ('true', 'false', None):
raise Response(400)

participant = get_participant(state, restrict=True)
was = participant.is_suspicious

with website.db.get_cursor() as c:
if to is None:
is_suspicious = website.db.one("""
Expand All @@ -36,14 +39,15 @@ with website.db.get_cursor() as c:
action='set', values=dict(is_suspicious=is_suspicious)
))

# send an email
# send an email if the prior is_suspicious was not None
participant = get_participant(state, restrict=True)
status = 'true' if is_suspicious else 'false'
website.app.email_queue.put( participant
, 'suspicious-'+status
, include_unsubscribe=False
, _user_initiated=False
)
if was is not None:
website.app.email_queue.put( participant
, 'suspicious-'+status
, include_unsubscribe=False
, _user_initiated=False
)

[---] application/json via json_dump
{"is_suspicious": is_suspicious}

0 comments on commit f948d15

Please sign in to comment.