about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-01-25 01:29:40 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-01-25 01:29:40 +0100
commitca28d9c2aec0764dc9190e2802e5e6e23cf6d8c3 (patch)
tree51d86739522f79ee545f7c821507997f0a4914cb /app/models/status.rb
parent8a880a3d464daf486a10d85b8ee49305aa6b1e5b (diff)
parent999cde94a6a2d67cf36160365378951d3b55b868 (diff)
Merge branch 'blackle-master'
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index d5f52b55c..651d0dbc9 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -1,6 +1,7 @@
 # frozen_string_literal: true
 
 class Status < ApplicationRecord
+  include ActiveModel::Validations
   include Paginable
   include Streamable
   include Cacheable
@@ -27,8 +28,8 @@ class Status < ApplicationRecord
 
   validates :account, presence: true
   validates :uri, uniqueness: true, unless: 'local?'
-  validates :text, presence: true, length: { maximum: 500 }, if: proc { |s| s.local? && !s.reblog? }
-  validates :text, presence: true, if: proc { |s| !s.local? && !s.reblog? }
+  validates :text, presence: true, unless: 'reblog?'
+  validates_with StatusLengthValidator
   validates :reblog, uniqueness: { scope: :account, message: 'of status already exists' }, if: 'reblog?'
 
   default_scope { order('id desc') }
@@ -174,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?