add participant_users to conversations

This commit is contained in:
Jonne Hass 2011-11-05 12:09:15 +01:00
parent 9ee3b2d080
commit 655558cb95

View file

@ -36,11 +36,19 @@ class Conversation < ActiveRecord::Base
def participant_handles
self.participants.map{|p| p.diaspora_handle}.join(";")
end
def participant_handles= handles
handles.split(';').each do |handle|
self.participants << Webfinger.new(handle).fetch
end
end
def participant_users
@participant_users ||= lambda do
user_ids = self.participants.map {|p| p.owner_id}.compact
User.where(:id => user_ids)
end.call
end
def last_author
self.messages.last.author if self.messages.size > 0