.BANCHO. /api/v1/isOnline now supports both userid and username

This commit is contained in:
Nyo 2016-08-21 20:32:17 +02:00
parent 7910291b77
commit 8f79e58185

View File

@ -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