* VRFS-2432 notify when stream mix is done

This commit is contained in:
Seth Call 2014-11-03 10:00:42 -06:00
parent 1327229048
commit ace7ac15c8
8 changed files with 136 additions and 3 deletions

View File

@ -53,6 +53,7 @@ message ClientMessage {
RECORDING_ENDED = 215;
RECORDING_MASTER_MIX_COMPLETE = 220;
DOWNLOAD_AVAILABLE = 221;
RECORDING_STREAM_MIX_COMPLETE = 222;
// band notifications
BAND_INVITATION = 225;
@ -151,7 +152,8 @@ message ClientMessage {
optional RecordingEnded recording_ended = 215;
optional RecordingMasterMixComplete recording_master_mix_complete = 220;
optional DownloadAvailable download_available = 221;
optional RecordingStreamMixComplete recording_stream_mix_complete = 222;
// band notifications
optional BandInvitation band_invitation = 225;
optional BandInvitationAccepted band_invitation_accepted = 230;
@ -484,6 +486,15 @@ message RecordingMasterMixComplete {
optional string claimed_recording_id = 6;
}
message RecordingStreamMixComplete {
optional string recording_id = 1;
optional string band_id = 2;
optional string msg = 3;
optional string notification_id = 4;
optional string created_at = 5;
optional string claimed_recording_id = 6;
}
message DownloadAvailable {
}

View File

@ -35,6 +35,7 @@ module NotificationTypes
RECORDING_STARTED = "RECORDING_STARTED"
RECORDING_ENDED = "RECORDING_ENDED"
RECORDING_MASTER_MIX_COMPLETE = "RECORDING_MASTER_MIX_COMPLETE"
RECORDING_STREAM_MIX_COMPLETE = "RECORDING_STREAM_MIX_COMPLETE"
# band notifications
BAND_INVITATION = "BAND_INVITATION"
@ -44,4 +45,5 @@ module NotificationTypes
# general purpose text message
TEXT_MESSAGE = "TEXT_MESSAGE"
end

View File

@ -729,6 +729,23 @@ module JamRuby
)
end
def recording_stream_mix_complete(receiver_id, recording_id, claimed_recording_id, band_id, msg, notification_id, created_at)
recording_stream_mix_complete = Jampb::RecordingStreamMixComplete.new(
:recording_id => recording_id,
:claimed_recording_id => claimed_recording_id,
:band_id => band_id,
:msg => msg,
:notification_id => notification_id,
:created_at => created_at
)
Jampb::ClientMessage.new(
:type => ClientMessage::Type::RECORDING_STREAM_MIX_COMPLETE,
:route_to => USER_TARGET_PREFIX + receiver_id,
:recording_stream_mix_complete => recording_stream_mix_complete
)
end
def client_update(product, version, uri, size)
client_update = Jampb::ClientUpdate.new(
product: product,

View File

@ -217,8 +217,10 @@ module JamRuby
return "#{name} has stopped recording."
when NotificationTypes::RECORDING_MASTER_MIX_COMPLETE
return "This recording has been mastered and mixed and is ready to share."
return "One of your recordings has been mastered and mixed and is ready to share."
when NotificationTypes::RECORDING_STREAM_MIX_COMPLETE
return "One of your recordings has a stream mix available and is ready to share."
# band notifications
when NotificationTypes::BAND_INVITATION
@ -1157,6 +1159,33 @@ module JamRuby
end
end
def send_recording_stream_mix_complete(recording)
# only people who get told about mixes are folks who claimed it... not everyone in the session
recording.claimed_recordings.each do |claimed_recording|
notification = Notification.new
notification.band_id = recording.band.id if recording.band
notification.recording_id = recording.id
notification.target_user_id = claimed_recording.user_id
notification.description = NotificationTypes::RECORDING_STREAM_MIX_COMPLETE
notification.save
notification_msg = format_msg(notification.description, {:band => recording.band})
msg = @@message_factory.recording_stream_mix_complete(
claimed_recording.user_id,
recording.id,
claimed_recording.id,
notification.band_id,
notification_msg,
notification.id,
notification.created_date)
@@mq_router.publish_to_user(claimed_recording.user_id, msg)
end
end
def send_client_update(product, version, uri, size)
msg = @@message_factory.client_update( product, version, uri, size)

View File

@ -192,9 +192,17 @@ module JamRuby
self.mp3_md5 = mp3_md5
self.completed = true
save!
# did we have a stream mix already when this one finished? We'll check later for sending a notification only on the 1st finished stream mix
has_stream_mix = recording.has_stream_mix
Recording.where(:id => self.recording.id).update_all(:has_stream_mix => true)
# only update first_quick_mix_id pointer if this is the 1st quick mix to complete for this recording
Recording.where(:id => self.recording.id).update_all(:first_quick_mix_id => self.id) if recording.first_quick_mix_id.nil?
unless has_stream_mix
Notification.send_recording_stream_mix_complete(recording)
end
end
def s3_url(type='ogg')

View File

@ -53,6 +53,7 @@
RECORDING_ENDED : "RECORDING_ENDED",
RECORDING_MASTER_MIX_COMPLETE : "RECORDING_MASTER_MIX_COMPLETE",
DOWNLOAD_AVAILABLE : "DOWNLOAD_AVAILABLE",
RECORDING_STREAM_MIX_COMPLETE : "RECORDING_STREAM_MIX_COMPLETE",
// band notifications
BAND_INVITATION : "BAND_INVITATION",

View File

@ -188,6 +188,7 @@
registerMusicianRecordingSaved();
registerBandRecordingSaved();
registerRecordingMasterMixComplete();
registerRecordingStreamMixComplete();
// band notifications
registerBandInvitation();
@ -280,6 +281,45 @@
});
}
else if (type === context.JK.MessageType.RECORDING_MASTER_MIX_COMPLETE) {
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('SHARE');
$action_btn.click(function() {
rest.getRecording({id: payload.recording_id})
.done(function(recording) {
if(recording.my) {
ui.launchShareDialog(recording.my.id, 'recording');
}
else {
context.JK.Banner.showAlert('Unable to share recording')
}
})
.fail(app.ajaxError)
});
}
else if (type === context.JK.MessageType.RECORDING_STREAM_MIX_COMPLETE) {
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('SHARE');
$action_btn.click(function() {
rest.getRecording({id: payload.recording_id})
.done(function(recording) {
if(recording.my) {
ui.launchShareDialog(recording.my.id, 'recording');
}
else {
context.JK.Banner.showAlert('Unable to share recording')
}
})
.fail(app.ajaxError)
});
}
else if (type === context.JK.MessageType.JOIN_REQUEST) {
var $action_btn = $notification.find($btnNotificationAction);
$action_btn.text('APPROVE');
@ -1128,6 +1168,31 @@
});
}
function registerRecordingStreamMixComplete() {
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.RECORDING_STREAM_MIX_COMPLETE, function(header, payload) {
logger.debug("Handling RECORDING_STREAM_MIX_COMPLETE msg " + JSON.stringify(payload));
handleNotification(payload, header.type);
app.notify({
"title": "Recording Stream Mix Complete",
"text": payload.msg,
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
}, [{
id: "btn-share",
text: "SHARE",
"layout-action": "close",
href: "#",
"class": "button-orange",
callback: shareRecording,
callback_args: {
"claimed_recording_id": payload.claimed_recording_id
}
}]
);
});
}
function shareRecording(args) {
var claimedRecordingId = args.claimed_recording_id;

View File

@ -39,7 +39,7 @@ child(:comments => :comments) {
node :my do |recording|
claim = recording.claim_for_user(current_user) || recording.candidate_claimed_recording
if claim
{ name: claim.name, description: claim.description, genre: claim.genre.id, genre_name: claim.genre.description }
{ name: claim.name, description: claim.description, genre: claim.genre.id, genre_name: claim.genre.description, id: claim.id }
else
nil
end