diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-03-09 20:06:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-09 20:06:51 +0100 |
commit | b2cd34474b58b8a1f5e01ba73d236551dd0a878f (patch) | |
tree | 53e6abc10bd98ebd99d33ae51b67940734bd99fe /app/models | |
parent | 803f536cdd2e378146372976b64896a656ceec5b (diff) |
Add rate limit for editing (#17728)
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/status.rb | 5 | ||||
-rw-r--r-- | app/models/status_edit.rb | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index db10eedc2..12daee2de 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -212,7 +212,7 @@ class Status < ApplicationRecord 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, @@ -221,7 +221,8 @@ class Status < ApplicationRecord 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 diff --git a/app/models/status_edit.rb b/app/models/status_edit.rb index 94a387c36..6da9b4b85 100644 --- a/app/models/status_edit.rb +++ b/app/models/status_edit.rb @@ -17,6 +17,8 @@ # class StatusEdit < ApplicationRecord + include RateLimitable + self.ignored_columns = %w( media_attachments_changed ) @@ -26,6 +28,8 @@ class StatusEdit < ApplicationRecord 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 |