diff --git a/pb/src/client_container.proto b/pb/src/client_container.proto index ed0647e95..0169de05e 100644 --- a/pb/src/client_container.proto +++ b/pb/src/client_container.proto @@ -101,6 +101,7 @@ message ClientMessage { optional SessionJoin session_join = 190; optional SessionDepart session_depart = 195; optional MusicianSessionJoin musician_session_join = 196; + optional BandSessionJoin band_session_join = 197; // recording notifications optional MusicianRecordingSaved musician_recording_saved = 200; @@ -112,7 +113,6 @@ message ClientMessage { // band notifications optional BandInvitation band_invitation = 225; optional BandInvitationAccepted band_invitation_accepted = 230; - optional BandSessionJoin band_session_join = 235; optional MusicianSessionFresh musician_session_fresh = 240; optional MusicianSessionStale musician_session_stale = 245; @@ -289,6 +289,14 @@ message MusicianSessionJoin { optional string created_at = 5; } +message BandSessionJoin { + optional string session_id = 1; + optional string photo_url = 2; + optional string msg = 3; + optional string notification_id = 4; + optional string created_at = 5; +} + message MusicianRecordingSaved { optional string recording_id = 1; optional string photo_url = 2; @@ -316,7 +324,10 @@ message RecordingEnded { } message RecordingMasterMixComplete { - + optional string recording_id = 1; + optional string msg = 2; + optional string notification_id = 3; + optional string created_at = 4; } message BandInvitation { @@ -336,14 +347,6 @@ message BandInvitationAccepted { optional string created_at = 5; } -message BandSessionJoin { - optional string session_id = 1; - optional string photo_url = 2; - optional string msg = 3; - optional string notification_id = 4; - optional string created_at = 5; -} - // route_to: client: // sent by server to let the rest of the participants know a client has become active again after going stale message MusicianSessionFresh { diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb index 54cfe8fa7..ed279577b 100644 --- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb @@ -126,6 +126,24 @@ send_notification(email, subject, msg, unique_args) end + def band_session_join(email, msg) + subject = "A band that you follow has joined a session" + unique_args = {:type => "band_session_join"} + send_notification(email, subject, msg, unique_args) + end + + def musician_recording_saved(email, msg) + subject = msg + unique_args = {:type => "musician_recording_saved"} + send_notification(email, subject, msg, unique_args) + end + + def band_recording_saved(email, msg) + subject = msg + unique_args = {:type => "band_recording_saved"} + send_notification(email, subject, msg, unique_args) + end + def band_invitation(email, msg) subject = "You have been invited to join a band on JamKazam" unique_args = {:type => "band_invitation"} @@ -138,12 +156,6 @@ send_notification(email, subject, msg, unique_args) end - def band_session_join(email, msg) - subject = "A band that you follow has joined a session" - unique_args = {:type => "band_session_join"} - send_notification(email, subject, msg, unique_args) - end - def send_notification(email, subject, msg, unique_args) @body = msg sendgrid_category "Notification" diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.html.erb index e69de29bb..daac81671 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.html.erb @@ -0,0 +1,3 @@ +<% provide(:title, 'New Band Invitation') %> + +
<%= @body %>
\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.text.erb index e69de29bb..2f21cf84a 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation.text.erb @@ -0,0 +1 @@ +<%= @body %> \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.html.erb index e69de29bb..91eb88c0b 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.html.erb @@ -0,0 +1,3 @@ +<% provide(:title, 'Band Invitation Accepted') %> + +<%= @body %>
\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.text.erb index e69de29bb..2f21cf84a 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_invitation_accepted.text.erb @@ -0,0 +1 @@ +<%= @body %> \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.html.erb index e69de29bb..e0a1a0008 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.html.erb @@ -0,0 +1,3 @@ +<% provide(:title, 'New Band Recording') %> + +<%= @body %>
\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.text.erb index e69de29bb..2f21cf84a 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/band_recording_saved.text.erb @@ -0,0 +1 @@ +<%= @body %> \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.html.erb index e69de29bb..8a0ff0a7a 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.html.erb @@ -0,0 +1,3 @@ +<% provide(:title, 'New Musician Recording') %> + +<%= @body %>
\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.text.erb index e69de29bb..2f21cf84a 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/musician_recording_saved.text.erb @@ -0,0 +1 @@ +<%= @body %> \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.html.erb index e69de29bb..7d74c64b8 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.html.erb @@ -0,0 +1,3 @@ +<% provide(:title, 'Recording Master Mix Completed') %> + +<%= @body %>
\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.text.erb index e69de29bb..2f21cf84a 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/recording_master_mix_complete.text.erb @@ -0,0 +1 @@ +<%= @body %> \ No newline at end of file diff --git a/ruby/lib/jam_ruby/message_factory.rb b/ruby/lib/jam_ruby/message_factory.rb index 1bd831be2..7bdcb0881 100644 --- a/ruby/lib/jam_ruby/message_factory.rb +++ b/ruby/lib/jam_ruby/message_factory.rb @@ -389,6 +389,22 @@ module JamRuby ) end + def band_session_join(receiver_id, session_id, photo_url, msg, notification_id, created_at) + band_session_join = Jampb::BandSessionJoin.new( + :session_id => session_id, + :photo_url => photo_url, + :msg => msg, + :notification_id => notification_id, + :created_at => created_at + ) + + return Jampb::ClientMessage.new( + :type => ClientMessage::Type::BAND_SESSION_JOIN, + :route_to => USER_TARGET_PREFIX + receiver_id, + :band_session_join => band_session_join + ) + end + def musician_recording_saved(receiver_id, recording_id, photo_url, msg, notification_id, created_at) musician_recording_saved = Jampb::MusicianRecordingSaved.new( :recording_id => recording_id, @@ -421,7 +437,7 @@ module JamRuby ) end - def recording_started(photo_url, msg) + def recording_started(receiver_id, photo_url, msg) recording_started = Jampb::RecordingStarted.new( :photo_url => photo_url, :msg => msg @@ -429,12 +445,12 @@ module JamRuby return Jampb::ClientMessage.new( :type => ClientMessage::Type::RECORDING_STARTED, - :route_to => CLIENT_TARGET, + :route_to => USER_TARGET_PREFIX + receiver_id, :recording_started => recording_started ) end - def recording_ended(photo_url, msg) + def recording_ended(receiver_id, photo_url, msg) recording_ended = Jampb::RecordingEnded.new( :photo_url => photo_url, :msg => msg @@ -442,7 +458,7 @@ module JamRuby return Jampb::ClientMessage.new( :type => ClientMessage::Type::RECORDING_ENDED, - :route_to => CLIENT_TARGET, + :route_to => USER_TARGET_PREFIX + receiver_id, :recording_ended => recording_ended ) end @@ -485,22 +501,6 @@ module JamRuby ) end - def band_session_join(session_id, photo_url, msg, notification_id, created_at) - band_session_join = Jampb::BandSessionJoin.new( - :session_id => session_id, - :photo_url => photo_url, - :msg => msg, - :notification_id => notification_id, - :created_at => created_at - ) - - return Jampb::ClientMessage.new( - :type => ClientMessage::Type::BAND_SESSION_JOIN, - :route_to => USER_TARGET_PREFIX + receiver_id, - :band_session_join => band_session_join - ) - end - # create a musician fresh session message def musician_session_fresh(session_id, user_id, username, photo_url) fresh = Jampb::MusicianSessionFresh.new( diff --git a/ruby/lib/jam_ruby/models/notification.rb b/ruby/lib/jam_ruby/models/notification.rb index 9cd041b4f..6f054bbac 100644 --- a/ruby/lib/jam_ruby/models/notification.rb +++ b/ruby/lib/jam_ruby/models/notification.rb @@ -151,6 +151,9 @@ module JamRuby when NotificationTypes::MUSICIAN_SESSION_JOIN return "#{name} is now in a session." + when NotificationTypes::BAND_SESSION_JOIN + return "#{band_name} is now in a session." + # recording notifications when NotificationTypes::MUSICIAN_RECORDING_SAVED @@ -176,9 +179,6 @@ module JamRuby when NotificationTypes::BAND_INVITATION_ACCEPTED return "#{name} has accepted your band invitation to join #{band_name}." - when NotificationTypes::BAND_SESSION_JOIN - return "#{band_name} is now in a session." - else return "" end @@ -510,80 +510,189 @@ module JamRuby end end - def send_musician_recording_saved(recording, user) + def send_band_session_join(music_session, band) - ids = retrieve_friends_and_followers(connection, user_id) + # if the session is private, don't send any notifications + if music_session.musician_access || music_session.fan_access - notification = Notification.new - notification.description = NotificationTypes::MUSICIAN_RECORDING_SAVED - notification.source_user_id = user.id - notification.target_user_id = join_request.user.id - notification.session_id = music_session.id - notification.save + band_followers = BandFollower.where(:band_id => band.id) - notification_msg = format_msg(notification.description, user) + unless band_followers.empty? + notifications, online_followers, offline_followers = [] - msg = @@message_factory.musician_recording_saved( - join_request.id, - music_session.id, - music_session.creator.name, - music_session.creator.photo_url, - notification_msg, - notification.id, - notification.created_at.to_s - ) + band_followers.each do |bf| + if (bf.follower.musician && music_session.musician_access) || (!bf.follower.musician && music_session.fan_access) + notification = Notification.new + notification.band_id = band.id + notification.description = NotificationTypes::BAND_SESSION_JOIN + notification.target_user_id = receiver.id + notification.save + # notifications << notification + bf.follower.online ? online_followers << bf.follower : offline_followers << bf.follower + end + end - @@mq_router.publish_to_friends(ids, msg, sender = {:client_id => connection.client_id}) + # this was throwing an error related to the split method. (activerecord-import gem) + # unless notifications.empty? + # Notification.import notifications + # end + + notification_msg = format_msg(NotificationTypes::BAND_SESSION_JOIN, nil, band) + + # send real-time notifications + unless online_followers.empty? + msg = @@message_factory.band_session_join( + receiver.id, + music_session.id, + band.name, + band.photo_url, + notification_msg, + notification.id, + notification.created_at.to_s + ) + + @@mq_router.publish_to_friends(online_followers.map! {|f| f.id}, msg, band.id) + end + + # send email notifications + unless offline_followers.empty? + UserMailer.band_session_join(offline_followers.map! {|f| f.email}, msg) + end + end + end end - def send_band_recording_saved(recording, user) + def send_musician_recording_saved(recording) - ids = retrieve_friends_and_followers(connection, user_id) + if music_session.musician_access || music_session.fan_access - notification = Notification.new - notification.description = NotificationTypes::MUSICIAN_RECORDING_SAVED - notification.source_user_id = user.id - notification.target_user_id = join_request.user.id - notification.session_id = music_session.id - notification.save + user = recording.owner - notification_msg = format_msg(notification.description, user) + friends = Friendship.where(:friend_id => user.id) + user_followers = UserFollower.where(:user_id => user.id) - msg = @@message_factory.band_recording_saved( - join_request.id, - music_session.id, - music_session.creator.name, - music_session.creator.photo_url, - notification_msg, - notification.id, - notification.created_at.to_s - ) + friend_users = friends.map { |fu| fu.friend } + follower_users = user_followers.map { |uf| uf.follower } + friends_and_followers = friend_users.concat(follower_users) - @@mq_router.publish_to_friends(ids, msg, sender = {:client_id => connection.client_id}) + unless friends_and_followers.empty? + + friends_and_followers = friends_and_followers - music_session.users + + notifications, online_ff, offline_ff = [] + + friends_and_followers.each do |ff| + notification = Notification.new + notification.description = NotificationTypes::MUSICIAN_SESSION_JOIN + notification.source_user_id = user.id + notification.target_user_id = ff.id + notification.save + # notifications << notification + ff.online ? online_ff << ff : offline_ff << ff + end + + # unless notifications.empty? + # Notification.import notifications + # end + + notification_msg = format_msg(NotificationTypes::MUSICIAN_RECORDING_SAVED, user) + + # send real-time notifications + online_followers.each do |of| + msg = @@message_factory.musician_recording_saved( + of.id, + recording.id, + user.photo_url, + notification_msg, + notification.id, + notification.created_at.to_s + ) + + @@mq_router.publish_to_user(of.id, notification_msg) + end + + # send email notifications + unless offline_ff.empty? + UserMailer.musician_recording_saved(offline_ff.map! {|f| f.email}, msg) + end + end + end + end + + def send_band_recording_saved(recording) + + band_followers = BandFollower.where(:band_id => band.id) + + band_followers.each do |bf| + notification = Notification.new + notification.description = NotificationTypes::BAND_RECORDING_SAVED + notification.band_id = band.id + notification.target_user_id = bf.follower.id + notification.recording_id = recording.id + notification.save + # notifications << notification + bf.follower.online ? online_followers << bf.follower : offline_followers << bf.follower + end + + # this was throwing an error related to the split method. (activerecord-import gem) + # unless notifications.empty? + # Notification.import notifications + # end + + notification_msg = format_msg(NotificationTypes::BAND_RECORDING_SAVED, nil, recording.band) + + # send real-time notifications + online_followers.each do |of| + msg = @@message_factory.band_recording_saved( + of.id, + recording.id, + band.photo_url, + notification_msg, + notification.id, + notification.created_at.to_s + ) + + @@mq_router.publish_to_user(of.id, notification_msg) + end + + # send email notifications + unless offline_followers.empty? + UserMailer.band_recording_saved(offline_followers.map! {|f| f.email}, msg) + end end def send_recording_started(music_session, connection, user) notification_msg = format_msg(NotificationTypes::RECORDING_STARTED, user) - msg = @@message_factory.recording_started( - user.photo_url, - notification_msg - ) + music_session.users.each do |musician| + if musician.id != user.id + msg = @@message_factory.recording_started( + musician.id, + user.photo_url, + notification_msg + ) - @@mq_router.server_publish_to_session(music_session, msg, sender = {:client_id => connection.client_id}) + @@mq_router.publish_to_user(musician.id, msg) + end + end end def send_recording_ended(music_session, connection, user) notification_msg = format_msg(NotificationTypes::RECORDING_ENDED, user) - msg = @@message_factory.recording_ended( - user.photo_url, - notification_msg - ) + music_session.users.each do |musician| + if musician.id != user.id + msg = @@message_factory.recording_ended( + musician.id, + user.photo_url, + notification_msg + ) - @@mq_router.server_publish_to_session(music_session, msg, sender = {:client_id => connection.client_id}) + @@mq_router.publish_to_user(musician.id, msg) + end + end end def send_recording_master_mix_complete(recording) @@ -646,58 +755,6 @@ module JamRuby end end - def send_band_session_join(music_session, band) - - # if the session is private, don't send any notifications - if music_session.musician_access || music_session.fan_access - - band_followers = BandFollower.where(:band_id => band.id) - - unless band_followers.empty? - notifications, online_followers, offline_followers = [] - - band_followers.each do |bf| - if (bf.follower.musician && music_session.musician_access) || (!bf.follower.musician && music_session.fan_access) - notification = Notification.new - notification.band_id = band.id - notification.description = NotificationTypes::BAND_SESSION_JOIN - notification.target_user_id = receiver.id - notification.save - # notifications << notification - bf.follower.online ? online_followers << bf.follower : offline_followers << bf.follower - end - end - - # this was throwing an error related to the split method. (activerecord-import gem) - # unless notifications.empty? - # Notification.import notifications - # end - - notification_msg = format_msg(NotificationTypes::BAND_SESSION_JOIN, nil, band) - - # send real-time notifications - unless online_followers.empty? - msg = @@message_factory.band_session_join( - receiver.id, - music_session.id, - band.name, - band.photo_url, - notification_msg, - notification.id, - notification.created_at.to_s - ) - - @@mq_router.publish_to_friends(online_followers.map! {|f| f.id}, msg, band.id) - end - - # send email notifications - unless offline_followers.empty? - UserMailer.band_session_join(offline_followers.map! {|f| f.email}, msg) - end - end - end - end - def send_musician_session_fresh(music_session, client_id, user) msg = @@message_factory.musician_session_fresh( diff --git a/web/app/assets/javascripts/AAB_message_factory.js b/web/app/assets/javascripts/AAB_message_factory.js index 36f232b14..e45d11c86 100644 --- a/web/app/assets/javascripts/AAB_message_factory.js +++ b/web/app/assets/javascripts/AAB_message_factory.js @@ -34,6 +34,7 @@ SESSION_JOIN : "SESSION_JOIN", SESSION_DEPART : "SESSION_DEPART", MUSICIAN_SESSION_JOIN : "MUSICIAN_SESSION_JOIN", + BAND_SESSION_JOIN : "BAND_SESSION_JOIN", // recording notifications MUSICIAN_RECORDING_SAVED : "MUSICIAN_RECORDING_SAVED", @@ -45,7 +46,6 @@ // band notifications BAND_INVITATION : "BAND_INVITATION", BAND_INVITATION_ACCEPTED : "BAND_INVITATION_ACCEPTED", - BAND_SESSION_JOIN : "BAND_SESSION_JOIN", TEST_SESSION_MESSAGE : "TEST_SESSION_MESSAGE", PING_REQUEST : "PING_REQUEST", diff --git a/web/app/assets/javascripts/sidebar.js b/web/app/assets/javascripts/sidebar.js index 60a01db70..c1c2eacad 100644 --- a/web/app/assets/javascripts/sidebar.js +++ b/web/app/assets/javascripts/sidebar.js @@ -443,6 +443,7 @@ registerSessionJoin(); registerSessionDepart(); registerMusicianSessionJoin(); + registerBandSessionJoin(); // recording notifications registerMusicianRecordingSaved(); @@ -454,7 +455,6 @@ // band notifications registerBandInvitation(); registerBandInvitationAccepted(); - registerBandSessionJoin(); // watch for Invite More Users events $('#sidebar-div .btn-email-invitation').click(function() { @@ -608,7 +608,7 @@ } function registerSessionEnded() { - + // TODO: this should clean up all notifications related to this session } function registerJoinRequest() { @@ -695,8 +695,10 @@ context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SESSION_DEPART, function(header, payload) { logger.debug("Handling SESSION_DEPART msg " + JSON.stringify(payload)); - if(payload.recording_id && context.JK.CurrentSessionModel.recordingModel.isRecording(payload.recording_id)) { - context.JK.CurrentSessionModel.recordingModel.onServerStopRecording(payload.recording_id); + var recordingId = payload.recording_id; + + if(recordingId&& context.JK.CurrentSessionModel.recordingModel.isRecording(recordingId)) { + context.JK.CurrentSessionModel.recordingModel.onServerStopRecording(recordingId); /**app.notify({ "title": "Recording Stopped", "text": payload.username + " has left the session.", @@ -723,16 +725,84 @@ "title": "Musician Joined Session", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, { + "ok_text": "LISTEN", + "ok_callback": listenToSession, + "ok_callback_args": { + "session_id": payload.session_id + } + }); }); } + function registerBandSessionJoin() { + context.JK.JamServer.registerMessageCallback(context.JK.MessageType.BAND_SESSION_JOIN, function(header, payload) { + logger.debug("Handling BAND_SESSION_JOIN msg " + JSON.stringify(payload)); + + handleNotification(payload, header.type); + + // TODO: add LISTEN button linking to session + app.notify({ + "title": "Band Joined Session", + "text": payload.msg, + "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) + }, { + "ok_text": "LISTEN", + "ok_callback": listenToSession, + "ok_callback_args": { + "session_id": payload.session_id + } + }); + }); + } + + function listenToSession(args) { + var sessionId = args.session_id; + } + function registerMusicianRecordingSaved() { + context.JK.JamServer.registerMessageCallback(context.JK.MessageType.MUSICIAN_RECORDING_SAVED, function(header, payload) { + logger.debug("Handling MUSICIAN_RECORDING_SAVED msg " + JSON.stringify(payload)); + + handleNotification(payload, header.type); + + app.notify({ + "title": "Musician Recording Saved", + "text": payload.msg, + "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) + }, { + "ok_text": "LISTEN", + "ok_callback": listenToRecording, + "ok_callback_args": { + "recording_id": payload.recording_id + } + }); + }); } function registerBandRecordingSaved() { + context.JK.JamServer.registerMessageCallback(context.JK.MessageType.BAND_RECORDING_SAVED, function(header, payload) { + logger.debug("Handling BAND_RECORDING_SAVED msg " + JSON.stringify(payload)); + handleNotification(payload, header.type); + + app.notify({ + "title": "Band Recording Saved", + "text": payload.msg, + "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) + }, { + "ok_text": "LISTEN", + "ok_callback": listenToRecording, + "ok_callback_args": { + "recording_id": payload.recording_id + } + }); + }); + } + + function listenToRecording(args) { + var recordingId = args.recording_id; } function registerRecordingStarted() { @@ -760,7 +830,27 @@ } function registerRecordingMasterMixComplete() { + context.JK.JamServer.registerMessageCallback(context.JK.MessageType.RECORDING_MASTER_MIX_COMPLETE, function(header, payload) { + logger.debug("Handling RECORDING_MASTER_MIX_COMPLETE msg " + JSON.stringify(payload)); + handleNotification(payload, header.type); + + app.notify({ + "title": "Recording Master Mix Complete", + "text": payload.msg, + "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) + }, { + "ok_text": "SHARE", + "ok_callback": shareRecording, + "ok_callback_args": { + "recording_id": payload.recording_id + } + }); + }); + } + + function shareRecording(args) { + var recordingId = args.recording_id; } function registerBandInvitation() { @@ -809,21 +899,6 @@ }); } - function registerBandSessionJoin() { - context.JK.JamServer.registerMessageCallback(context.JK.MessageType.BAND_SESSION_JOIN, function(header, payload) { - logger.debug("Handling BAND_SESSION_JOIN msg " + JSON.stringify(payload)); - - handleNotification(payload, header.type); - - // TODO: add LISTEN button linking to session - app.notify({ - "title": "Band Joined Session", - "text": payload.msg, - "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); - }); - } - this.initialize = function(invitationDialogInstance) { events(); initializeFriendsPanel();