Shorten caching of quote posts pending approval (#37570)
This commit is contained in:
parent
42b2fdb0ac
commit
958103368e
@ -29,7 +29,7 @@ class StatusesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
expires_in 3.minutes, public: true if @status.distributable? && public_fetch_mode?
|
expires_in @status.quote&.pending? ? 5.seconds : 3.minutes, public: true if @status.distributable? && public_fetch_mode?
|
||||||
render_with_cache json: @status, content_type: 'application/activity+json', serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter
|
render_with_cache json: @status, content_type: 'application/activity+json', serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -47,6 +47,8 @@ class Quote < ApplicationRecord
|
|||||||
|
|
||||||
def accept!
|
def accept!
|
||||||
update!(state: :accepted)
|
update!(state: :accepted)
|
||||||
|
|
||||||
|
reset_parent_cache! if attribute_changed?(:state)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reject!
|
def reject!
|
||||||
@ -75,6 +77,15 @@ class Quote < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def reset_parent_cache!
|
||||||
|
return if status_id.nil?
|
||||||
|
|
||||||
|
Rails.cache.delete("v3:statuses/#{status_id}")
|
||||||
|
|
||||||
|
# This clears the web cache for the ActivityPub representation
|
||||||
|
Rails.cache.delete("statuses/show:v3:statuses/#{status_id}")
|
||||||
|
end
|
||||||
|
|
||||||
def set_accounts
|
def set_accounts
|
||||||
self.account = status.account
|
self.account = status.account
|
||||||
self.quoted_account = quoted_status&.account
|
self.quoted_account = quoted_status&.account
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user