Skip to content

Commit

Permalink
update user profile before it's used by plugins refs codefirst#197
Browse files Browse the repository at this point in the history
  • Loading branch information
shimomura1004 committed Jul 6, 2014
1 parent fbec21a commit b85dfd9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b85dfd9

Please sign in to comment.