status: disallow quoting of non-public posts

pull/36/head
Ariadne Conill 2022-12-25 03:56:19 +00:00
parent a697e1da13
commit 1cef1eb847
1 changed files with 5 additions and 0 deletions

View File

@ -89,6 +89,7 @@ class Status < ApplicationRecord
validates :reblog, uniqueness: { scope: :account }, if: :reblog? validates :reblog, uniqueness: { scope: :account }, if: :reblog?
validates :visibility, exclusion: { in: %w(direct limited) }, if: :reblog? validates :visibility, exclusion: { in: %w(direct limited) }, if: :reblog?
validates :content_type, inclusion: { in: %w(text/plain text/markdown text/html) }, allow_nil: true validates :content_type, inclusion: { in: %w(text/plain text/markdown text/html) }, allow_nil: true
validates :quote_visibility, inclusion: { in: %w(public unlisted) }, if: :quote?
accepts_nested_attributes_for :poll accepts_nested_attributes_for :poll
@ -213,6 +214,10 @@ class Status < ApplicationRecord
!quote_id.nil? && quote !quote_id.nil? && quote
end end
def quote_visibility
quote&.visibility
end
def within_realtime_window? def within_realtime_window?
created_at >= REAL_TIME_WINDOW.ago created_at >= REAL_TIME_WINDOW.ago
end end