mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 12:53:17 +08:00
DEV: Add API scopes for post revisions (#26183)
This commit adds API scopes for reading, modifying, and deleting post revisions.
This commit is contained in:
parent
c986f9a947
commit
70c23f11a9
|
@ -71,6 +71,20 @@ class ApiKeyScope < ActiveRecord::Base
|
|||
actions: %w[posts#latest],
|
||||
},
|
||||
},
|
||||
revisions: {
|
||||
read: {
|
||||
actions: %w[posts#latest_revision posts#revisions],
|
||||
params: %i[post_id],
|
||||
},
|
||||
modify: {
|
||||
actions: %w[posts#hide_revision posts#show_revision posts#revert],
|
||||
params: %i[post_id],
|
||||
},
|
||||
permanently_delete: {
|
||||
actions: %w[posts#permanently_delete_revisions],
|
||||
params: %i[post_id],
|
||||
},
|
||||
},
|
||||
tags: {
|
||||
list: {
|
||||
actions: %w[tags#index],
|
||||
|
|
|
@ -5063,6 +5063,10 @@ en:
|
|||
delete: Delete a post.
|
||||
recover: Recover a post.
|
||||
list: List latest posts and private posts. RSS is also supported.
|
||||
revisions:
|
||||
read: "Get the latest or a specific revision."
|
||||
modify: "Hide, show, or revert revisions."
|
||||
permanently_delete: "Permanently delete a revision."
|
||||
tags:
|
||||
list: List tags.
|
||||
tag_groups:
|
||||
|
|
|
@ -450,6 +450,7 @@ RSpec.describe Admin::ApiController do
|
|||
"users",
|
||||
"email",
|
||||
"posts",
|
||||
"revisions",
|
||||
"tags",
|
||||
"tag_groups",
|
||||
"uploads",
|
||||
|
@ -491,6 +492,12 @@ RSpec.describe Admin::ApiController do
|
|||
scopes["posts"].any? { |h| h["urls"].include?("/posts/:post_id/recover (PUT)") },
|
||||
).to be_truthy
|
||||
|
||||
expect(
|
||||
scopes["revisions"].any? do |h|
|
||||
h["urls"].include?("/posts/:post_id/revisions/permanently_delete (DELETE)")
|
||||
end,
|
||||
).to be_truthy
|
||||
|
||||
expect(scopes["users"].find { _1["key"] == "update" }["urls"]).to contain_exactly(
|
||||
"/users/:username (PUT)",
|
||||
"/users/:username/preferences/badge_title (PUT)",
|
||||
|
|
Loading…
Reference in New Issue
Block a user