From 14bd46946d25186044485aa101dd2da976b61181 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 30 Nov 2016 21:32:11 +0100 Subject: Per-status control for unlisted mode, also federation for unlisted mode Fix #233, fix #268 --- app/controllers/api/v1/statuses_controller.rb | 4 ++-- app/controllers/concerns/obfuscate_filename.rb | 17 +++++++++++++++++ app/controllers/settings/profiles_controller.rb | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 app/controllers/concerns/obfuscate_filename.rb (limited to 'app/controllers') diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index a0b15cfbc..8b7690850 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -52,7 +52,7 @@ class Api::V1::StatusesController < ApiController end def create - @status = PostStatusService.new.call(current_user.account, params[:status], params[:in_reply_to_id].blank? ? nil : Status.find(params[:in_reply_to_id]), media_ids: params[:media_ids], sensitive: params[:sensitive]) + @status = PostStatusService.new.call(current_user.account, params[:status], params[:in_reply_to_id].blank? ? nil : Status.find(params[:in_reply_to_id]), media_ids: params[:media_ids], sensitive: params[:sensitive], unlisted: params[:unlisted]) render action: :show end @@ -73,7 +73,7 @@ class Api::V1::StatusesController < ApiController @reblogged_map = { @status.id => false } RemovalWorker.perform_async(reblog.id) - + render action: :show end diff --git a/app/controllers/concerns/obfuscate_filename.rb b/app/controllers/concerns/obfuscate_filename.rb new file mode 100644 index 000000000..9f12cb7e9 --- /dev/null +++ b/app/controllers/concerns/obfuscate_filename.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +module ObfuscateFilename + extend ActiveSupport::Concern + + class_methods do + def obfuscate_filename(*args) + before_action { obfuscate_filename(*args) } + end + end + + def obfuscate_filename(path) + file = params.dig(*path) + return if file.nil? + + file.original_filename = 'media' + File.extname(file.original_filename) + end +end diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 21fbba2af..0276f5fed 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -24,7 +24,7 @@ class Settings::ProfilesController < ApplicationController private def account_params - params.require(:account).permit(:display_name, :note, :avatar, :header, :silenced) + params.require(:account).permit(:display_name, :note, :avatar, :header) end def set_account -- cgit