Skip to content

Commit

Permalink
Merge pull request #11 from caarmen/avoid-concurrent-withings-refresh…
Browse files Browse the repository at this point in the history
…-tokens

Prevent multiple concurrent requests to refresh a withings access token
  • Loading branch information
caarmen authored May 18, 2023
2 parents 57cb39e + 1aceb02 commit 91adec6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion withingsslack/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def withings_notification_webhook(
+ f"userid={userid}, startdate={startdate}, enddate={enddate}"
)
if last_processed_notification_per_user.get(userid, None) != (startdate, enddate):
last_processed_notification_per_user[userid] = (startdate, enddate)
try:
last_weight_data = withings_api.get_last_weight(
db,
Expand All @@ -153,7 +154,6 @@ def withings_notification_webhook(
else:
if last_weight_data:
slack.post_weight(last_weight_data)
last_processed_notification_per_user[userid] = (startdate, enddate)
else:
logging.info("Ignoring duplicate withings notification")
return Response(status_code=status.HTTP_204_NO_CONTENT)
Expand Down

0 comments on commit 91adec6

Please sign in to comment.