]> git.openstreetmap.org Git - rails.git/blobdiff - app/abilities/api_ability.rb
Merge remote-tracking branch 'upstream/pull/5806'
[rails.git] / app / abilities / api_ability.rb
index acacec049af1f20f6372c3a008945961fdda6c29..b0bd2578f11fe9f03242c9174f108837552ac812 100644 (file)
@@ -3,14 +3,14 @@
 class ApiAbility
   include CanCan::Ability
 
 class ApiAbility
   include CanCan::Ability
 
-  def initialize(user, scopes)
+  def initialize(user, scopes) # rubocop:disable Metrics/CyclomaticComplexity
     can :read, [:version, :capability, :permission, :map]
 
     if Settings.status != "database_offline"
       can [:read, :feed, :search], Note
       can :create, Note unless user
 
     can :read, [:version, :capability, :permission, :map]
 
     if Settings.status != "database_offline"
       can [:read, :feed, :search], Note
       can :create, Note unless user
 
-      can [:read, :download], Changeset
+      can :read, Changeset
       can :read, ChangesetComment
       can :read, Tracepoint
       can :read, User
       can :read, ChangesetComment
       can :read, Tracepoint
       can :read, User
@@ -34,17 +34,18 @@ class ApiAbility
         can :read, :active_user_blocks_list if scopes.include?("read_prefs")
 
         if user.terms_agreed?
         can :read, :active_user_blocks_list if scopes.include?("read_prefs")
 
         if user.terms_agreed?
-          can [:create, :update, :upload, :close, :subscribe, :unsubscribe], Changeset if scopes.include?("write_map")
+          can [:create, :update, :upload, :close], Changeset if scopes.include?("write_map")
+          can [:create, :destroy], ChangesetSubscription if scopes.include?("write_map")
           can :create, ChangesetComment if scopes.include?("write_changeset_comments")
           can [:create, :update, :destroy], [Node, Way, Relation] if scopes.include?("write_map")
         end
 
         if user.moderator?
           can :create, ChangesetComment if scopes.include?("write_changeset_comments")
           can [:create, :update, :destroy], [Node, Way, Relation] if scopes.include?("write_map")
         end
 
         if user.moderator?
-          can [:destroy, :restore], ChangesetComment if scopes.include?("write_changeset_comments")
+          can [:create, :destroy], :changeset_comment_visibility if scopes.include?("write_changeset_comments")
 
           can :destroy, Note if scopes.include?("write_notes")
 
 
           can :destroy, Note if scopes.include?("write_notes")
 
-          can :redact, [OldNode, OldWay, OldRelation] if user.terms_agreed? && scopes.include?("write_redactions")
+          can [:create, :destroy], :element_version_redaction if user.terms_agreed? && scopes.include?("write_redactions")
 
           can :create, UserBlock if scopes.include?("write_blocks")
         end
 
           can :create, UserBlock if scopes.include?("write_blocks")
         end