From b85dfd9dab9cc60173d2431bcced8c9e065d0109 Mon Sep 17 00:00:00 2001 From: SHIMOMURA Sho Date: Sun, 6 Jul 2014 22:08:01 +0900 Subject: [PATCH] update user profile before it's used by plugins refs #197 --- app/models/message.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/message.rb b/app/models/message.rb index 1b291b2b2..d3f0fdd80 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -57,6 +57,12 @@ def self.make(user, room, message_body, allow_empty=false) return :login_error if user.nil? return :empty_message if not allow_empty and message_body.strip.empty? + profile = user.user_profiles.to_a.find{|profile| profile.room_id == room._id} + if profile + user.name = profile.name + user.profile_image_url = profile.profile_image_url + end + message = Message.new(:room => room, :body => message_body || "", :user => user) if message.save then message else :error_on_save