Federate spoiler_text using warning attribute on <content /> instead of a <category term="spoiler" /> Clean up schema file from accidental development migrationslocal
parent
f8da0dd490
commit
999cde94a6
23 changed files with 160 additions and 174 deletions
@ -0,0 +1,10 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class StatusLengthValidator < ActiveModel::Validator |
||||
MAX_CHARS = 500 |
||||
|
||||
def validate(status) |
||||
return unless status.local? && !status.reblog? |
||||
status.errors.add(:text, I18n.t('statuses.over_character_limit', max: MAX_CHARS)) if [status.text, status.spoiler_text].join.length > MAX_CHARS |
||||
end |
||||
end |
@ -1,15 +0,0 @@ |
||||
class StatusLengthValidator < ActiveModel::Validator |
||||
def validate(status) |
||||
if status.local? && !status.reblog? |
||||
combinedText = status.text |
||||
if (status.spoiler? && status.spoiler_text.present?) |
||||
combinedText = status.spoiler_text + "\n" + status.text |
||||
end |
||||
|
||||
maxChars = 500 |
||||
unless combinedText.length <= maxChars |
||||
status.errors[:text] << "is too long (maximum is #{maxChars})" |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,5 +0,0 @@ |
||||
class AddSpoilerToStatuses < ActiveRecord::Migration[5.0] |
||||
def change |
||||
add_column :statuses, :spoiler, :boolean, default: false |
||||
end |
||||
end |
Loading…
Reference in new issue