FEATURE: An API key scope for editing posts. (#13441)

FEATURE: An API key scope for editing posts. (#13441)

diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rb
index 3534785..be78125 100644
--- a/app/models/api_key_scope.rb
+++ b/app/models/api_key_scope.rb
@@ -33,6 +33,9 @@ class ApiKeyScope < ActiveRecord::Base
           },
           wordpress: { actions: %w[topics#wordpress], params: %i[topic_id] }
         },
+        posts: {
+          edit: { actions: %w[posts#update], params: %i[id] }
+        },
         users: {
           bookmarks: { actions: %w[users#bookmarks], params: %i[username] },
           sync_sso: { actions: %w[admin/users#sync_sso], params: %i[sso sig] },
@@ -84,7 +87,9 @@ class ApiKeyScope < ActiveRecord::Base
         excluded_paths = %w[/new-topic /new-message /exception]
 
         memo.tap do |m|
-          m << path if actions.include?(action) && api_supported_path && !excluded_paths.include?(path)
+          if actions.include?(action) && api_supported_path && !excluded_paths.include?(path)
+            m << "#{path} (#{route.verb})"
+          end
         end
       end
     end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index dbfc5cc..2f73310 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4026,6 +4026,8 @@ en:
               write: Create a new topic or post to an existing one.
               read_lists: Read topic lists like top, new, latest, etc. RSS is also supported.
               wordpress: Necessary for the WordPress wp-discourse plugin to work.
+            posts:
+              edit: Edit any post or a specific one.
             users:
               bookmarks: List user bookmarks. It returns bookmark reminders when using the ICS format.
               sync_sso: Synchronize a user using DiscourseConnect.
diff --git a/spec/requests/admin/api_controller_spec.rb b/spec/requests/admin/api_controller_spec.rb
index 7921364..c52b343 100644
--- a/spec/requests/admin/api_controller_spec.rb
+++ b/spec/requests/admin/api_controller_spec.rb
@@ -222,7 +222,7 @@ describe Admin::ApiController do
 
         scopes = response.parsed_body['scopes']
 
-        expect(scopes.keys).to contain_exactly('topics', 'users', 'email')
+        expect(scopes.keys).to contain_exactly('topics', 'users', 'email', 'posts')
       end
     end
   end

GitHub sha: 4afd8f9bdf6187fb1dddbd11ec47e2c4c811dba1

This commit appears in #13441 which was approved by eviltrout. It was merged by romanrizzi.