about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorchr <chr@cybre.space>2018-11-12 20:30:47 -0800
committerchr <chr@cybre.space>2021-03-01 21:46:58 -0800
commit6958c14a770dc0921462553330860fb48194fc5e (patch)
tree667adfa8fb2439899621b07d46647ae9872af1ee /app/models
parent633d175146d6acaf2cc4bfbfcfdee4c85ef20ed1 (diff)
Bio length -> 500 characters
Increase the cybre.space profile bio text length limit to 500
characters. Also modifies the account settings page to automatically
resize the textbox to the size of the contained text, so that it's
easier to type longer bios.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index e6cf03fa8..9a1c4cd40 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -89,6 +89,7 @@ class Account < ApplicationRecord
   validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? }
   validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? }
   validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
+  validate :note_has_eight_newlines?, if: -> { local? && will_save_change_to_note? }
   validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? }
 
   scope :remote, -> { where.not(domain: nil) }
@@ -346,7 +347,6 @@ class Account < ApplicationRecord
   rescue ActiveRecord::RecordInvalid
     self.avatar = nil
     self.header = nil
-
     save!
   end
 
@@ -382,6 +382,10 @@ class Account < ApplicationRecord
     return 'local' if local?
 
     @synchronization_uri_prefix ||= uri[/http(s?):\/\/[^\/]+\//]
+  end 
+  
+  def note_has_eight_newlines?
+    errors.add(:note, 'Bio can\'t have more then 8 newlines') unless note.count("\n") <= 8
   end
 
   class Field < ActiveModelSerializers::Model