kopia lustrzana https://github.com/jointakahe/takahe
Implement /api/v1/tags/<hashtag> endpoint
rodzic
161ff745f8
commit
f576c913a9
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Ładowanie…
Reference in New Issue