2023-03-09 13:36:24 -08:00
|
|
|
from django.http import HttpRequest
|
|
|
|
from hatchway import api_view
|
|
|
|
|
2023-03-11 10:17:20 -08:00
|
|
|
from activities.models import Post
|
|
|
|
from activities.services import TimelineService
|
2023-03-09 13:36:24 -08:00
|
|
|
from api import schemas
|
|
|
|
from api.decorators import scope_required
|
2023-03-11 10:17:20 -08:00
|
|
|
from api.pagination import MastodonPaginator, PaginatingApiResponse, PaginationResult
|
2023-03-09 13:36:24 -08:00
|
|
|
|
|
|
|
|
|
|
|
@scope_required("read:bookmarks")
|
|
|
|
@api_view.get
|
|
|
|
def bookmarks(
|
|
|
|
request: HttpRequest,
|
|
|
|
max_id: str | None = None,
|
|
|
|
since_id: str | None = None,
|
|
|
|
min_id: str | None = None,
|
|
|
|
limit: int = 20,
|
|
|
|
) -> list[schemas.Status]:
|
2023-03-11 10:17:20 -08:00
|
|
|
queryset = TimelineService(request.identity).bookmarks()
|
|
|
|
paginator = MastodonPaginator()
|
|
|
|
pager: PaginationResult[Post] = paginator.paginate(
|
|
|
|
queryset,
|
|
|
|
min_id=min_id,
|
|
|
|
max_id=max_id,
|
|
|
|
since_id=since_id,
|
|
|
|
limit=limit,
|
|
|
|
)
|
|
|
|
return PaginatingApiResponse(
|
|
|
|
schemas.Status.map_from_post(pager.results, request.identity),
|
|
|
|
request=request,
|
|
|
|
include_params=["limit"],
|
|
|
|
)
|