diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-08-25 01:41:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-25 01:41:18 +0200 |
commit | 9caa90025fd9f1ef46a74f31cefd19335e291e76 (patch) | |
tree | 51d91a2c713bcddc9d21cd63836db3ae4bc3d226 /app/validators | |
parent | c5157ef07bbae5c3a307d6a005aef0f1c0452af3 (diff) |
Pinned statuses (#4675)
* Pinned statuses * yarn manage:translations
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/status_pin_validator.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/validators/status_pin_validator.rb b/app/validators/status_pin_validator.rb new file mode 100644 index 000000000..f557df6af --- /dev/null +++ b/app/validators/status_pin_validator.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class StatusPinValidator < ActiveModel::Validator + def validate(pin) + pin.errors.add(:status, I18n.t('statuses.pin_errors.reblog')) if pin.status.reblog? + pin.errors.add(:status, I18n.t('statuses.pin_errors.ownership')) if pin.account_id != pin.status.account_id + pin.errors.add(:status, I18n.t('statuses.pin_errors.private')) unless %w(public unlisted).include?(pin.status.visibility) + end +end |