Implement /api/v1/tags/<hashtag> endpoint

pull/554/head
Christof Dorner 2023-04-06 22:35:31 +02:00
rodzic 161ff745f8
commit f576c913a9
2 zmienionych plików z 17 dodań i 0 usunięć

Wyświetl plik

@ -96,6 +96,7 @@ urlpatterns = [
path("v1/statuses/<id>/unbookmark", statuses.unbookmark_status),
# Tags
path("v1/followed_tags", tags.followed_tags),
path("v1/tags/<hashtag>", tags.hashtag),
path("v1/tags/<id>/follow", tags.follow),
path("v1/tags/<id>/unfollow", tags.unfollow),
# Timelines

Wyświetl plik

@ -9,6 +9,22 @@ from api.pagination import MastodonPaginator, PaginatingApiResponse, PaginationR
from users.models import HashtagFollow
@api_view.get
def hashtag(request: HttpRequest, hashtag: str) -> schemas.Tag:
tag = get_object_or_404(
Hashtag,
pk=hashtag.lower(),
)
followed = None
if request.identity:
followed = tag.followers.filter(identity=request.identity).exists()
return schemas.Tag.from_hashtag(
tag,
followed=followed,
)
@scope_required("read:follows")
@api_view.get
def followed_tags(