bugfix: only give points to unique users

no longer gives people extra points for having more tabs open
This commit is contained in:
Lili (Tlapka) 2022-09-30 12:01:33 +02:00
parent 351e612ede
commit 9ce16bb35e
1 changed files with 3 additions and 2 deletions

View File

@ -16,9 +16,10 @@ def give_points_to_chat(db):
url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/integrations/clients' url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/integrations/clients'
headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']} headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']}
r = requests.post(url, headers=headers) r = requests.post(url, headers=headers)
for user_object in r.json(): unique_users = list(set(map(lambda user_object: user_object["user"]["id"], r.json())))
for user_id in unique_users:
give_points_to_user(db, give_points_to_user(db,
user_object["user"]["id"], user_id,
current_app.config['POINTS_AMOUNT_GIVEN']) current_app.config['POINTS_AMOUNT_GIVEN'])
def send_chat(message): def send_chat(message):