diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-01-10 19:12:10 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-01-10 21:00:30 +0100 |
commit | a2a64ecd3e3551707412c47f0d16e484dea25632 (patch) | |
tree | bc4e0b8e0ca2a2735f527bff8bd73421c0ff72dd /app/models/account.rb | |
parent | fb0c906c717f2b21bb63610742a357850142b522 (diff) | |
parent | 70801b850c78d7879182eeba4eae509af42fafeb (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - .eslintrc.yml Removed, as upstream removed it. - app/controllers/admin/statuses_controller.rb Minor code cleanup when porting one of our features. - app/models/account.rb Note length validation has changed upstream. We now use upstream's validation (dropped legacy glitch-soc account metadata stuff) but with configurable limit. - app/services/post_status_service.rb Upstream has added support for scheduled toots, refactoring the code a bit. Adapted our changes to this refactoring. - app/views/stream_entries/_detailed_status.html.haml Not a real conflict, changes too close. - app/views/stream_entries/_simple_status.html.haml Not a real conflict, changes too close.
Diffstat (limited to 'app/models/account.rb')
-rw-r--r-- | app/models/account.rb | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 67d9a583e..1ee63c738 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -79,7 +79,7 @@ class Account < ApplicationRecord validates_with UniqueUsernameValidator, if: -> { local? && will_save_change_to_username? } validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? } validates :display_name, length: { maximum: MAX_DISPLAY_NAME_LENGTH }, if: -> { local? && will_save_change_to_display_name? } - validate :note_length_does_not_exceed_length_limit, if: -> { local? && will_save_change_to_note? } + validates :note, note_length: { maximum: MAX_NOTE_LENGTH }, if: -> { local? && will_save_change_to_note? } validates :fields, length: { maximum: MAX_FIELDS }, if: -> { local? && will_save_change_to_fields? } scope :remote, -> { where.not(domain: nil) } @@ -488,22 +488,6 @@ class Account < ApplicationRecord self.public_key = keypair.public_key.to_pem end - YAML_START = "---\r\n" - YAML_END = "\r\n...\r\n" - - def note_length_does_not_exceed_length_limit - note_without_metadata = note - if note.start_with? YAML_START - idx = note.index YAML_END - unless idx.nil? - note_without_metadata = note[(idx + YAML_END.length) .. -1] - end - end - if note_without_metadata.mb_chars.grapheme_length > MAX_NOTE_LENGTH - errors.add(:note, "can't be longer than 500 graphemes") - end - end - def normalize_domain return if local? |