Don't validate the revoker for a block if it hasn't changed

The revoker only has to be a moderator at the time they make the
revocation - as things stood trying to view a block that had been
revoked by somebody that was no longer a moderator failed.
This commit is contained in:
Tom Hughes 2020-01-09 10:59:34 +00:00
parent 928465764e
commit b1e1572af3

View file

@ -79,6 +79,6 @@ class UserBlock < ApplicationRecord
# but i've also included it here just in case.
def moderator_permissions
errors.add(:base, I18n.t("user_block.model.non_moderator_update")) if creator_id_changed? && !creator.moderator?
errors.add(:base, I18n.t("user_block.model.non_moderator_revoke")) unless revoker_id.nil? || revoker.moderator?
errors.add(:base, I18n.t("user_block.model.non_moderator_revoke")) if revoker_id_changed? && !revoker_id.nil? && !revoker.moderator?
end
end