mirror of
https://github.com/discourse/discourse.git
synced 2025-04-29 17:14:34 +08:00
FEATURE: Setting to allow moderators to change post ownership (#13708)
This commit is contained in:
parent
e384e738bf
commit
0dc96ce817
@ -74,7 +74,10 @@ export function buildManageButtons(attrs, currentUser, siteSettings) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentUser.admin) {
|
if (
|
||||||
|
currentUser.admin ||
|
||||||
|
(siteSettings.moderators_change_post_ownership && currentUser.staff)
|
||||||
|
) {
|
||||||
contents.push({
|
contents.push({
|
||||||
icon: "user",
|
icon: "user",
|
||||||
label: "post.controls.change_owner",
|
label: "post.controls.change_owner",
|
||||||
|
@ -1612,6 +1612,7 @@ en:
|
|||||||
gtm_container_id: "Google Tag Manager container id. eg: GTM-ABCDEF. <br/>Note: Third-party scripts loaded by GTM may need to be allowlisted in 'content security policy script src'."
|
gtm_container_id: "Google Tag Manager container id. eg: GTM-ABCDEF. <br/>Note: Third-party scripts loaded by GTM may need to be allowlisted in 'content security policy script src'."
|
||||||
enable_escaped_fragments: "Fall back to Google's Ajax-Crawling API if no webcrawler is detected. See <a href='https://developers.google.com/webmasters/ajax-crawling/docs/learn-more' target='_blank'>https://developers.google.com/webmasters/ajax-crawling/docs/learn-more</a>"
|
enable_escaped_fragments: "Fall back to Google's Ajax-Crawling API if no webcrawler is detected. See <a href='https://developers.google.com/webmasters/ajax-crawling/docs/learn-more' target='_blank'>https://developers.google.com/webmasters/ajax-crawling/docs/learn-more</a>"
|
||||||
moderators_manage_categories_and_groups: "Allow moderators to manage categories and groups"
|
moderators_manage_categories_and_groups: "Allow moderators to manage categories and groups"
|
||||||
|
moderators_change_post_ownership: "Allow moderators to change post ownership"
|
||||||
cors_origins: "Allowed origins for cross-origin requests (CORS). Each origin must include http:// or https://. The DISCOURSE_ENABLE_CORS env variable must be set to true to enable CORS."
|
cors_origins: "Allowed origins for cross-origin requests (CORS). Each origin must include http:// or https://. The DISCOURSE_ENABLE_CORS env variable must be set to true to enable CORS."
|
||||||
use_admin_ip_allowlist: "Admins can only log in if they are at an IP address defined in the Screened IPs list (Admin > Logs > Screened Ips)."
|
use_admin_ip_allowlist: "Admins can only log in if they are at an IP address defined in the Screened IPs list (Admin > Logs > Screened Ips)."
|
||||||
blocked_ip_blocks: "A list of private IP blocks that should never be crawled by Discourse"
|
blocked_ip_blocks: "A list of private IP blocks that should never be crawled by Discourse"
|
||||||
|
@ -1566,6 +1566,9 @@ security:
|
|||||||
enable_escaped_fragments: true
|
enable_escaped_fragments: true
|
||||||
allow_index_in_robots_txt: true
|
allow_index_in_robots_txt: true
|
||||||
moderators_manage_categories_and_groups: false
|
moderators_manage_categories_and_groups: false
|
||||||
|
moderators_change_post_ownership:
|
||||||
|
client: true
|
||||||
|
default: false
|
||||||
moderators_view_emails:
|
moderators_view_emails:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
|
@ -251,7 +251,9 @@ module PostGuardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
def can_change_post_owner?
|
def can_change_post_owner?
|
||||||
is_admin?
|
return true if is_admin?
|
||||||
|
|
||||||
|
SiteSetting.moderators_change_post_ownership && is_staff?
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_change_post_timestamps?
|
def can_change_post_timestamps?
|
||||||
|
@ -625,18 +625,6 @@ RSpec.describe TopicsController do
|
|||||||
expect(response).to be_forbidden
|
expect(response).to be_forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'forbidden to moderators' do
|
|
||||||
before do
|
|
||||||
sign_in(moderator)
|
|
||||||
end
|
|
||||||
it 'correctly denies' do
|
|
||||||
post "/t/111/change-owner.json", params: {
|
|
||||||
topic_id: 111, username: 'user_a', post_ids: [1, 2, 3]
|
|
||||||
}
|
|
||||||
expect(response).to be_forbidden
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'forbidden to trust_level_4s' do
|
describe 'forbidden to trust_level_4s' do
|
||||||
before do
|
before do
|
||||||
sign_in(trust_level_4)
|
sign_in(trust_level_4)
|
||||||
@ -651,12 +639,35 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'changing ownership' do
|
describe 'changing ownership' do
|
||||||
let!(:editor) { sign_in(admin) }
|
|
||||||
fab!(:topic) { Fabricate(:topic) }
|
fab!(:topic) { Fabricate(:topic) }
|
||||||
fab!(:user_a) { Fabricate(:user) }
|
fab!(:user_a) { Fabricate(:user) }
|
||||||
fab!(:p1) { Fabricate(:post, topic: topic) }
|
fab!(:p1) { Fabricate(:post, topic: topic) }
|
||||||
fab!(:p2) { Fabricate(:post, topic: topic) }
|
fab!(:p2) { Fabricate(:post, topic: topic) }
|
||||||
|
|
||||||
|
describe 'moderator signed in' do
|
||||||
|
let!(:editor) { sign_in(moderator) }
|
||||||
|
|
||||||
|
it "returns 200 when moderators_change_post_ownership is true" do
|
||||||
|
SiteSetting.moderators_change_post_ownership = true
|
||||||
|
|
||||||
|
post "/t/#{topic.id}/change-owner.json", params: {
|
||||||
|
username: user_a.username_lower, post_ids: [p1.id]
|
||||||
|
}
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns 403 when moderators_change_post_ownership is false" do
|
||||||
|
SiteSetting.moderators_change_post_ownership = false
|
||||||
|
|
||||||
|
post "/t/#{topic.id}/change-owner.json", params: {
|
||||||
|
username: user_a.username_lower, post_ids: [p1.id]
|
||||||
|
}
|
||||||
|
expect(response.status).to eq(403)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe 'admin signed in' do
|
||||||
|
let!(:editor) { sign_in(admin) }
|
||||||
|
|
||||||
it "raises an error with a parameter missing" do
|
it "raises an error with a parameter missing" do
|
||||||
[
|
[
|
||||||
{ post_ids: [1, 2, 3] },
|
{ post_ids: [1, 2, 3] },
|
||||||
@ -728,6 +739,7 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#change_timestamps' do
|
describe '#change_timestamps' do
|
||||||
let!(:params) { { timestamp: Time.zone.now } }
|
let!(:params) { { timestamp: Time.zone.now } }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user