From 704a792f1897742fde98588a49f2091744215f5f Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Mon, 5 Jun 2023 09:04:34 -0600 Subject: [PATCH] FEATURE: Add API Scope for latest posts (#21913) Adds api scopes for - `/posts.json` - `/posts.rss` - `/private-posts.json` - `/private-posts.rss` --- app/models/api_key_scope.rb | 3 +++ config/locales/client.en.yml | 1 + spec/requests/admin/api_controller_spec.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rb index b272efd4092..f6662815b7e 100644 --- a/app/models/api_key_scope.rb +++ b/app/models/api_key_scope.rb @@ -61,6 +61,9 @@ class ApiKeyScope < ActiveRecord::Base delete: { actions: %w[posts#destroy], }, + list: { + actions: %w[posts#latest], + }, }, tags: { list: { diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2fdcfa4cdc5..55b4689250f 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4778,6 +4778,7 @@ en: posts: edit: Edit any post or a specific one. delete: Delete a post. + list: List latest posts and private posts. RSS is also supported. tags: list: List tags. categories: diff --git a/spec/requests/admin/api_controller_spec.rb b/spec/requests/admin/api_controller_spec.rb index 9f1d94c32a9..3d6bae83881 100644 --- a/spec/requests/admin/api_controller_spec.rb +++ b/spec/requests/admin/api_controller_spec.rb @@ -436,6 +436,8 @@ RSpec.describe Admin::ApiController do ) expect(scopes["topics"].any? { |h| h["urls"].include?("/latest.rss (GET)") }).to be_truthy + expect(scopes["posts"].any? { |h| h["urls"].include?("/posts (GET)") }).to be_truthy + expect(scopes["posts"].any? { |h| h["urls"].include?("/private-posts (GET)") }).to be_truthy end end