From 93151f0c51a0418cd51e270a0834c92a771910ab Mon Sep 17 00:00:00 2001 From: "Holly \"Frinkeldoodle\" Lotor" Date: Fri, 17 Jan 2020 07:07:03 +0000 Subject: Port render_with_cache, CacheConcern from upstream --- app/controllers/api/v1/custom_emojis_controller.rb | 5 ++--- app/controllers/api/v1/instances/activity_controller.rb | 3 ++- app/controllers/api/v1/instances/peers_controller.rb | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'app/controllers/api') diff --git a/app/controllers/api/v1/custom_emojis_controller.rb b/app/controllers/api/v1/custom_emojis_controller.rb index 1bb19a09d..6ddb5936c 100644 --- a/app/controllers/api/v1/custom_emojis_controller.rb +++ b/app/controllers/api/v1/custom_emojis_controller.rb @@ -6,8 +6,7 @@ class Api::V1::CustomEmojisController < Api::BaseController skip_before_action :set_cache_headers def index - render_cached_json('api:v1:custom_emojis', expires_in: 1.minute) do - ActiveModelSerializers::SerializableResource.new(CustomEmoji.local.where(disabled: false), each_serializer: REST::CustomEmojiSerializer) - end + expires_in 3.minutes, public: true + render_with_cache(each:serializer: REST:CustomEmojiSerializer) { CustomEmoji.local.where(disabled: false) } end end diff --git a/app/controllers/api/v1/instances/activity_controller.rb b/app/controllers/api/v1/instances/activity_controller.rb index 09edfe365..d0080c5c2 100644 --- a/app/controllers/api/v1/instances/activity_controller.rb +++ b/app/controllers/api/v1/instances/activity_controller.rb @@ -7,7 +7,8 @@ class Api::V1::Instances::ActivityController < Api::BaseController respond_to :json def show - render_cached_json('api:v1:instances:activity:show', expires_in: 1.day) { activity } + expires_in 1.day, public: true + render_with_cache json: :activity, expires_in: 1.day end private diff --git a/app/controllers/api/v1/instances/peers_controller.rb b/app/controllers/api/v1/instances/peers_controller.rb index 93c4c45af..bb04e604d 100644 --- a/app/controllers/api/v1/instances/peers_controller.rb +++ b/app/controllers/api/v1/instances/peers_controller.rb @@ -7,7 +7,8 @@ class Api::V1::Instances::PeersController < Api::BaseController respond_to :json def index - render_cached_json('api:v1:instances:peers:index', expires_in: 1.day) { actively_federated_domains } + expires_in 1.day, public: true + render_with_cache(expires_in: 1.day) { actively_federated_domains } end private -- cgit