X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fmastodon_api%2Fcontrollers%2Ftag_controller.ex;h=ca5ee48ac151ab82470b8d01cb1c17952d9d9a31;hb=b2112302ce49a4bdf0d0a0779854cd9f1a838ff3;hp=b8995eb00c8f8ae866701ca8850dc10bd75ec01b;hpb=d55de5debf3645d97ec792e669f1249e62e07191;p=akkoma diff --git a/lib/pleroma/web/mastodon_api/controllers/tag_controller.ex b/lib/pleroma/web/mastodon_api/controllers/tag_controller.ex index b8995eb00..ca5ee48ac 100644 --- a/lib/pleroma/web/mastodon_api/controllers/tag_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/tag_controller.ex @@ -4,9 +4,24 @@ defmodule Pleroma.Web.MastodonAPI.TagController do alias Pleroma.User alias Pleroma.Hashtag + alias Pleroma.Pagination + + import Pleroma.Web.ControllerHelper, + only: [ + add_link_headers: 2 + ] plug(Pleroma.Web.ApiSpec.CastAndValidate) - plug(Pleroma.Web.Plugs.OAuthScopesPlug, %{scopes: ["read"]} when action in [:show]) + + plug( + Pleroma.Web.Plugs.OAuthScopesPlug, + %{scopes: ["read"]} when action in [:show] + ) + + plug( + Pleroma.Web.Plugs.OAuthScopesPlug, + %{scopes: ["read:follows"]} when action in [:show_followed] + ) plug( Pleroma.Web.Plugs.OAuthScopesPlug, @@ -44,4 +59,19 @@ defmodule Pleroma.Web.MastodonAPI.TagController do _ -> render_error(conn, :not_found, "Hashtag not found") end end + + def show_followed(conn, params) do + with %{assigns: %{user: %User{} = user}} <- conn do + params = Map.put(params, :id_type, :integer) + + hashtags = + user + |> User.HashtagFollow.followed_hashtags_query() + |> Pagination.fetch_paginated(params) + + conn + |> add_link_headers(hashtags) + |> render("index.json", tags: hashtags, for_user: user) + end + end end