Newer
Older
# licensed under the Affero General Public License version 3 or later. See
Daniel Vincent Grippi
a validé
module SocketsHelper
def obj_id(object)
object.respond_to?(:post_id) ? object.post_id : object.id
user = User.find_by_id uid
v = render_to_string(:partial => 'shared/stream_element', :locals => {:post => object, :current_user => user})
elsif object.is_a? Person
v = render_to_string(:partial => type_partial(object), :locals => {:person => object, :current_user => user}) unless object.is_a? Retraction
else
v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction
end
Rails.logger.error("web socket view rendering failed for object #{object.inspect}.")
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
action_hash[:photo_hash] = object.thumb_hash
if object.is_a? Comment
action_hash[:my_post?] = (object.post.person.owner.id == uid)
action_hash[:notification] = notification(object)
action_hash[:mine?] = object.person && (object.person.owner.id == uid) if object.respond_to?(:person)
def notification(object)
begin
render_to_string(:partial => 'shared/notification', :locals => {:object => object})
rescue Exception => e
Rails.logger.error("web socket notification failed for object #{object.inspect}.")
end
end