VRFS-1668 initial work on new notifications / refactor to make notification buttons more dynamic

This commit is contained in:
Brian Smith 2014-05-13 01:22:23 -04:00
parent 9948917f95
commit 2302c89154
11 changed files with 510 additions and 197 deletions

View File

@ -153,3 +153,4 @@ rename_chat_messages.sql
fix_connection_fields.sql
session_ratings.sql
scheduled_sessions.sql
notification_scheduled_session.sql

View File

@ -0,0 +1 @@
alter table notifications alter column description TYPE varchar(100);

View File

@ -27,15 +27,25 @@ message ClientMessage {
NEW_BAND_FOLLOWER = 161;
// session invitations
SESSION_INVITATION = 165;
SESSION_ENDED = 170;
JOIN_REQUEST = 175;
JOIN_REQUEST_APPROVED = 180;
JOIN_REQUEST_REJECTED = 185;
SESSION_JOIN = 190;
SESSION_DEPART = 195;
MUSICIAN_SESSION_JOIN = 196;
TRACKS_CHANGED = 197;
SESSION_INVITATION = 165;
SESSION_ENDED = 166;
JOIN_REQUEST = 167;
JOIN_REQUEST_APPROVED = 168;
JOIN_REQUEST_REJECTED = 169;
SESSION_JOIN = 170;
SESSION_DEPART = 171;
MUSICIAN_SESSION_JOIN = 172;
TRACKS_CHANGED = 173;
SCHEDULED_SESSION_INVITATION = 174;
SCHEDULED_SESSION_RSVP = 175;
SCHEDULED_SESSION_RSVP_APPROVED = 176;
SCHEDULED_SESSION_RSVP_CANCELLED = 177;
SCHEDULED_SESSION_RSVP_CANCELLED_ORG = 178;
SCHEDULED_SESSION_CANCELLED = 179;
SCHEDULED_SESSION_RESCHEDULED = 180;
SCHEDULED_SESSION_REMINDER = 181;
SCHEDULED_SESSION_COMMENT = 182;
// recording notifications
MUSICIAN_RECORDING_SAVED = 200;
@ -106,15 +116,24 @@ message ClientMessage {
optional NewBandFollower new_band_follower = 161;
// session invitations
optional SessionInvitation session_invitation = 165; // from server to user
optional SessionEnded session_ended = 170;
optional JoinRequest join_request = 175;
optional JoinRequestApproved join_request_approved = 180;
optional JoinRequestRejected join_request_rejected = 185;
optional SessionJoin session_join = 190;
optional SessionDepart session_depart = 195;
optional MusicianSessionJoin musician_session_join = 196;
optional TracksChanged tracks_changed = 197;
optional SessionInvitation session_invitation = 165; // from server to user
optional SessionEnded session_ended = 166;
optional JoinRequest join_request = 167;
optional JoinRequestApproved join_request_approved = 168;
optional JoinRequestRejected join_request_rejected = 169;
optional SessionJoin session_join = 170;
optional SessionDepart session_depart = 171;
optional MusicianSessionJoin musician_session_join = 172;
optional TracksChanged tracks_changed = 173;
optional ScheduledSessionInvitation scheduled_session_invitation = 174;
optional ScheduledSessionRsvp scheduled_session_rsvp = 175;
optional ScheduledSessionRsvpApproved scheduled_session_rsvp_approved = 176;
optional ScheduledSessionRsvpCancelled scheduled_session_rsvp_cancelled = 177;
optional ScheduledSessionRsvpCancelledOrg scheduled_session_rsvp_cancelled_org = 178;
optional ScheduledSessionCancelled scheduled_session_cancelled = 179;
optional ScheduledSessionRescheduled scheduled_session_rescheduled = 180;
optional ScheduledSessionReminder scheduled_session_reminder = 181;
optional ScheduledSessionComment scheduled_session_comment = 182;
// recording notifications
optional MusicianRecordingSaved musician_recording_saved = 200;
@ -324,6 +343,56 @@ message MusicianSessionJoin {
optional string created_at = 8;
}
message ScheduledSessionInvitation {
optional string session_id = 1;
optional string photo_url = 2;
optional string msg = 3;
optional string session_name = 4;
optional string session_date = 5;
optional string notification_id = 6;
optional string created_at = 7;
}
message ScheduledSessionRsvp {
optional string session_id = 1;
optional string photo_url = 2;
optional string msg = 3;
optional string slot_id = 4;
optional string instruments = 5;
optional string session_name = 6;
optional string session_date = 7;
optional string notification_id = 8;
optional string created_at = 9;
}
message ScheduledSessionRsvpApproved {
}
message ScheduledSessionRsvpCancelled {
}
message ScheduledSessionRsvpCancelledOrg {
}
message ScheduledSessionCancelled {
}
message ScheduledSessionRescheduled {
}
message ScheduledSessionReminder {
}
message ScheduledSessionComment {
}
message MusicianRecordingSaved {
optional string recording_id = 1;
optional string photo_url = 2;

View File

@ -218,6 +218,33 @@
end
end
def scheduled_session_invitation(email, msg, session_id)
end
def scheduled_session_rsvp(email, msg)
end
def scheduled_session_approved(email, msg)
end
def scheduled_session_rsvp_cancelled(email, msg)
end
def scheduled_session_rsvp_cancelled_org(email, msg)
end
def scheduled_session_cancelled(email, msg)
end
def scheduled_session_rescheduled(email, msg)
end
def scheduled_session_reminder(email, msg)
end
def scheduled_session_comment(email, msg)
end
def band_session_join(email, msg, session_id)
subject = "A band that you follow has joined a session"
unique_args = {:type => "band_session_join"}

View File

@ -18,6 +18,17 @@ module NotificationTypes
SESSION_DEPART = "SESSION_DEPART"
MUSICIAN_SESSION_JOIN = "MUSICIAN_SESSION_JOIN"
# scheduled sessions
SCHEDULED_SESSION_INVITATION = "SCHEDULED_SESSION_INVITATION"
SCHEDULED_SESSION_RSVP = "SCHEDULED_SESSION_RSVP"
SCHEDULED_SESSION_RSVP_APPROVED = "SCHEDULED_SESSION_RSVP_APPROVED"
SCHEDULED_SESSION_RSVP_CANCELLED = "SCHEDULED_SESSION_RSVP_CANCELLED"
SCHEDULED_SESSION_RSVP_CANCELLED_ORG = "SCHEDULED_SESSION_RSVP_CANCELLED_ORG"
SCHEDULED_SESSION_CANCELLED = "SCHEDULED_SESSION_CANCELLED"
SCHEDULED_SESSION_RESCHEDULED = "SCHEDULED_SESSION_RESCHEDULED"
SCHEDULED_SESSION_REMINDER = "SCHEDULED_SESSION_REMINDER"
SCHEDULED_SESSION_COMMENT = "SCHEDULED_SESSION_COMMENT"
# recording notifications
MUSICIAN_RECORDING_SAVED = "MUSICIAN_RECORDING_SAVED"
BAND_RECORDING_SAVED = "BAND_RECORDING_SAVED"

View File

@ -434,6 +434,52 @@ module JamRuby
)
end
def scheduled_session_invitation(receiver_id, session_id, photo_url, msg, session_name, session_date, notification_id, created_at)
scheduled_session_invitation = Jampb::ScheduledSessionInvitation.new(
:session_id => session_id,
:photo_url => photo_url,
:msg => msg,
:session_name => session_name,
:session_date => session_date,
:notification_id => notification_id,
:created_at => created_at
)
Jampb::ClientMessage.new(
:type => ClientMessage::Type::SCHEDULED_SESSION_INVITATION,
:route_to => USER_TARGET_PREFIX + receiver_id,
:scheduled_session_invitation => scheduled_session_invitation
)
end
# SCHEDULED_SESSION_RSVP = 175;
# SCHEDULED_SESSION_RSVP_APPROVED = 176;
# SCHEDULED_SESSION_RSVP_CANCELLED = 177;
# SCHEDULED_SESSION_RSVP_CANCELLED_ORG = 178;
# SCHEDULED_SESSION_CANCELLED = 179;
# SCHEDULED_SESSION_RESCHEDULED = 180;
# SCHEDULED_SESSION_REMINDER = 181;
# SCHEDULED_SESSION_COMMENT = 182;
def scheduled_session_rsvp(receiver_id, session_id, photo_url, msg, slots, instruments, session_name, session_date, notification_id, created_at)
scheduled_session_rsvp = Jampb::ScheduledSessionRsvp.new(
:session_id => session_id,
:photo_url => photo_url,
:msg => msg,
:session_name => session_name,
:session_date => session_date,
:notification_id => notification_id,
:created_at => created_at
)
Jampb::ClientMessage.new(
:type => ClientMessage::Type::SCHEDULED_SESSION_RSVP,
:route_to => USER_TARGET_PREFIX + receiver_id,
:scheduled_session_rsvp => scheduled_session_rsvp
)
end
def band_session_join(receiver_id, session_id, photo_url, fan_access, musician_access, approval_required, msg, notification_id, created_at)
band_session_join = Jampb::BandSessionJoin.new(
:session_id => session_id,

View File

@ -10,7 +10,7 @@ module JamRuby
belongs_to :target_user, :class_name => "JamRuby::User", :foreign_key => "target_user_id"
belongs_to :source_user, :class_name => "JamRuby::User", :foreign_key => "source_user_id"
belongs_to :band, :class_name => "JamRuby::Band", :foreign_key => "band_id"
belongs_to :session, :class_name => "JamRuby::ActiveMusicSession", :foreign_key => "session_id"
belongs_to :music_session, :class_name => "JamRuby::MusicSession", :foreign_key => "music_session_id"
belongs_to :recording, :class_name => "JamRuby::Recording", :foreign_key => "recording_id"
validates :target_user, :presence => true
@ -50,7 +50,7 @@ module JamRuby
band = Band.find(self.band_id)
end
self.class.format_msg(self.description, source_user, band)
self.class.format_msg(self.description, {:user => source_user, :band => band})
end
# TODO: MAKE ALL METHODS BELOW ASYNC SO THE CLIENT DOESN'T BLOCK ON NOTIFICATION LOGIC
@ -111,7 +111,12 @@ module JamRuby
return ids
end
def format_msg(description, user = nil, band = nil)
def format_msg(description, options)
user = options[:user]
band = options[:band]
session = options[:session]
name, band_name = ""
unless user.nil?
name = user.name
@ -143,7 +148,7 @@ module JamRuby
# session notifications
when NotificationTypes::SESSION_INVITATION
return "#{name} has invited you to a session."
return "You have been invited to join a session by #{name}."
when NotificationTypes::JOIN_REQUEST
return "#{name} has requested to join your session."
@ -166,6 +171,32 @@ module JamRuby
when NotificationTypes::BAND_SESSION_JOIN
return "#{band_name} is now in a session."
when NotificationTypes::SCHEDULED_SESSION_INVITATION
return "You have been invited to join a session by #{name}."
when NotificationTypes::SCHEDULED_SESSION_RSVP
return "#{name} would like to play in a session you have scheduled."
when NotificationTypes::SCHEDULED_SESSION_RSVP_APPROVED
return "Your RSVP to a scheduled session has been approved!"
when NotificationTypes::SCHEDULED_SESSION_RSVP_CANCELLED
return "A musician has cancelled an RSVP to your session."
when NotificationTypes::SCHEDULED_SESSION_RSVP_CANCELLED_ORG
return "The session organizer has cancelled this session."
when NotificationTypes::SCHEDULED_SESSION_CANCELLED
return "The session organizer has cancelled this session:"
when NotificationTypes::SCHEDULED_SESSION_RESCHEDULED
return "The following session has been rescheduled:"
when NotificationTypes::SCHEDULED_SESSION_REMINDER
return "A session to which you have RSVPd will begin in one hour, so get ready to play!"
when NotificationTypes::SCHEDULED_SESSION_COMMENT
return "New message about session:"
# recording notifications
when NotificationTypes::MUSICIAN_RECORDING_SAVED
@ -204,7 +235,7 @@ module JamRuby
user = User.find(user_id)
online_msg = online ? "online." : "offline."
notification_msg = format_msg(NotificationTypes::FRIEND_UPDATE, user) + online_msg
notification_msg = format_msg(NotificationTypes::FRIEND_UPDATE, {:user => user}) + online_msg
msg = @@message_factory.friend_update(
user.id,
user.photo_url,
@ -227,7 +258,7 @@ module JamRuby
notification.friend_request_id = friend_request_id
notification.save
notification_msg = format_msg(notification.description, user)
notification_msg = format_msg(notification.description, {:user => user})
if friend.online
msg = @@message_factory.friend_request(
@ -256,7 +287,7 @@ module JamRuby
notification.target_user_id = user_id
notification.save
notification_msg = format_msg(notification.description, friend)
notification_msg = format_msg(notification.description, {:user => friend})
if user.online
msg = @@message_factory.friend_request_accepted(
@ -282,7 +313,7 @@ module JamRuby
notification.target_user_id = user.id
notification.save
notification_msg = format_msg(notification.description, follower)
notification_msg = format_msg(notification.description, {:user => follower})
if follower.id != user.id
if user.online
@ -315,7 +346,7 @@ module JamRuby
notification.band_id = band.id
notification.save
notification_msg = format_msg(notification.description, follower, band)
notification_msg = format_msg(notification.description, {:user => follower, :band => band})
# this protects against sending the notification to a band member who decides to follow the band
if follower.id != bm.user.id
@ -346,7 +377,7 @@ module JamRuby
notification.session_id = session_id
notification.save
notification_msg = format_msg(NotificationTypes::SESSION_INVITATION, sender)
notification_msg = format_msg(NotificationTypes::SESSION_INVITATION, {:user => sender})
if receiver.online
msg = @@message_factory.session_invitation(
@ -389,7 +420,7 @@ module JamRuby
notification.session_id = music_session.id
notification.save
notification_msg = format_msg(notification.description, join_request.user)
notification_msg = format_msg(notification.description, {:user => join_request.user})
msg = @@message_factory.join_request(
join_request.id,
@ -412,7 +443,7 @@ module JamRuby
notification.session_id = music_session.id
notification.save
notification_msg = format_msg(notification.description, music_session.creator)
notification_msg = format_msg(notification.description, {:user => music_session.creator})
msg = @@message_factory.join_request_approved(
join_request.id,
@ -435,7 +466,7 @@ module JamRuby
notification.session_id = music_session.id
notification.save
notification_msg = format_msg(notification.description, music_session.creator)
notification_msg = format_msg(notification.description, {:user => music_session.creator})
msg = @@message_factory.join_request_rejected(
join_request.id,
@ -451,7 +482,7 @@ module JamRuby
def send_session_join(music_session, connection, user)
notification_msg = format_msg(NotificationTypes::SESSION_JOIN, user)
notification_msg = format_msg(NotificationTypes::SESSION_JOIN, {:user => user})
msg = @@message_factory.session_join(
music_session.id,
@ -465,7 +496,7 @@ module JamRuby
def send_session_depart(music_session, client_id, user, recordingId)
notification_msg = format_msg(NotificationTypes::SESSION_DEPART, user)
notification_msg = format_msg(NotificationTypes::SESSION_DEPART, {:user => user})
msg = @@message_factory.session_depart(
music_session.id,
@ -486,7 +517,7 @@ module JamRuby
@@mq_router.server_publish_to_session(music_session, msg)
end
def send_musician_session_join(music_session, connection, user)
def send_musician_session_join(music_session, user)
if music_session.musician_access || music_session.fan_access
@ -501,7 +532,7 @@ module JamRuby
# remove anyone in the session and invited musicians
friends_and_followers = friends_and_followers - music_session.users - music_session.invited_musicians
notifications, online_ff, offline_ff = [], [], []
notification_msg = format_msg(NotificationTypes::MUSICIAN_SESSION_JOIN, user)
notification_msg = format_msg(NotificationTypes::MUSICIAN_SESSION_JOIN, {:user => user})
friends_and_followers.each do |ff|
notification = Notification.new
@ -541,13 +572,61 @@ module JamRuby
end
end
def send_scheduled_session_invitation(music_session, user)
notification = Notification.new
notification.description = NotificationTypes::SCHEDULED_SESSION_INVITATION
notification.source_user_id = music_session.creator.id
notification.target_user_id = user.id
notification.session_id = music_session.id
notification.save
notification_msg = format_msg(notification.description, {:user => music_session.creator, :session => music_session})
msg = @@message_factory.scheduled_session_invitation(
user.id,
music_session.id,
music_session.creator.photo_url,
notification_msg,
music_session.description,
music_session.scheduled_start,
notification.id,
notification.created_date
)
@@mq_router.publish_to_user(user.id, msg)
end
def send_scheduled_session_rsvp(music_session, user, rsvp_requests)
end
def send_scheduled_session_approved(email, msg)
end
def send_scheduled_session_rsvp_cancelled(email, msg)
end
def send_scheduled_session_rsvp_cancelled_org(email, msg)
end
def send_scheduled_session_cancelled(email, msg)
end
def send_scheduled_session_rescheduled(email, msg)
end
def send_scheduled_session_reminder(email, msg)
end
def send_scheduled_session_comment(email, msg)
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
notifications, online_followers, offline_followers = [], [], []
notification_msg = format_msg(NotificationTypes::BAND_SESSION_JOIN, nil, band)
notification_msg = format_msg(NotificationTypes::BAND_SESSION_JOIN, {:band => band})
followers = band.followers.map { |bf| bf.user }
@ -602,7 +681,7 @@ module JamRuby
friends_and_followers = friend_users.concat(follower_users).uniq
notifications, online_ff, offline_ff = [], [], []
notification_msg = format_msg(NotificationTypes::MUSICIAN_RECORDING_SAVED, user)
notification_msg = format_msg(NotificationTypes::MUSICIAN_RECORDING_SAVED, {:user => user})
friends_and_followers.each do |ff|
notification = Notification.new
@ -636,7 +715,7 @@ module JamRuby
def send_band_recording_saved(recording)
notification_msg = format_msg(NotificationTypes::BAND_RECORDING_SAVED, nil, recording.band)
notification_msg = format_msg(NotificationTypes::BAND_RECORDING_SAVED, {:band => recording.band})
band.followers.each do |bf|
follower = bf.user
@ -669,9 +748,9 @@ module JamRuby
end
end
def send_recording_started(music_session, connection, user)
def send_recording_started(music_session, user)
notification_msg = format_msg(NotificationTypes::RECORDING_STARTED, user)
notification_msg = format_msg(NotificationTypes::RECORDING_STARTED, {:user => user})
music_session.users.each do |musician|
if musician.id != user.id
@ -686,9 +765,9 @@ module JamRuby
end
end
def send_recording_ended(music_session, connection, user)
def send_recording_ended(music_session, user)
notification_msg = format_msg(NotificationTypes::RECORDING_ENDED, user)
notification_msg = format_msg(NotificationTypes::RECORDING_ENDED, {:user => user})
music_session.users.each do |musician|
if musician.id != user.id
@ -715,7 +794,7 @@ module JamRuby
notification.description = NotificationTypes::RECORDING_MASTER_MIX_COMPLETE
notification.save
notification_msg = format_msg(notification.description, nil, recording.band)
notification_msg = format_msg(notification.description, {:band => recording.band})
msg = @@message_factory.recording_master_mix_complete(
claimed_recording.user_id,
@ -771,7 +850,7 @@ module JamRuby
notification.target_user_id = receiver.id
notification.save
notification_msg = format_msg(notification.description, nil, band)
notification_msg = format_msg(notification.description, {:band => band})
if receiver.online
msg = @@message_factory.band_invitation(
@ -800,7 +879,7 @@ module JamRuby
notification.target_user_id = receiver.id
notification.save
notification_msg = format_msg(notification.description, sender, band)
notification_msg = format_msg(notification.description, {:user => sender, :band => band})
if receiver.online
msg = @@message_factory.band_invitation_accepted(

View File

@ -33,9 +33,17 @@
JOIN_REQUEST_REJECTED : "JOIN_REQUEST_REJECTED",
SESSION_JOIN : "SESSION_JOIN",
SESSION_DEPART : "SESSION_DEPART",
TRACKS_CHANGED : "TRACKS_CHANGED",
MUSICIAN_SESSION_JOIN : "MUSICIAN_SESSION_JOIN",
BAND_SESSION_JOIN : "BAND_SESSION_JOIN",
TRACKS_CHANGED : "TRACKS_CHANGED",
SCHEDULED_SESSION_INVITATION : "SCHEDULED_SESSION_INVITATION",
SCHEDULED_SESSION_RSVP : "SCHEDULED_SESSION_RSVP",
SCHEDULED_SESSION_RSVP_APPROVED : "SCHEDULED_SESSION_RSVP_APPROVED",
SCHEDULED_SESSION_RSVP_CANCELLED : "SCHEDULED_SESSION_RSVP_CANCELLED",
SCHEDULED_SESSION_RSVP_CANCELLED_ORG : "SCHEDULED_SESSION_RSVP_CANCELLED_ORG",
SCHEDULED_SESSION_CANCELLED : "SCHEDULED_SESSION_CANCELLED",
SCHEDULED_SESSION_RESCHEDULED : "SCHEDULED_SESSION_RESCHEDULED",
SCHEDULED_SESSION_REMINDER : "SCHEDULED_SESSION_REMINDER",
SCHEDULED_SESSION_COMMENT : "SCHEDULED_SESSION_COMMENT",
// recording notifications
MUSICIAN_RECORDING_SAVED : "MUSICIAN_RECORDING_SAVED",
@ -48,6 +56,7 @@
// band notifications
BAND_INVITATION : "BAND_INVITATION",
BAND_INVITATION_ACCEPTED : "BAND_INVITATION_ACCEPTED",
BAND_SESSION_JOIN : "BAND_SESSION_JOIN",
// text message
TEXT_MESSAGE : "TEXT_MESSAGE",

View File

@ -763,15 +763,46 @@
var firstNotification = false;
var notifyDetails;
this.notify = function (message, descriptor) {
var okButton = {
id: "btn-okay",
text: "OKAY",
"layout-action": "close",
href: "#",
css: "button-orange"
};
var cancelButton = {
id: "btn-cancel",
text: "CANCEL",
"layout-action": "close",
href: "#",
css: "button-grey"
};
var defaultButtons = [
okButton,
cancelButton
];
this.notify = function (message, buttons) {
if (!buttons) {
buttons = defaultButtons;
}
// this allows clients to just specify the important action button without having to repeat the cancel descripton everywhere
if (buttons.length === 1) {
buttons.push(cancelButton);
}
var $notify = $('[layout="notify"]');
if (notifyQueue.length === 0) {
firstNotification = true;
setNotificationInfo(message, descriptor, $notify);
setNotificationInfo(message, buttons, $notify);
}
notifyQueue.push({message: message, descriptor: descriptor});
notifyQueue.push({message: message, descriptor: buttons});
// JW - speeding up the in/out parts of notify. Extending non-moving time.
$notify.slideDown(250)
.delay(4000)
@ -796,7 +827,7 @@
});
};
function setNotificationInfo(message, descriptor, notificationSelector) {
function setNotificationInfo(message, buttons, notificationSelector) {
var $notify = $('[layout="notify"]');
$('h2', $notify).text(message.title);
$('p', $notify).empty();
@ -822,73 +853,32 @@
$('div.detail', $notify).hide();
}
$('#ok-button', $notify).unbind('click');
$('#cancel-button', $notify).unbind('click');
var $buttonDiv = $('#buttons', $notify);
$buttonDiv.empty();
if (descriptor) {
if (descriptor.ok_text) {
$('#ok-button', $notify).html(descriptor.ok_text);
}
else {
$('#ok-button', $notify).html("OKAY");
}
$.each(buttons, function(index, val) {
$buttonDiv.append('<a id="' + val.id + '" href="#" class="' + val.css + '" layout-action="close">' + val.text + '</a>&nbsp;&nbsp;')
$('#ok-button', $notify).click(function () {
if (descriptor.ok_callback !== undefined) {
if (descriptor.ok_callback_args) {
descriptor.ok_callback(descriptor.ok_callback_args);
return false;
// ensure it doesn't fire twice
$('#' + val.id, $notify).unbind('click');
$('#' + val.id, $notify).click(function() {
console.log($(this).attr('class'));
console.log("handling click");
if (val.callback !== undefined) {
if (val.callback_args) {
val.callback(val.callback_args);
}
else {
descriptor.ok_callback();
return false;
val.callback();
}
return false;
}
else {
notificationSelector.hide();
}
});
if (descriptor.cancel_text) {
$('#cancel-button', $notify).html(descriptor.cancel_text);
}
else {
if (descriptor.no_cancel) {
$('#cancel-button', $notify).hide();
}
else {
$('#cancel-button', $notify).html("CANCEL");
}
}
$('#cancel-button', $notify).click(function () {
if (descriptor.cancel_callback !== undefined) {
if (descriptor.cancel_callback_args) {
descriptor.cancel_callback(descriptor.cancel_callback_args);
return false;
}
else {
descriptor.cancel_callback();
return false;
}
}
else {
notificationSelector.hide();
}
});
}
// by default OKAY and CANCEL should just hide the notification
else {
$('#ok-button', $notify).html("OKAY");
$('#ok-button', $notify).click(function () {
notificationSelector.hide();
});
$('#cancel-button', $notify).html("CANCEL");
$('#cancel-button', $notify).click(function () {
notificationSelector.hide();
});
}
});
}
this.setWizardStep = setWizardStep;

View File

@ -165,6 +165,7 @@
registerJoinRequestRejected();
registerMusicianSessionJoin();
registerBandSessionJoin();
registerScheduledSessionInvitation();
// recording notifications
registerMusicianRecordingSaved();
@ -411,11 +412,19 @@
"title": "Join Request Approved",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, {
"ok_text": "JOIN SESSION",
"ok_callback": openTerms,
"ok_callback_args": { "session_id": payload.session_id, "notification_id": payload.notification_id }
});
}, [{
id: "btn-join",
text: "JOIN SESSION",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: openTerms,
callback_args: {
"session_id": payload.session_id,
"notification_id": payload.notification_id
}
}]
);
});
}
@ -444,14 +453,31 @@
"title": "New Join Request",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, {
"ok_text": "APPROVE",
"ok_callback": approveJoinRequest,
"ok_callback_args": { "join_request_id": payload.join_request_id, "notification_id": payload.notification_id },
"cancel_text": "REJECT",
"cancel_callback": rejectJoinRequest,
"cancel_callback_args": { "join_request_id": payload.join_request_id, "notification_id": payload.notification_id }
});
}, [{
id: "btn-approve",
text: "APPROVE",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: approveJoinRequest,
callback_args: {
"join_request_id": payload.join_request_id,
"notification_id": payload.notification_id
}
},
{
id: "btn-reject",
text: "REJECT",
"layout-action": "close",
href: "#",
css: "button-grey",
callback: rejectJoinRequest,
callback_args: {
"join_request_id": payload.join_request_id,
"notification_id": payload.notification_id
}
}]
);
});
}
@ -514,11 +540,19 @@
"title": "New Friend Request",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, {
"ok_text": "ACCEPT",
"ok_callback": acceptFriendRequest,
"ok_callback_args": { "friend_request_id": payload.friend_request_id, "notification_id": payload.notification_id }
});
}, [{
id: "btn-accept",
text: "ACCEPT",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: acceptFriendRequest,
callback_args: {
"friend_request_id": payload.friend_request_id,
"notification_id": payload.notification_id
}
}]
);
});
}
@ -573,11 +607,19 @@
app.notify({
"title": "Session Invitation",
"text": participantHtml
}, {
"ok_text": "JOIN SESSION",
"ok_callback": openTerms,
"ok_callback_args": { "session_id": payload.session_id, "notification_id": payload.notification_id }
});
}, [{
id: "btn-join",
text: "JOIN SESSION",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: openTerms,
callback_args: {
"session_id": payload.session_id,
"notification_id": payload.notification_id
}
}]
);
}).error(app.ajaxError);
});
@ -618,20 +660,24 @@
handleNotification(payload, header.type);
app.notify({
"title": "Musician Joined Session",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, {
"ok_text": okText,
"ok_callback": callback,
"ok_callback_args": {
"session_id": payload.session_id,
"fan_access": payload.fan_access,
"musician_access": payload.musician_access,
"approval_required": payload.approval_required,
"notification_id": payload.notification_id
}
}
"title": "Musician Joined Session",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, [{
id: "btn-action",
text: okText,
"layout-action": "close",
href: "#",
css: "button-orange",
callback: callback,
callback_args: {
"session_id": payload.session_id,
"fan_access": payload.fan_access,
"musician_access": payload.musician_access,
"approval_required": payload.approval_required,
"notification_id": payload.notification_id
}
}]
);
}
});
@ -672,25 +718,42 @@
handleNotification(payload, header.type);
app.notify({
"title": "Band Joined Session",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, {
"ok_text": "LISTEN",
"ok_callback": callback,
"ok_callback_args": {
"session_id": payload.session_id,
"fan_access": payload.fan_access,
"musician_access": payload.musician_access,
"approval_required": payload.approval_required,
"notification_id": payload.notification_id
}
}
"title": "Band Joined Session",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, [{
id: "btn-listen",
text: okText,
"layout-action": "close",
href: "#",
css: "button-orange",
callback: callback,
callback_args: {
"session_id": payload.session_id,
"fan_access": payload.fan_access,
"musician_access": payload.musician_access,
"approval_required": payload.approval_required,
"notification_id": payload.notification_id
}
}]
);
}
});
}
function registerScheduledSessionInvitation() {
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SCHEDULED_SESSION_INVITATION, function(header, payload) {
logger.debug("Handling SCHEDULED_SESSION_INVITATION msg " + JSON.stringify(payload));
handleNotification(payload, header.type);
app.notify({
"title": "Session Invitation",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
});
});
}
function registerMusicianRecordingSaved() {
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.MUSICIAN_RECORDING_SAVED, function(header, payload) {
@ -702,14 +765,19 @@
"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,
"notification_id": payload.notification_id
}
});
}, [{
id: "btn-listen",
text: "LISTEN",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: listenToRecording,
callback_args: {
"recording_id": payload.recording_id,
"notification_id": payload.notification_id
}
}]
);
});
}
@ -723,14 +791,19 @@
"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,
"notification_id": payload.notification_id
}
});
}, [{
id: "btn-listen",
text: "LISTEN",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: listenToRecording,
callback_args: {
"recording_id": payload.recording_id,
"notification_id": payload.notification_id
}
}]
);
});
}
@ -745,13 +818,18 @@
"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
}
});
}, [{
id: "btn-share",
text: "SHARE",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: shareRecording,
callback_args: {
"recording_id": payload.recording_id
}
}]
);
});
}
@ -769,15 +847,20 @@
"title": "Band Invitation",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, {
"ok_text": "ACCEPT",
"ok_callback": acceptBandInvitation,
"ok_callback_args": {
"band_invitation_id": payload.band_invitation_id,
"band_id": payload.band_id,
"notification_id": payload.notification_id
}
});
}, [{
id: "btn-accept",
text: "ACCEPT",
"layout-action": "close",
href: "#",
css: "button-orange",
callback: acceptBandInvitation,
callback_args: {
"band_invitation_id": payload.band_invitation_id,
"band_id": payload.band_id,
"notification_id": payload.notification_id
}
}]
);
});
}

View File

@ -6,10 +6,7 @@
</a>
<p></p>
<div class="detail"></div>
<div class="right clearall">
<a id="ok-button" href="#" class="button-orange" layout-action="close">OKAY</a>
&nbsp;&nbsp;
<a id="cancel-button" href="#" class="button-grey" layout-action="close">CANCEL</a>
<div id="buttons" class="right clearall">
</div>
</div>