mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-21 20:15:10 +01:00
d5c9feb7b7
* Add support for private pinned toots * Allow local user to pin private toots * Change wording to avoid "direct message"
11 lines
526 B
Ruby
11 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
|