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.
This commit is contained in:
@ -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?
|
||||
|
||||
|
Reference in New Issue
Block a user