Skip to content

Commit

Permalink
feat: admin/show-usersでMeDetailedも返せるように
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Sep 25, 2023
1 parent fcc852b commit ab124b5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mipac/actions/admins/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from mipac.http import HTTPClient, Route
from mipac.models.admin import IndexStat, ModerationLog, ServerInfo, UserIP
from mipac.models.meta import AdminMeta
from mipac.models.user import UserDetailed
from mipac.models.user import MeDetailed, UserDetailed
from mipac.types.admin import IIndexStat, IModerationLog, IServerInfo, ITableStats, IUserIP
from mipac.types.meta import IAdminMeta, IUpdateMetaBody
from mipac.types.user import IUserDetailed
from mipac.types.user import IMeDetailed, IUserDetailed, is_me_detailed
from mipac.utils.cache import cache
from mipac.utils.format import convert_dict_keys_to_camel
from mipac.utils.pagination import Pagination
Expand Down Expand Up @@ -254,7 +254,7 @@ async def show_users(
origin: str = "combined",
username: str | None = None,
hostname: str | None = None,
) -> list[UserDetailed]:
) -> list[MeDetailed | UserDetailed]:
body = {
"limit": limit,
"offset": offset,
Expand All @@ -264,7 +264,10 @@ async def show_users(
"username": username,
"hostname": hostname,
}
res: list[IUserDetailed] = await self.__session.request(
res: list[IUserDetailed | IMeDetailed] = await self.__session.request(
Route("POST", "/api/admin/show-users"), auth=True, json=body
)
return [UserDetailed(i, client=self.__client) for i in res]


return [MeDetailed(i, client=self.__client) if is_me_detailed(i, config.account_id) else UserDetailed(i, client=self.__client) for i in res]

0 comments on commit ab124b5

Please sign in to comment.