Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

update profile of current_user before it's used by plugins refs #197 #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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