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:
parent
f4db47d35d
commit
6734ae4d48
6 changed files with 15 additions and 13 deletions
|
@ -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 <ste.pigozzi@gmail.com>"]
|
||||
license = "AGPL-3.0+"
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1 +1 @@
|
|||
semantic = "5.9.1"
|
||||
semantic = "5.9.2"
|
||||
|
|
Loading…
Reference in a new issue