fedibird-fe/app/validators/status_pin_validator.rb
Claire e4bf21df6a Add support for private pinned posts
* Add support for private pinned toots

* Allow local user to pin private toots

* Change wording to avoid "direct message"
2023-02-06 16:28:36 +09:00

10 lines
526 B
Ruby

# frozen_string_literal: true
class StatusPinValidator < ActiveModel::Validator
def validate(pin)
pin.errors.add(:base, I18n.t('statuses.pin_errors.reblog')) if pin.status.reblog?
pin.errors.add(:base, I18n.t('statuses.pin_errors.ownership')) if pin.account_id != pin.status.account_id
pin.errors.add(:base, I18n.t('statuses.pin_errors.direct')) if pin.status.direct_visibility?
pin.errors.add(:base, I18n.t('statuses.pin_errors.limit')) if pin.account.status_pins.count > 4 && pin.account.local?
end
end