From f971a5c4fb5da9c5f9b8de83ccbc4ee1d260fa0f Mon Sep 17 00:00:00 2001 From: SHIMOMURA Sho Date: Sun, 6 Jul 2014 22:08:01 +0900 Subject: [PATCH] update profile of current_user before it's used by plugins refs #197 --- app/controllers/api/v1/message_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/api/v1/message_controller.rb b/app/controllers/api/v1/message_controller.rb index ba9211a8b..f14a2e30a 100644 --- a/app/controllers/api/v1/message_controller.rb +++ b/app/controllers/api/v1/message_controller.rb @@ -63,6 +63,12 @@ def create files = (params["files"] || {}).values has_files = !(files.empty?) + profile = current_user.user_profiles.to_a.find{|profile| profile.room_id == room._id} + if profile + current_user.name = profile.name + current_user.profile_image_url = profile.profile_image_url + end + case message = Message.make(current_user, room, params[:message], has_files) when Message files.each {|file| message.attach(file)}