From 8f79e581857b09298eca8727639e0a6fe66696d3 Mon Sep 17 00:00:00 2001 From: Nyo Date: Sun, 21 Aug 2016 20:32:17 +0200 Subject: [PATCH] .BANCHO. /api/v1/isOnline now supports both userid and username --- handlers/apiIsOnlineHandler.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/handlers/apiIsOnlineHandler.py b/handlers/apiIsOnlineHandler.py index 9664868..c630660 100644 --- a/handlers/apiIsOnlineHandler.py +++ b/handlers/apiIsOnlineHandler.py @@ -9,12 +9,19 @@ def GETApiIsOnline(): data = {"message": "unknown error"} try: # Check arguments - if "u" not in bottle.request.query: + if "u" not in bottle.request.query and "id" not in bottle.request.query: raise exceptions.invalidArgumentsException() # Get online staus - username = bottle.request.query["u"] - data["result"] = True if glob.tokens.getTokenFromUsername(username) != None else False + if "u" in bottle.request.query: + username = bottle.request.query["u"] + data["result"] = True if glob.tokens.getTokenFromUsername(username) != None else False + else: + try: + userID = int(bottle.request.query["id"]) + data["result"] = True if glob.tokens.getTokenFromUserID(userID) != None else False + except: + raise exceptions.invalidArgumentsException() # Status code and message statusCode = 200