diff --git a/pyproject.toml b/pyproject.toml index 2623ae08..4f683256 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "royalnet" - version = "5.9.1" + version = "5.9.2" description = "A multipurpose bot and web framework" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" diff --git a/royalnet/backpack/commands/royalnetaliases.py b/royalnet/backpack/commands/royalnetaliases.py index 63c2f5e7..3fa88d48 100644 --- a/royalnet/backpack/commands/royalnetaliases.py +++ b/royalnet/backpack/commands/royalnetaliases.py @@ -14,7 +14,7 @@ class RoyalnetaliasesCommand(rc.Command): async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: if name := args.optional(0) is not None: - user = await User.find(alchemy=self.alchemy, session=data.session, alias=name) + user = await User.find(alchemy=self.alchemy, session=data.session, identifier=name) else: user = await data.get_author(error_if_none=True) diff --git a/royalnet/backpack/commands/royalnetroles.py b/royalnet/backpack/commands/royalnetroles.py index 6873b2c2..93ff1d96 100644 --- a/royalnet/backpack/commands/royalnetroles.py +++ b/royalnet/backpack/commands/royalnetroles.py @@ -14,7 +14,7 @@ class RoyalnetrolesCommand(rc.Command): async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: if name := args.optional(0) is not None: - user = await User.find(alchemy=self.alchemy, session=data.session, alias=name) + user = await User.find(alchemy=self.alchemy, session=data.session, identifier=name) else: user = await data.get_author(error_if_none=True) diff --git a/royalnet/backpack/tables/users.py b/royalnet/backpack/tables/users.py index c9887ef3..b785c0a6 100644 --- a/royalnet/backpack/tables/users.py +++ b/royalnet/backpack/tables/users.py @@ -37,16 +37,17 @@ class User: return Column(String) @classmethod - async def find(cls, alchemy, session, alias: Union[str, int]): - if isinstance(alias, str): - result = await ru.asyncify(session.query(alchemy.get(Alias)).filter_by(alias=alias.lower()).one_or_none) - elif isinstance(alias, int): - result = await ru.asyncify(session.query(alchemy.get(cls)).get, alias) + async def find(cls, alchemy, session, identifier: Union[str, int]): + if isinstance(identifier, str): + alias = await ru.asyncify(session.query(alchemy.get(Alias)).filter_by(alias=identifier.lower()).one_or_none) + if alias is None: + return None + else: + return alias.user + elif isinstance(identifier, int): + return await ru.asyncify(session.query(alchemy.get(cls)).get, identifier) else: raise TypeError("alias is of an invalid type.") - if result is not None: - result = result.user - return result def json(self) -> JSON: return { diff --git a/royalnet/constellation/api/apistar.py b/royalnet/constellation/api/apistar.py index 3bf8941c..4eb4154d 100644 --- a/royalnet/constellation/api/apistar.py +++ b/royalnet/constellation/api/apistar.py @@ -17,10 +17,10 @@ log = logging.getLogger(__name__) class ApiStar(PageStar, ABC): parameters: Dict[str, Dict[str, str]] = {} auth: Dict[str, bool] = {} + deprecated: Dict[str, bool] = {} tags: List[str] = [] - deprecated: bool = False async def page(self, request: Request) -> JSONResponse: if request.query_params: @@ -89,6 +89,7 @@ class ApiStar(PageStar, ABC): "summary": ru.strip_tabs(summary) if summary is not None else "", "description": ru.strip_tabs(description) if description is not None else "", "tags": self.tags, + "deprecated": self.deprecated.get(method.__name__, False), "security": [{"RoyalnetLoginToken": ["logged_in"]}] if self.auth.get(method.__name__) else [], "parameters": [{ "name": parameter_name, diff --git a/royalnet/version.py b/royalnet/version.py index 6c855539..62374c71 100644 --- a/royalnet/version.py +++ b/royalnet/version.py @@ -1 +1 @@ -semantic = "5.9.1" +semantic = "5.9.2"