about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-10-08 16:45:40 +0200
committerGitHub <noreply@github.com>2022-10-08 16:45:40 +0200
commit45ebdb72ca1678eb30e6087f61bd019c7ea903f4 (patch)
tree39fa4a3185bf358efa8c954a42b39b927d3b904b /app/controllers
parent678fc4d292664550df554a224b8fd59dcef20d35 (diff)
Add support for language preferences for trending statuses and links (#18288)
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/trends/links_controller.rb1
-rw-r--r--app/controllers/admin/trends/statuses_controller.rb1
-rw-r--r--app/controllers/api/v1/trends/links_controller.rb4
3 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/admin/trends/links_controller.rb b/app/controllers/admin/trends/links_controller.rb
index a497eae41..a3454f2da 100644
--- a/app/controllers/admin/trends/links_controller.rb
+++ b/app/controllers/admin/trends/links_controller.rb
@@ -4,6 +4,7 @@ class Admin::Trends::LinksController < Admin::BaseController
   def index
     authorize :preview_card, :review?
 
+    @locales       = PreviewCardTrend.pluck('distinct language')
     @preview_cards = filtered_preview_cards.page(params[:page])
     @form          = Trends::PreviewCardBatch.new
   end
diff --git a/app/controllers/admin/trends/statuses_controller.rb b/app/controllers/admin/trends/statuses_controller.rb
index c538962f9..2b8226138 100644
--- a/app/controllers/admin/trends/statuses_controller.rb
+++ b/app/controllers/admin/trends/statuses_controller.rb
@@ -4,6 +4,7 @@ class Admin::Trends::StatusesController < Admin::BaseController
   def index
     authorize :status, :review?
 
+    @locales  = StatusTrend.pluck('distinct language')
     @statuses = filtered_statuses.page(params[:page])
     @form     = Trends::StatusBatch.new
   end
diff --git a/app/controllers/api/v1/trends/links_controller.rb b/app/controllers/api/v1/trends/links_controller.rb
index 1a9f918f2..8ff3b364e 100644
--- a/app/controllers/api/v1/trends/links_controller.rb
+++ b/app/controllers/api/v1/trends/links_controller.rb
@@ -28,7 +28,9 @@ class Api::V1::Trends::LinksController < Api::BaseController
   end
 
   def links_from_trends
-    Trends.links.query.allowed.in_locale(content_locale)
+    scope = Trends.links.query.allowed.in_locale(content_locale)
+    scope = scope.filtered_for(current_account) if user_signed_in?
+    scope
   end
 
   def insert_pagination_headers