about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-01-18 16:28:18 +0100
committerGitHub <noreply@github.com>2023-01-18 16:28:18 +0100
commitb034dc42be2250f9b754fb88c9163b62d41f78f5 (patch)
tree94f8e5604ae93ea50a7d3a8f180238c454fea9c9 /app/controllers
parent0405be69d265b81a41be9c253e4b50aa6c8e1ee9 (diff)
Fix /api/v1/admin/trends/tags using wrong serializer (#18943)
* Fix /api/v1/admin/trends/tags using wrong serializer

Fix regression from #18641

* Only use `REST::Admin::TagSerializer` when the user can `manage_taxonomies`

* Fix admin trending hashtag component to not link if `id` is unknown
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/v1/admin/trends/tags_controller.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/controllers/api/v1/admin/trends/tags_controller.rb b/app/controllers/api/v1/admin/trends/tags_controller.rb
index f3c0c4b6b..e77df3021 100644
--- a/app/controllers/api/v1/admin/trends/tags_controller.rb
+++ b/app/controllers/api/v1/admin/trends/tags_controller.rb
@@ -3,6 +3,14 @@
 class Api::V1::Admin::Trends::TagsController < Api::V1::Trends::TagsController
   before_action -> { authorize_if_got_token! :'admin:read' }
 
+  def index
+    if current_user&.can?(:manage_taxonomies)
+      render json: @tags, each_serializer: REST::Admin::TagSerializer
+    else
+      super
+    end
+  end
+
   private
 
   def enabled?