chore: NoteのVisibilityを共通の型に

pull/82/head
yupix 1 year ago
parent e3ba0b45bc
commit b998a0a84a
No known key found for this signature in database
GPG Key ID: 2FF705F5C56D9C06

@ -9,7 +9,7 @@ from mipac.http import HTTPClient, Route
from mipac.models.drive import File from mipac.models.drive import File
from mipac.models.note import Note, NoteReaction, NoteState, NoteTranslateResult from mipac.models.note import Note, NoteReaction, NoteState, NoteTranslateResult
from mipac.models.poll import MiPoll, Poll from mipac.models.poll import MiPoll, Poll
from mipac.types.note import ICreatedNote, INote, INoteState, INoteTranslateResult from mipac.types.note import ICreatedNote, INote, INoteState, INoteTranslateResult, INoteVisibility
from mipac.utils.cache import cache from mipac.utils.cache import cache
from mipac.utils.format import remove_dict_empty from mipac.utils.format import remove_dict_empty
from mipac.utils.pagination import Pagination from mipac.utils.pagination import Pagination
@ -23,7 +23,7 @@ __all__ = ['NoteActions']
def create_note_body( def create_note_body(
content: str | None = None, content: str | None = None,
visibility: Literal['public', 'home', 'followers', 'specified'] = 'public', visibility: INoteVisibility = 'public',
visible_user_ids: list[str] | None = None, visible_user_ids: list[str] | None = None,
cw: str | None = None, cw: str | None = None,
local_only: bool = False, local_only: bool = False,
@ -227,7 +227,7 @@ class ClientNoteActions(AbstractAction):
async def reply( async def reply(
self, self,
content: str | None = None, content: str | None = None,
visibility: Literal['public', 'home', 'followers', 'specified'] = 'public', visibility: INoteVisibility = 'public',
visible_user_ids: list[str] | None = None, visible_user_ids: list[str] | None = None,
cw: str | None = None, cw: str | None = None,
local_only: bool = False, local_only: bool = False,
@ -262,7 +262,7 @@ class ClientNoteActions(AbstractAction):
async def create_quote( async def create_quote(
self, self,
content: str | None = None, content: str | None = None,
visibility: Literal['public', 'home', 'followers', 'specified'] = 'public', visibility: INoteVisibility = 'public',
visible_user_ids: list[str] | None = None, visible_user_ids: list[str] | None = None,
cw: str | None = None, cw: str | None = None,
local_only: bool = False, local_only: bool = False,
@ -280,7 +280,7 @@ class ClientNoteActions(AbstractAction):
---------- ----------
content: str | None, default=None content: str | None, default=None
text text
visibility: Literal['public', 'home', 'followers', 'specified'], default='public' visibility: INoteVisibility, default='public'
Disclosure range Disclosure range
visible_user_ids: list[str] | None, default=None visible_user_ids: list[str] | None, default=None
List of users to be published List of users to be published
@ -363,7 +363,7 @@ class NoteActions(ClientNoteActions):
async def send( async def send(
self, self,
content: str | None = None, content: str | None = None,
visibility: Literal['public', 'home', 'followers', 'specified'] = 'public', visibility: INoteVisibility = 'public',
visible_user_ids: list[str] | None = None, visible_user_ids: list[str] | None = None,
cw: str | None = None, cw: str | None = None,
local_only: bool = False, local_only: bool = False,
@ -383,7 +383,7 @@ class NoteActions(ClientNoteActions):
---------- ----------
content : str | None, default=None content : str | None, default=None
投稿する内容 投稿する内容
visibility : Literal['public', 'home', 'followers', 'specified'], optional visibility : INoteVisibility, optional
公開範囲, by default "public" 公開範囲, by default "public"
Enum: "public" "home" "followers" "specified" Enum: "public" "home" "followers" "specified"
visible_user_ids : list[str] | None, optional visible_user_ids : list[str] | None, optional

@ -107,7 +107,7 @@ class PartialNote(Generic[T]):
return self._note['user_id'] return self._note['user_id']
@property @property
def visibility(self,) -> Literal['public', 'home', 'followers', 'specified']: def visibility(self,) -> INoteVisibility:
return self._note['visibility'] return self._note['visibility']
@property @property

@ -7,6 +7,7 @@ from .user import ILiteUser
T = TypeVar('T') T = TypeVar('T')
INoteVisibility = Literal['public', 'home', 'followers', 'specified']
class INoteState(TypedDict): class INoteState(TypedDict):
is_favorited: bool is_favorited: bool
@ -70,7 +71,7 @@ class IPartialNote(TypedDict):
text: str | None text: str | None
user: ILiteUser user: ILiteUser
user_id: str user_id: str
visibility: Literal['public', 'home', 'followers', 'specified'] visibility: INoteVisibility
tags: NotRequired[list[str]] # タグがついてないとbodyに存在しない tags: NotRequired[list[str]] # タグがついてないとbodyに存在しない

Loading…
Cancel
Save