-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
from mipac.abc.action import AbstractAction | ||
from mipac.http import HTTPClient, Route | ||
from mipac.models.follow import FollowRequest | ||
from mipac.types.follow import IFollowRequest | ||
|
||
if TYPE_CHECKING: | ||
from mipac.manager.client import ClientActions | ||
|
||
|
||
class MyActions(AbstractAction): | ||
def __init__(self, session: HTTPClient, client: ClientActions): | ||
self.__session = session | ||
self.__client = client | ||
|
||
async def fetch_follow_requests(self): | ||
res: list[IFollowRequest] = await self.__session.request(Route('POST', '/api/following/requests/list'), auth=True, lower=True) | ||
return [FollowRequest(i, client=self.__client) for i in res] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
from mipac.abc.manager import AbstractManager | ||
from mipac.actions.my import MyActions | ||
from mipac.http import HTTPClient | ||
|
||
if TYPE_CHECKING: | ||
from mipac.manager.client import ClientActions | ||
|
||
|
||
class MyManager(AbstractManager): | ||
def __init__(self, *, session: HTTPClient, client: ClientActions): | ||
self.__session = session | ||
self.__client = client | ||
|
||
@property | ||
def action(self): | ||
return MyActions(session=self.__session, client=self.__client) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import annotations | ||
from typing import TYPE_CHECKING | ||
from mipac.models.lite.user import LiteUser | ||
from mipac.types.follow import IFollowRequest | ||
|
||
if TYPE_CHECKING: | ||
from mipac.manager.client import ClientActions | ||
|
||
class FollowRequest: | ||
def __init__(self, follow_request: IFollowRequest, *, client: ClientActions) -> None: | ||
self.__follow_request = follow_request | ||
self.__client = client | ||
|
||
@property | ||
def id(self) -> str: | ||
return self.__follow_request['id'] | ||
|
||
@property | ||
def follower(self) -> LiteUser: | ||
return LiteUser(self.__follow_request['follower']) | ||
|
||
@property | ||
def followee(self) -> LiteUser: | ||
return LiteUser(self.__follow_request['followee']) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from typing import TypedDict | ||
|
||
from mipac.types.user import IUserLite | ||
|
||
|
||
class IFollowRequest(TypedDict): | ||
id: str | ||
follower: IUserLite | ||
followee: IUserLite |