gab-social/app/validators/group_pinned_status_validator.rb
mgabdev d030783089 Added GroupPinnedStatuses
• Added:
- GroupPinnedStatuses
- controllers for timeline, creation, deletion
- redux actions, reducers for creation, deletion
- timeline fetching in timelines action
- options to pin, unpin in status options popover for group admin
2020-09-10 15:07:01 -05:00

11 lines
581 B
Ruby

# frozen_string_literal: true
class GroupPinnedStatusValidator < ActiveModel::Validator
def validate(groupPin)
groupPin.errors.add(:base, I18n.t('statuses.group_pin_errors.reblog')) if groupPin.status.reblog?
groupPin.errors.add(:base, I18n.t('statuses.pin_errors.ungrouped')) unless groupPin.status.group_id
groupPin.errors.add(:base, I18n.t('statuses.pin_errors.notGroupStatus')) if groupPin.status.group_id != groupPin.group.id
groupPin.errors.add(:base, I18n.t('statuses.group_pin_errors.limit')) if groupPin.group.group_pinned_statuses.count >= 4
end
end