about summary refs log tree commit diff
path: root/app/controllers/activitypub/collections_controller.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-04-04 01:30:44 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-04-04 01:30:44 +0200
commitcc6e3c39001c11c82b198e357dd5d3e3fc032637 (patch)
treee075a73801a32115c0137a7bf4ae8f1f7daee1de /app/controllers/activitypub/collections_controller.rb
parentd4882aa64a7a483ec30ca61a507c2a6f5d3294f5 (diff)
Cache featured collections, as well as outbox, followers and following (#10467)
Diffstat (limited to 'app/controllers/activitypub/collections_controller.rb')
-rw-r--r--app/controllers/activitypub/collections_controller.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/controllers/activitypub/collections_controller.rb b/app/controllers/activitypub/collections_controller.rb
index 995da9c55..853f4f907 100644
--- a/app/controllers/activitypub/collections_controller.rb
+++ b/app/controllers/activitypub/collections_controller.rb
@@ -6,13 +6,19 @@ class ActivityPub::CollectionsController < Api::BaseController
   before_action :set_account
   before_action :set_size
   before_action :set_statuses
+  before_action :set_cache_headers
 
   def show
-    render json: collection_presenter,
-           serializer: ActivityPub::CollectionSerializer,
-           adapter: ActivityPub::Adapter,
-           content_type: 'application/activity+json',
-           skip_activities: true
+    skip_session!
+
+    render_cached_json(['activitypub', 'collection', @account, params[:id]], content_type: 'application/activity+json') do
+      ActiveModelSerializers::SerializableResource.new(
+        collection_presenter,
+        serializer: ActivityPub::CollectionSerializer,
+        adapter: ActivityPub::Adapter,
+        skip_activities: true
+      )
+    end
   end
 
   private