def deauth_users_endpoint(): """disables users that were sent an auth token but did not ack it in time""" if not config.DEBUG: limit_to_localhost() app.rq_fast.enqueue(scan_for_deauthed_users) return jsonify(status='ok')
def dbstats_api(): """internal endpoint used to retrieve the number of db connections""" if not config.DEBUG: limit_to_localhost() return jsonify(status='ok', stats=sqlalchemy_pool_status() ) # cant be async, used by the reboot script
def delete_user_data_endpoint(): """endpoint used to delete all of a users data""" #disabling this function as its too risky abort(403) if not config.DEBUG: limit_to_localhost() payload = request.get_json(silent=True) user_id = payload.get('user_id', None) are_u_sure = payload.get('are_u_sure', False) delete_all_user_data(user_id, are_u_sure) return jsonify(status='ok')
def get_rq_q_length_endpoint(): # TODO remove me later if not config.DEBUG: limit_to_localhost() from rq import Queue for queue_name in [ 'tippicserver-%s-fast' % config.DEPLOYMENT_ENV, 'tippicserver-%s-slow' % config.DEPLOYMENT_ENV ]: q = Queue(queue_name, connection=app.redis) print('there are currently %s jobs in the %s queue' % (q.count, queue_name)) gauge_metric('rq_queue_len', q.count, 'queue_name:%s' % queue_name) return jsonify(status='ok')
def skip_picture_endpoint(): """advances current_picture_index""" if not config.DEBUG: limit_to_localhost() try: payload = request.get_json(silent=True) skip_by = payload.get('skip_by', 1) except Exception as e: print(e) raise InvalidUsage('bad-request') else: skip_picture_wait(skip_by) increment_metric('skip-picture-wait') return jsonify(status='ok')
def user_phone_number_blacklist_endpoint(): """blacklist a number""" if not config.DEBUG: limit_to_localhost() try: payload = request.get_json(silent=True) phone_number = payload.get('phone-number', None) if phone_number is None: print('user_phone_number_blacklist_endpoint: user_phone: %s' % phone_number) raise InvalidUsage('bad-request') except Exception as e: print(e) raise InvalidUsage('bad-request') if not blacklist_phone_number(phone_number): raise InternalError('cant blacklist number') return jsonify(status='ok')
def balance_api(): """endpoint used to get the current balance of the seed and channels""" if not config.DEBUG: limit_to_localhost() base_seed, channel_seeds = ssm.get_stellar_credentials() balance = {'base_seed': {}, 'channel_seeds': {}} from kin import Keypair kp = Keypair() balance['base_seed']['kin'] = get_kin_balance( kp.address_from_seed(base_seed)) index = 0 for channel in channel_seeds: # seeds only need to carry XLMs balance['channel_seeds'][index] = {'kin': 0} balance['channel_seeds'][index]['kin'] = get_kin_balance( kp.address_from_seed(channel)) index = index + 1 return jsonify(status='ok', balance=balance)
def total_kins_endpoint(): if not config.DEBUG: limit_to_localhost() return jsonify(status='ok', total=get_tx_totals())
def reregister_users_endpoint(): if not config.DEBUG: limit_to_localhost() # app.rq_slow.enqueue(re_register_all_users) return jsonify(status='ok')
def users_unauthed_endpoint(): """get the list of userids that are not authenticated""" if not config.DEBUG: limit_to_localhost() return jsonify(user_ids=get_unauthed_users())