def submit_ping_results(request): """Called by the client to submit the results of the addresses pinged.""" global nb_submited_requests, nb_submited_results client_addr = get_client_ip(request) logger.debug('submit_ping_results request: %s', request.json_body) # Check that token is valid. Always accept it even if it is bad # as otherwise this would block client Also, the "bad" token is # probably caused by a server problem, not people trying to push # wrong results. token = request.json_body.get('token') nick = request.json_body.get('userid') uuid = request.json_body.get('uuid') # Store results. results = request.json_body.get('results') if results is None: # FB: should return 400 client error raise HTTPBadRequest('No "results" field.') results.insert(0, client_addr) results.append("TOKEN=" + token) results.append("NICK=" + nick) results.append("UUID=" + uuid) resources.store_results(results) resources.store_known_pignable(results) nb_submited_requests += 1 nb_submited_results += len(results) # Update leaderboards if nick was passed. if nick is not None: resources.update_leaderboards(nick, results) return {'success': True}
def submit_ping_results(request): """Called by the client to submit the results of the addresses pinged.""" logger.debug('submit_ping_results request: %s', request.json_body) # Check that token is valid. token = request.json_body.get('token') if not resources.check_token(token): raise HTTPForbidden('Invalid or absent token value.') # Store results. results = request.json_body.get('results') if results is None: raise HTTPBadRequest('No "results" field.') resources.store_results(results) # Update leaderboards if userid was passed. userid = request.json_body.get('userid') if userid is not None: resources.update_leaderboards(userid, results) return {'success': True}