2019-11-11 08:56:08 +00:00
|
|
|
from starlette.requests import Request
|
|
|
|
from starlette.responses import *
|
2019-11-28 01:30:40 +00:00
|
|
|
from royalnet.constellation import *
|
2019-11-11 08:56:08 +00:00
|
|
|
from royalnet.utils import *
|
2019-11-28 01:30:40 +00:00
|
|
|
from royalnet.backpack.tables import *
|
2020-02-09 18:12:34 +00:00
|
|
|
from royalnet.constellation.api import *
|
2019-11-11 08:56:08 +00:00
|
|
|
|
|
|
|
|
2020-02-09 18:12:34 +00:00
|
|
|
class ApiUserGetStar(ApiStar):
|
|
|
|
path = "/api/user/get/v1"
|
2019-11-11 08:56:08 +00:00
|
|
|
|
2020-02-09 18:12:34 +00:00
|
|
|
async def api(self, data: ApiData) -> dict:
|
|
|
|
user_id_str = data["id"]
|
2019-11-11 08:56:08 +00:00
|
|
|
try:
|
2020-02-09 18:12:34 +00:00
|
|
|
user_id = int(user_id_str)
|
2019-11-11 08:56:08 +00:00
|
|
|
except (ValueError, TypeError):
|
2020-02-09 18:12:34 +00:00
|
|
|
raise InvalidParameterError("'id' is not a valid int.")
|
|
|
|
user: User = await asyncify(data.session.query(self.alchemy.get(User)).get, user_id)
|
2019-11-11 08:56:08 +00:00
|
|
|
if user is None:
|
2020-02-09 18:12:34 +00:00
|
|
|
raise NotFoundError("No such user.")
|
|
|
|
return user.json()
|