1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

publish: 5.9.2

This commit is contained in:
Steffo 2020-06-22 19:19:01 +02:00
parent f4db47d35d
commit 6734ae4d48
Signed by: steffo
GPG key ID: 896A80F55F7C97F0
6 changed files with 15 additions and 13 deletions

View file

@ -5,7 +5,7 @@
[tool.poetry] [tool.poetry]
name = "royalnet" name = "royalnet"
version = "5.9.1" version = "5.9.2"
description = "A multipurpose bot and web framework" description = "A multipurpose bot and web framework"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"] authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0+" license = "AGPL-3.0+"

View file

@ -14,7 +14,7 @@ class RoyalnetaliasesCommand(rc.Command):
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
if name := args.optional(0) is not 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: else:
user = await data.get_author(error_if_none=True) user = await data.get_author(error_if_none=True)

View file

@ -14,7 +14,7 @@ class RoyalnetrolesCommand(rc.Command):
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
if name := args.optional(0) is not 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: else:
user = await data.get_author(error_if_none=True) user = await data.get_author(error_if_none=True)

View file

@ -37,16 +37,17 @@ class User:
return Column(String) return Column(String)
@classmethod @classmethod
async def find(cls, alchemy, session, alias: Union[str, int]): async def find(cls, alchemy, session, identifier: Union[str, int]):
if isinstance(alias, str): if isinstance(identifier, str):
result = await ru.asyncify(session.query(alchemy.get(Alias)).filter_by(alias=alias.lower()).one_or_none) alias = await ru.asyncify(session.query(alchemy.get(Alias)).filter_by(alias=identifier.lower()).one_or_none)
elif isinstance(alias, int): if alias is None:
result = await ru.asyncify(session.query(alchemy.get(cls)).get, alias) return None
else:
return alias.user
elif isinstance(identifier, int):
return await ru.asyncify(session.query(alchemy.get(cls)).get, identifier)
else: else:
raise TypeError("alias is of an invalid type.") raise TypeError("alias is of an invalid type.")
if result is not None:
result = result.user
return result
def json(self) -> JSON: def json(self) -> JSON:
return { return {

View file

@ -17,10 +17,10 @@ log = logging.getLogger(__name__)
class ApiStar(PageStar, ABC): class ApiStar(PageStar, ABC):
parameters: Dict[str, Dict[str, str]] = {} parameters: Dict[str, Dict[str, str]] = {}
auth: Dict[str, bool] = {} auth: Dict[str, bool] = {}
deprecated: Dict[str, bool] = {}
tags: List[str] = [] tags: List[str] = []
deprecated: bool = False
async def page(self, request: Request) -> JSONResponse: async def page(self, request: Request) -> JSONResponse:
if request.query_params: if request.query_params:
@ -89,6 +89,7 @@ class ApiStar(PageStar, ABC):
"summary": ru.strip_tabs(summary) if summary is not None else "", "summary": ru.strip_tabs(summary) if summary is not None else "",
"description": ru.strip_tabs(description) if description is not None else "", "description": ru.strip_tabs(description) if description is not None else "",
"tags": self.tags, "tags": self.tags,
"deprecated": self.deprecated.get(method.__name__, False),
"security": [{"RoyalnetLoginToken": ["logged_in"]}] if self.auth.get(method.__name__) else [], "security": [{"RoyalnetLoginToken": ["logged_in"]}] if self.auth.get(method.__name__) else [],
"parameters": [{ "parameters": [{
"name": parameter_name, "name": parameter_name,

View file

@ -1 +1 @@
semantic = "5.9.1" semantic = "5.9.2"