Skip to content

Commit

Permalink
Merge pull request #34 from yupix/refactory/meta
Browse files Browse the repository at this point in the history
Refactory/meta
  • Loading branch information
yupix authored Jan 18, 2023
2 parents 1cd6d66 + 255aecd commit 1c9d053
Show file tree
Hide file tree
Showing 61 changed files with 1,132 additions and 655 deletions.
50 changes: 45 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Added

- added new `ClientActions` class.
- added `avatar_color` property at `LiteUser` class.
- Note: Since avatar_color is deprecated in v13, only None is returned for v13 instances.
- added `un_renote` method at `ClientNoteActions` class.
Expand All @@ -20,15 +21,40 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- added `MuteActions` class.
- added `MuteUser` class.
- added `IMuteUser` class.
- added `AdminActions` class.
- added `ICustomEmojiLiteRequired` class.
- The following methods are added to the `AdminEmojiActions` class.
- `gets`
- `gets_remote`
- added some meta class.
- `ICPU`
- `IPolicies`
- `IAnnouncement`
- `IV12Features`
- `IV11Features`
- `IFeatures`
- `IV12AdminMeta`
- `ISharedAdminMeta`
- `ILiteV12Meta`
- `ILiteV11Meta`
- `IMetaCommonV12`
- `ICommonV11`
- `IMetaCommon`
- `ILiteMeta`
- `IV12Meta`
- `IMeta`
- `IAdminMeta`
- `Policies`
- `Features`
- `Meta`
- `AdminMeta`
- `CPU`
- `MetaCommon`
- `LiteMeta`
- added some federation class.
- `IFederationInstanceRequired`
- `IFederationInstance`
- `FederationInstance`

- added some notification classes.
- `Notification`
- `NotificationFollow`
Expand All @@ -47,15 +73,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- If you want to change the config, please use `Client.config.from_dict`.
- CustomEmoji now inherits PartialCustomEmoji.
- PartialCustomEmoji url has been changed to return `str | None` to match v13.
- For v13, the url is automatically generated. (Although it returns None by type, it never actually returns None.
## Removed

- Delete `get_user` method at `FollowRequestActions` class.
- AdminManager's `get_invite` method has been moved to `AdminActions.
- **BREAKING CHANGE** `ClientActions` has been changed to `ClientManager`
- **BREAKING CHANGE** Some paths will be changed as follows
- `manager.admin` -> `manager.admins`
- `manager.admin.manager` -> `manager.admins.admin`
- `actions.admin` -> `actions.admins`

## Fixed

- fixed `ChatMessage` model.
- For v13, the url is automatically generated. (Although it returns None by type, it never actually returns None.
- fixed `Chat` action.
- fixed `Chat` action.

## Removed

- Delete `get_user` method at `FollowRequestActions` class.
- removed some meta classes.
- `LiteInstanceMeta`
- `IInstanceMetaLite`
- `IInstanceFeatures`
- `IInstancePolicies`
- `InstanceMeta`

## [0.3.99] 2022-12-25
## Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MiPACはMisskey v11, 12, 13をサポートしているApi Wrapperです。
|name|version|supported|
|---|---|---|
|[Misskey Official](https://github.com/misskey-dev/misskey)|v13, v12, v11||
|[Ayuskey](https://github.com/teamblackcrystal/misskey)|latest||
|[Ayuskey](https://github.com/teamblackcrystal/misskey)|v5, v6||

## 使い方

Expand Down
4 changes: 2 additions & 2 deletions mipac/abstract/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from mipac.http import HTTPClient

if TYPE_CHECKING:
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager

__all__ = ('AbstractAction',)


class AbstractAction(ABC):
@abstractmethod
def __init__(self, session: HTTPClient, client: ClientActions):
def __init__(self, session: HTTPClient, client: ClientManager):
pass
4 changes: 2 additions & 2 deletions mipac/abstract/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from mipac.http import HTTPClient

if TYPE_CHECKING:
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager

__all__ = ('AbstractManager',)


class AbstractManager(ABC):
@abstractmethod
def __init__(self, *, session: HTTPClient, client: ClientActions):
def __init__(self, *, session: HTTPClient, client: ClientManager):
pass
2 changes: 1 addition & 1 deletion mipac/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .admin import *
from .admins import *
from .chart import *
from .chat import *
from .drive import *
Expand Down
File renamed without changes.
31 changes: 31 additions & 0 deletions mipac/actions/admins/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from mipac.abstract.action import AbstractAction
from mipac.http import HTTPClient, Route
from mipac.models.meta import AdminMeta
from mipac.types.meta import IAdminMeta

if TYPE_CHECKING:
from mipac.manager.client import ClientManager


class AdminActions(AbstractAction):
def __init__(self, *, session: HTTPClient, client: ClientManager):
self.__session = session
self.__client = client

async def get_meta(self, detail: bool = False) -> AdminMeta:
res: IAdminMeta = await self.__session.request(
Route('POST', '/api/admin/meta'),
json={'detail': detail},
auth=True,
lower=True,
)
return AdminMeta(res, client=self.__client)

async def get_invite(self) -> bool:
return bool(
await self.__session.request(Route('POST', '/api/admin/invite'))
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

if TYPE_CHECKING:
from mipac.http import HTTPClient
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager


class AdminEmojiActions(AbstractAction):
Expand All @@ -20,7 +20,7 @@ def __init__(
emoji_id: None | str = None,
*,
session: HTTPClient,
client: ClientActions
client: ClientManager
):
self.__emoji_id = emoji_id
self.__session = session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if TYPE_CHECKING:
from mipac.http import HTTPClient
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager


class AdminModeratorActions(AbstractAction):
Expand All @@ -16,10 +16,10 @@ def __init__(
user_id: str | None = None,
*,
session: HTTPClient,
client: ClientActions
client: ClientManager
):
self.__session: HTTPClient = session
self.__client: ClientActions = client
self.__client: ClientManager = client
self.__user_id: str | None = user_id

async def add(self, user_id: str | None = None) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions mipac/actions/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from mipac.models.chart import ActiveUsersChart, DriveChart

if TYPE_CHECKING:
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager


class ChartActions(AbstractAction):
def __init__(self, session: HTTPClient, client: ClientActions):
def __init__(self, session: HTTPClient, client: ClientManager):
self.__session = session
self.__client = client

Expand Down
6 changes: 3 additions & 3 deletions mipac/actions/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from mipac.util import check_multi_arg

if TYPE_CHECKING:
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager


class BaseChatAction(AbstractAction):
def __init__(
self,
session: HTTPClient,
client: ClientActions,
client: ClientManager,
*,
user_id: str | None = None,
message_id: str | None = None,
Expand Down Expand Up @@ -85,7 +85,7 @@ class ChatAction(BaseChatAction):
def __init__(
self,
session: HTTPClient,
client: ClientActions,
client: ClientManager,
*,
user_id: str | None = None,
message_id: str | None = None,
Expand Down
39 changes: 39 additions & 0 deletions mipac/actions/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Literal, overload

from mipac.abstract.action import AbstractAction
from mipac.http import HTTPClient, Route
from mipac.models.lite.meta import LiteMeta
from mipac.models.meta import Meta
from mipac.types.meta import ILiteMeta, IMeta

if TYPE_CHECKING:
from mipac.manager.client import ClientManager


class ClientActions(AbstractAction):
def __init__(self, *, session: HTTPClient, client: ClientManager) -> None:
self.__session: HTTPClient = session
self.__client: ClientManager = client

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

@overload
async def get_meta(self, detail: Literal[True] = ...) -> Meta:
...

async def get_meta(self, detail: bool = False):
params = {
'route': Route('POST', '/api/meta'),
'json': {'detail': detail},
'auth': True,
'lower': True,
}
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)
14 changes: 7 additions & 7 deletions mipac/actions/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from mipac.util import bool_to_string, remove_dict_empty

if TYPE_CHECKING:
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager

__all__ = ('DriveActions', 'FileActions', 'FolderActions')

Expand All @@ -21,10 +21,10 @@ def __init__(
file_id: str | None = None,
*,
session: HTTPClient,
client: ClientActions
client: ClientManager
) -> None:
self.__session: HTTPClient = session
self.__client: ClientActions = client
self.__client: ClientManager = client
self.__file_id = file_id

async def show_file(self, file_id: str | None, url: str | None) -> File:
Expand Down Expand Up @@ -172,11 +172,11 @@ def __init__(
folder_id: str | None = None,
*,
session: HTTPClient,
client: ClientActions
client: ClientManager
):
self.__folder_id = folder_id
self.__session: HTTPClient = session
self.__client: ClientActions = client
self.__client: ClientManager = client

async def create(self, name: str, parent_id: str | None = None) -> bool:
"""
Expand Down Expand Up @@ -269,9 +269,9 @@ async def get_files(


class DriveActions(AbstractAction):
def __init__(self, session: HTTPClient, client: ClientActions):
def __init__(self, session: HTTPClient, client: ClientManager):
self.__session: HTTPClient = session
self.__client: ClientActions = client
self.__client: ClientManager = client

async def get_folders(
self,
Expand Down
6 changes: 3 additions & 3 deletions mipac/actions/favorite.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if TYPE_CHECKING:
from mipac.http import HTTPClient
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager


class FavoriteActions(AbstractAction):
Expand All @@ -16,11 +16,11 @@ def __init__(
note_id: str | None = None,
*,
session: HTTPClient,
client: ClientActions
client: ClientManager
):
self.__note_id: str | None = note_id
self.__session: HTTPClient = session
self.__client: ClientActions = client
self.__client: ClientManager = client

async def add(self, note_id: str | None = None) -> bool:
note_id = note_id or self.__note_id
Expand Down
6 changes: 3 additions & 3 deletions mipac/actions/follow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

if TYPE_CHECKING:
from mipac.http import HTTPClient
from mipac.manager.client import ClientActions
from mipac.manager.client import ClientManager
from mipac.types.user import ILiteUser


Expand All @@ -20,7 +20,7 @@ def __init__(
user_id: str | None = None,
*,
session: HTTPClient,
client: ClientActions
client: ClientManager
):
self.__user_id: str | None = user_id
self.__session = session
Expand Down Expand Up @@ -90,7 +90,7 @@ def __init__(
user_id: str | None = None,
*,
session: HTTPClient,
client: ClientActions
client: ClientManager
):
self.__user_id: str | None = user_id
self.__session = session
Expand Down
Loading

0 comments on commit 1c9d053

Please sign in to comment.