mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:52:45 +08:00
FEATURE: Add recover api scopes (#25978)
This commit adds two new api scopes. One for recovering topics, and the other for recovering posts.
This commit is contained in:
parent
0b778697ff
commit
2d890d73a2
|
@ -34,6 +34,9 @@ class ApiKeyScope < ActiveRecord::Base
|
|||
delete: {
|
||||
actions: %w[topics#destroy],
|
||||
},
|
||||
recover: {
|
||||
actions: %w[topics#recover],
|
||||
},
|
||||
read: {
|
||||
actions: %w[topics#show topics#feed topics#posts topics#show_by_external_id],
|
||||
params: %i[topic_id external_id],
|
||||
|
@ -61,6 +64,9 @@ class ApiKeyScope < ActiveRecord::Base
|
|||
delete: {
|
||||
actions: %w[posts#destroy],
|
||||
},
|
||||
recover: {
|
||||
actions: %w[posts#recover],
|
||||
},
|
||||
list: {
|
||||
actions: %w[posts#latest],
|
||||
},
|
||||
|
|
|
@ -5037,11 +5037,13 @@ en:
|
|||
write: Create a new topic or post to an existing one.
|
||||
update: Update a topic. Change the title, category, tags, status, archetype, featured_link etc.
|
||||
delete: Delete a topic.
|
||||
recover: Recover a topic.
|
||||
read_lists: Read topic lists like top, new, latest, etc. RSS is also supported.
|
||||
status: "Update a topic's status. Status: closed, archive, visible, pinned. Enabled: true, false. Specify a category_id here and in the request payload to only allow status changes on topics in that category."
|
||||
posts:
|
||||
edit: Edit any post or a specific one.
|
||||
delete: Delete a post.
|
||||
recover: Recover a post.
|
||||
list: List latest posts and private posts. RSS is also supported.
|
||||
tags:
|
||||
list: List tags.
|
||||
|
|
|
@ -478,6 +478,7 @@ RSpec.describe Admin::ApiController do
|
|||
"/t/:slug/:topic_id/last (GET)",
|
||||
"/t/:topic_id/posts (GET)",
|
||||
"/latest.rss (GET)",
|
||||
"/t/:topic_id/recover (PUT)",
|
||||
]
|
||||
|
||||
topic_routes.each do |route|
|
||||
|
@ -486,6 +487,9 @@ RSpec.describe Admin::ApiController do
|
|||
|
||||
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
|
||||
expect(
|
||||
scopes["posts"].any? { |h| h["urls"].include?("/posts/:post_id/recover (PUT)") },
|
||||
).to be_truthy
|
||||
|
||||
expect(scopes["users"].find { _1["key"] == "update" }["urls"]).to contain_exactly(
|
||||
"/users/:username (PUT)",
|
||||
|
|
Loading…
Reference in New Issue
Block a user