Add privacy tab in profile settings (#26484)
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
This commit is contained in:
		
							
								
								
									
										27
									
								
								app/controllers/settings/privacy_controller.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/controllers/settings/privacy_controller.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class Settings::PrivacyController < Settings::BaseController
 | 
			
		||||
  before_action :set_account
 | 
			
		||||
 | 
			
		||||
  def show; end
 | 
			
		||||
 | 
			
		||||
  def update
 | 
			
		||||
    if UpdateAccountService.new.call(@account, account_params.except(:settings))
 | 
			
		||||
      current_user.update!(settings_attributes: account_params[:settings])
 | 
			
		||||
      ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
 | 
			
		||||
      redirect_to settings_privacy_path, notice: I18n.t('generic.changes_saved_msg')
 | 
			
		||||
    else
 | 
			
		||||
      render :show
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def account_params
 | 
			
		||||
    params.require(:account).permit(:discoverable, :locked, :hide_collections, settings: UserSettings.keys)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_account
 | 
			
		||||
    @account = current_account
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@@ -20,7 +20,7 @@ class Settings::ProfilesController < Settings::BaseController
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def account_params
 | 
			
		||||
    params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :bot, :discoverable, :hide_collections, fields_attributes: [:name, :value])
 | 
			
		||||
    params.require(:account).permit(:display_name, :note, :avatar, :header, :bot, fields_attributes: [:name, :value])
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_account
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user