.BANCHO. /api/v1/isOnline now supports both userid and username
This commit is contained in:
parent
7910291b77
commit
8f79e58185
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user