]> git.openstreetmap.org Git - rails.git/commitdiff
Don't validate the revoker for a block if it hasn't changed
authorTom Hughes <tom@compton.nu>
Thu, 9 Jan 2020 10:59:34 +0000 (10:59 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 9 Jan 2020 10:59:34 +0000 (10:59 +0000)
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.

app/models/user_block.rb

index 60f680ac3016e02b2d4b6acf4437658b26f01f5d..ad564f4189d9c9b0be5e73d4146bbcfd03c1ff79 100644 (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