Skip to content

Commit

Permalink
feat: Metaを最新のMisskeyに合わせて修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Oct 3, 2023
1 parent 425f843 commit b53ebab
Show file tree
Hide file tree
Showing 6 changed files with 454 additions and 485 deletions.
15 changes: 2 additions & 13 deletions mipac/actions/admins/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from mipac.abstract.action import AbstractAction
from mipac.config import config
from mipac.errors.base import NotSupportVersion, NotSupportVersionText, ParameterError
from mipac.errors.base import ParameterError
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 MeDetailed, UserDetailed
from mipac.models.meta import AdminMeta
from mipac.types.admin import IIndexStat, IModerationLog, IServerInfo, ITableStats, IUserIP
from mipac.types.meta import IAdminMeta, IUpdateMetaBody
from mipac.types.user import IMeDetailed, IUserDetailed, is_me_detailed
Expand Down Expand Up @@ -44,8 +44,6 @@ async def vacuum(self, full: bool = False, analyze: bool = False) -> bool:
)

async def update_user_note(self, user_id: str, text: str) -> bool:
if config.use_version < 12:
raise NotSupportVersion(NotSupportVersionText)
body = {"userId": user_id, "text": text}
return bool(
await self.__session.request(
Expand Down Expand Up @@ -153,9 +151,6 @@ async def get_moderation_logs(
until_id: str | None = None,
get_all: bool = False,
) -> AsyncGenerator[ModerationLog, None]:
if config.use_version < 12:
raise NotSupportVersion(NotSupportVersionText)

if limit > 100:
raise ParameterError("limit must be less than 100")

Expand Down Expand Up @@ -191,9 +186,6 @@ async def send_email(self, to: str, subject: str, text: str) -> bool:
)

async def resolve_abuse_user_report(self, report_id: str, forward: bool = False) -> bool:
if config.use_version < 12:
raise NotSupportVersion(NotSupportVersionText)

body = {"reportId": report_id, "forward": forward}
return bool(
await self.__session.request(
Expand Down Expand Up @@ -228,9 +220,6 @@ async def get_index_stats(self) -> list[IndexStat]:
return [IndexStat(i) for i in res]

async def get_user_ips(self, user_id: str) -> list[UserIP]:
if config.use_version < 12:
raise NotSupportVersion(NotSupportVersionText)

res: list[IUserIP] = await self.__session.request(
Route("POST", "/api/admin/get-user-ips"),
auth=True,
Expand Down
10 changes: 5 additions & 5 deletions mipac/actions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from mipac.errors.base import ParameterError
from mipac.http import HTTPClient, Route
from mipac.models.announcement import Announcement
from mipac.models.lite.meta import LiteMeta
from mipac.models.lite.meta import PartialMeta
from mipac.models.meta import Meta
from mipac.types.announcement import IAnnouncement
from mipac.types.meta import ILiteMeta, IMeta
from mipac.types.meta import IMeta, IPartialMeta
from mipac.utils.pagination import Pagination

if TYPE_CHECKING:
Expand All @@ -22,7 +22,7 @@ def __init__(self, *, session: HTTPClient, client: ClientManager) -> None:
self.__client: ClientManager = client

@overload
async def get_meta(self, detail: Literal[False] = ...) -> LiteMeta:
async def get_meta(self, detail: Literal[False] = ...) -> PartialMeta:
...

@overload
Expand All @@ -39,8 +39,8 @@ async def get_meta(self, detail: bool = False):
if detail is True:
meta: IMeta = await self.__session.request(**params)
return Meta(meta, client=self.__client)
lite_meta: ILiteMeta = await self.__session.request(**params)
return LiteMeta(lite_meta, client=self.__client)
lite_meta: IPartialMeta = await self.__session.request(**params)
return PartialMeta(lite_meta, client=self.__client)

async def get_announcements(
self,
Expand Down
7 changes: 2 additions & 5 deletions mipac/actions/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mipac.http import Route
from mipac.models.emoji import CustomEmoji
from mipac.models.note import NoteReaction
from mipac.types.meta import ILiteMeta
from mipac.types.meta import IPartialMeta
from mipac.types.note import INoteReaction
from mipac.utils.format import remove_dict_empty

Expand Down Expand Up @@ -68,10 +68,7 @@ async def get_reaction(
return [NoteReaction(i, client=self.__client) for i in res]

async def get_emoji_list(self) -> list[CustomEmoji]:
if config.use_version >= 13:
raise NotSupportVersion("Misskey v13以降では使用できません")

data: ILiteMeta = await self.__session.request(
data: IPartialMeta = await self.__session.request(
Route("GET", "/api/meta"),
json={"detail": False},
auth=True,
Expand Down
Loading

0 comments on commit b53ebab

Please sign in to comment.