From 999cde94a6a2d67cf36160365378951d3b55b868 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 25 Jan 2017 00:49:08 +0100 Subject: Instead of using spoiler boolean and spoiler_text, simply check for non-blank spoiler_text Federate spoiler_text using warning attribute on instead of a Clean up schema file from accidental development migrations --- app/models/status.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/status.rb') diff --git a/app/models/status.rb b/app/models/status.rb index 42abe92e5..651d0dbc9 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -28,9 +28,8 @@ class Status < ApplicationRecord validates :account, presence: true validates :uri, uniqueness: true, unless: 'local?' - validates :text, presence: true, if: proc { |s| s.local? && !s.reblog? } + validates :text, presence: true, unless: 'reblog?' validates_with StatusLengthValidator - validates :text, presence: true, if: proc { |s| !s.local? && !s.reblog? } validates :reblog, uniqueness: { scope: :account, message: 'of status already exists' }, if: 'reblog?' default_scope { order('id desc') } @@ -176,6 +175,7 @@ class Status < ApplicationRecord before_validation do text.strip! + spoiler_text&.strip! self.reblog = reblog.reblog if reblog? && reblog.reblog? self.in_reply_to_account_id = (thread.account_id == account_id && thread.reply? ? thread.in_reply_to_account_id : thread.account_id) if reply? -- cgit