before_action :set_thread, only: [:create]
override_rate_limit_headers :create, family: :statuses
+ override_rate_limit_headers :update, family: :statuses
# This API was originally unlimited, pagination cannot be introduced without
# breaking backwards-compatibility. Arbitrarily high number to cover most
public_visibility? || unlisted_visibility?
end
- def snapshot!(account_id: nil, at_time: nil)
+ def snapshot!(account_id: nil, at_time: nil, rate_limit: true)
edits.create!(
text: text,
spoiler_text: spoiler_text,
media_descriptions: ordered_media_attachments.map(&:description),
poll_options: preloadable_poll&.options,
account_id: account_id || self.account_id,
- created_at: at_time || edited_at
+ created_at: at_time || edited_at,
+ rate_limit: rate_limit
)
end
#
class StatusEdit < ApplicationRecord
+ include RateLimitable
+
self.ignored_columns = %w(
media_attachments_changed
)
delegate :id, :type, :url, :preview_url, :remote_url, :preview_remote_url, :text_url, :meta, :blurhash, to: :media_attachment
end
+ rate_limit by: :account, family: :statuses
+
belongs_to :status
belongs_to :account, optional: true
return if @status.edits.any?
- @status.snapshot!(at_time: @status.created_at)
+ @status.snapshot!(at_time: @status.created_at, rate_limit: false)
end
def create_edit!
return unless significant_changes?
- @status.snapshot!(account_id: @account.id)
+ @status.snapshot!(account_id: @account.id, rate_limit: false)
end
def skip_download?
return if @status.edits.any?
- @status.snapshot!(at_time: @status.created_at)
+ @status.snapshot!(at_time: @status.created_at, rate_limit: false)
end
def create_edit!