about summary refs log tree commit diff
path: root/app/controllers/settings
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2016-11-23 23:31:38 +0000
committerAndrea Faulds <ajf@ajf.me>2016-11-24 00:30:58 +0000
commitcefef2c57197a06d403b9cbe13e969e08aaf5301 (patch)
treea25d334dd3b5ea3c8281b1f71dd13c89064faaf9 /app/controllers/settings
parent7161f91313b51c8425bd184dc5374084fd4e68a8 (diff)
Extract filename obfuscation into module
Diffstat (limited to 'app/controllers/settings')
-rw-r--r--app/controllers/settings/profiles_controller.rb17
1 files changed, 5 insertions, 12 deletions
diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb
index 9d9c0bb72..21fbba2af 100644
--- a/app/controllers/settings/profiles_controller.rb
+++ b/app/controllers/settings/profiles_controller.rb
@@ -6,6 +6,10 @@ class Settings::ProfilesController < ApplicationController
   before_action :authenticate_user!
   before_action :set_account
 
+  include ObfuscateFilename
+  obfuscate_filename [:account, :avatar]
+  obfuscate_filename [:account, :header]
+
   def show
   end
 
@@ -20,18 +24,7 @@ class Settings::ProfilesController < ApplicationController
   private
 
   def account_params
-    p = params.require(:account).permit(:display_name, :note, :avatar, :header, :silenced)
-    if p[:avatar]
-        avatar = p[:avatar]
-        # Change so Paperclip won't expose the actual filename
-        avatar.original_filename = "media" + File.extname(avatar.original_filename)
-    end
-    if p[:header]
-        header = p[:header]
-        # Change so Paperclip won't expose the actual filename
-        header.original_filename = "media" + File.extname(header.original_filename)
-    end
-    p
+    params.require(:account).permit(:display_name, :note, :avatar, :header, :silenced)
   end
 
   def set_account