mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-28 18:21:00 +00:00
Implement Mastodon's v1/statuses/<id>/reblogged_by API endpoint (#551)
This commit is contained in:
parent
ba4414dbce
commit
96bc64fd01
2 changed files with 43 additions and 0 deletions
|
@ -91,6 +91,7 @@ urlpatterns = [
|
||||||
path("v1/statuses/<id>/favourited_by", statuses.favourited_by),
|
path("v1/statuses/<id>/favourited_by", statuses.favourited_by),
|
||||||
path("v1/statuses/<id>/reblog", statuses.reblog_status),
|
path("v1/statuses/<id>/reblog", statuses.reblog_status),
|
||||||
path("v1/statuses/<id>/unreblog", statuses.unreblog_status),
|
path("v1/statuses/<id>/unreblog", statuses.unreblog_status),
|
||||||
|
path("v1/statuses/<id>/reblogged_by", statuses.reblogged_by),
|
||||||
path("v1/statuses/<id>/bookmark", statuses.bookmark_status),
|
path("v1/statuses/<id>/bookmark", statuses.bookmark_status),
|
||||||
path("v1/statuses/<id>/unbookmark", statuses.unbookmark_status),
|
path("v1/statuses/<id>/unbookmark", statuses.unbookmark_status),
|
||||||
# Tags
|
# Tags
|
||||||
|
|
|
@ -246,6 +246,48 @@ def favourited_by(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@api_view.get
|
||||||
|
def reblogged_by(
|
||||||
|
request: HttpRequest,
|
||||||
|
id: str,
|
||||||
|
max_id: str | None = None,
|
||||||
|
since_id: str | None = None,
|
||||||
|
min_id: str | None = None,
|
||||||
|
limit: int = 20,
|
||||||
|
) -> ApiResponse[list[schemas.Account]]:
|
||||||
|
"""
|
||||||
|
View who reblogged a given status.
|
||||||
|
"""
|
||||||
|
post = post_for_id(request, id)
|
||||||
|
|
||||||
|
paginator = MastodonPaginator()
|
||||||
|
pager: PaginationResult[PostInteraction] = paginator.paginate(
|
||||||
|
post.interactions.filter(
|
||||||
|
type=PostInteraction.Types.boost,
|
||||||
|
state__in=PostInteractionStates.group_active(),
|
||||||
|
).select_related("identity"),
|
||||||
|
min_id=min_id,
|
||||||
|
max_id=max_id,
|
||||||
|
since_id=since_id,
|
||||||
|
limit=limit,
|
||||||
|
)
|
||||||
|
|
||||||
|
return PaginatingApiResponse(
|
||||||
|
[
|
||||||
|
schemas.Account.from_identity(
|
||||||
|
interaction.identity,
|
||||||
|
include_counts=False,
|
||||||
|
)
|
||||||
|
for interaction in pager.results
|
||||||
|
],
|
||||||
|
request=request,
|
||||||
|
include_params=[
|
||||||
|
"limit",
|
||||||
|
"id",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@scope_required("write:favourites")
|
@scope_required("write:favourites")
|
||||||
@api_view.post
|
@api_view.post
|
||||||
def reblog_status(request, id: str) -> schemas.Status:
|
def reblog_status(request, id: str) -> schemas.Status:
|
||||||
|
|
Loading…
Reference in a new issue