Skip to content

Commit

Permalink
chore: get_childrenを普通のメソッドに
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Nov 24, 2023
1 parent f77afff commit 8c51ba2
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions mipac/actions/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,34 @@ async def un_renote(self, note_id: str | None = None) -> bool:
)
return res

@cache(group="get_note_children")
async def get_children(
self,
limit: int = 100,
since_id: str | None = None,
untilId: str | None = None,
note_id: str | None = None,
get_all: bool = True,
) -> AsyncGenerator[Note, None]:
) -> list[Note]:
if limit > 100:
raise ParameterError("limit は100以下である必要があります")

if get_all:
limit = 100
note_id = note_id or self._note_id

if note_id is None:
raise ParameterError("note_id is required")

data = {
"noteId": note_id,
"limit": limit,
"sinceId": since_id,
"untilId": untilId,
}

notes: list[INote] = await self._session.request(
Route("POST", "/api/notes/children"), json=data
)
return [Note(note, self._client) for note in notes]


note_id = note_id or self._note_id

Expand Down

0 comments on commit 8c51ba2

Please sign in to comment.