mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:41:25 +08:00
FIX: public sidebar sections belong to system user (#20972)
Before, public sidebar sections were belonging to admin. However, a better choice is system user.
This commit is contained in:

committed by
GitHub

parent
6b9dd22ba7
commit
b72282123b
@ -16,9 +16,7 @@ class SidebarSectionsController < ApplicationController
|
||||
|
||||
def create
|
||||
sidebar_section =
|
||||
SidebarSection.create!(
|
||||
section_params.merge(user: current_user, sidebar_urls_attributes: links_params),
|
||||
)
|
||||
SidebarSection.create!(section_params.merge(sidebar_urls_attributes: links_params))
|
||||
|
||||
if sidebar_section.public?
|
||||
StaffActionLogger.new(current_user).log_create_public_sidebar_section(sidebar_section)
|
||||
@ -38,7 +36,10 @@ class SidebarSectionsController < ApplicationController
|
||||
sidebar_section = SidebarSection.find_by(id: section_params["id"])
|
||||
@guardian.ensure_can_edit!(sidebar_section)
|
||||
|
||||
sidebar_section.update!(section_params.merge(sidebar_urls_attributes: links_params))
|
||||
ActiveRecord::Base.transaction do
|
||||
sidebar_section.update!(section_params.merge(sidebar_urls_attributes: links_params))
|
||||
sidebar_section.sidebar_section_links.update_all(user_id: sidebar_section.user_id)
|
||||
end
|
||||
|
||||
if sidebar_section.public?
|
||||
StaffActionLogger.new(current_user).log_update_public_sidebar_section(sidebar_section)
|
||||
@ -95,7 +96,9 @@ class SidebarSectionsController < ApplicationController
|
||||
end
|
||||
|
||||
def section_params
|
||||
params.permit(:id, :title, :public)
|
||||
section_params = params.permit(:id, :title, :public)
|
||||
section_params.merge!(user: current_user) if !params[:public]
|
||||
section_params
|
||||
end
|
||||
|
||||
def links_params
|
||||
|
Reference in New Issue
Block a user