collection @notifications

attributes :description, :source_user_id, :target_user_id, :session_id, :recording_id, :invitation_id, :join_request_id, :friend_request_id, :band_id, :band_invitation_id, :formatted_msg, :message, :created_at, :lesson_session_id, :purpose

node :source_user do |n|
  source_user_data = {}
  if n.source_user
    source_user_data[:name] = n.source_user.name
  end
  source_user_data
end

node :notification_id do |n|
  n.id
end

# this has to be flat like this so this payload is the same as the protocol buffer (see initializeActions in sidebar.js)
node :fan_access do |n|
  unless n.music_session.nil?
    n.music_session.fan_access
  end
end

node :musician_access do |n|
  unless n.music_session.nil?
    n.music_session.musician_access
  end
end

node :approval_required do |n|
  unless n.music_session.nil?
    n.music_session.approval_required
  end
end
