Skip to content

Commit

Permalink
reviews: Retry Slack webhooks and add to Redis only when successful.
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
Simone Esposito committed Sep 2, 2016
1 parent c76948f commit d5476e5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions starpicker/reviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, review_id, text, rating=None, author=None):
self.text = text
self._rating = rating
self._author = author
self.is_new = R.sadd('starpicker:seen_review_ids', self.redis_key) == 1
self.is_new = not R.sismember('starpicker:seen_review_ids', self.redis_key)

@property
def redis_key(self):
Expand Down Expand Up @@ -76,7 +76,11 @@ def send_to_slack(self):
]
}

requests.post(config.SLACK_WEBHOOK_URL, json=body)
for webhook_url in config.SLACK_WEBHOOK_URLS:
r = requests.post(webhook_url, json=body)
r.raise_for_status()

R.sadd('starpicker:seen_review_ids', self.redis_key)


class TrustpilotReview(BaseReview):
Expand Down

0 comments on commit d5476e5

Please sign in to comment.