VRFS-933 notification bug fixes

This commit is contained in:
Brian Smith 2014-01-04 12:20:28 -05:00
parent 7ef959782e
commit a2b34d68dd
6 changed files with 151 additions and 114 deletions

View File

@ -290,11 +290,19 @@ message MusicianSessionJoin {
}
message MusicianRecordingSaved {
optional string recording_id = 1;
optional string photo_url = 2;
optional string msg = 3;
optional string notification_id = 4;
optional string created_at = 5;
}
message BandRecordingSaved {
optional string recording_id = 1;
optional string photo_url = 2;
optional string msg = 3;
optional string notification_id = 4;
optional string created_at = 5;
}
message RecordingStarted {

View File

@ -110,6 +110,7 @@
def new_band_follower(email, msg)
subject = "Your band has a new follower on JamKazam"
unique_args = {:type => "new_band_follower"}
binding.pry
send_notification(email, subject, msg, unique_args)
end

View File

@ -389,10 +389,36 @@ module JamRuby
)
end
def musician_recording_saved
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,
:photo_url => photo_url,
:msg => msg,
:notification_id => notification_id,
:created_at => created_at
)
return Jampb::ClientMessage.new(
:type => ClientMessage::Type::MUSICIAN_RECORDING_SAVED,
:route_to => USER_TARGET_PREFIX + receiver_id,
:musician_recording_saved => musician_recording_saved
)
end
def band_recording_saved
def band_recording_saved(receiver_id, recording_id, photo_url, msg, notification_id, created_at)
band_recording_saved = Jampb::BandRecordingSaved.new(
:recording_id => recording_id,
:photo_url => photo_url,
:msg => msg,
:notification_id => notification_id,
:created_at => created_at
)
return Jampb::ClientMessage.new(
:type => ClientMessage::Type::BAND_RECORDING_SAVED,
:route_to => USER_TARGET_PREFIX + receiver_id,
:band_recording_saved => band_recording_saved
)
end
def recording_started(photo_url, msg)

View File

@ -100,13 +100,17 @@ module JamRuby
end
def format_msg(description, user = nil, band = nil)
name = ""
name, band_name = ""
unless user.nil?
name = user.name
else
name = "Someone"
end
if !band.nil?
band_name = band.name
end
case description
# friend notifications
@ -153,7 +157,7 @@ module JamRuby
return "#{name} has made a new recording."
when NotificationTypes::BAND_RECORDING_SAVED
return "#{name} has made a new recording."
return "#{band.name} has made a new recording."
when NotificationTypes::RECORDING_STARTED
return "#{name} has started a recording."
@ -167,13 +171,13 @@ module JamRuby
# band notifications
when NotificationTypes::BAND_INVITATION
return "You have been invited to join the band #{name}."
return "You have been invited to join the band #{band_name}."
when NotificationTypes::BAND_INVITATION_ACCEPTED
return "#{name} has accepted your band invitation."
return "#{name} has accepted your band invitation to join #{band_name}."
when NotificationTypes::BAND_SESSION_JOIN
return "#{name} is now in a session."
return "#{band_name} is now in a session."
else
return ""
@ -293,8 +297,9 @@ module JamRuby
notification = Notification.new
notification.description = NotificationTypes::NEW_BAND_FOLLOWER
notification.source_user_id = follower.id
notification.target_user_id = bm.user.id
notifications << notification
notification.target_user_id = bm.user_id
# notifications << notification
notification.save
notification_msg = format_msg(notification.description, follower, band)
@ -307,16 +312,16 @@ module JamRuby
notification.created_at.to_s
)
@@mq_router.publish_to_user(user.id, msg)
@@mq_router.publish_to_user(bm.user_id, msg)
else
UserMailer.new_band_follower(user.email, notification_msg)
UserMailer.new_band_follower(bm.user.email, notification_msg)
end
end
unless notifications.empty?
Notification.import notifications
end
# unless notifications.empty?
# Notification.import notifications
# end
end
@ -471,14 +476,15 @@ module JamRuby
notification.description = NotificationTypes::MUSICIAN_SESSION_JOIN
notification.source_user_id = user.id
notification.target_user_id = ff.id
notifications << notification
notification.save
# notifications << notification
ff.online ? online_ff << ff : offline_ff << ff
end
end
unless notifications.empty?
Notification.import notifications
end
# unless notifications.empty?
# Notification.import notifications
# end
notification_msg = format_msg(NotificationTypes::MUSICIAN_SESSION_JOIN, user)
@ -517,7 +523,7 @@ module JamRuby
notification_msg = format_msg(notification.description, user)
msg = @@message_factory.join_request_approved(
msg = @@message_factory.musician_recording_saved(
join_request.id,
music_session.id,
music_session.creator.name,
@ -543,7 +549,7 @@ module JamRuby
notification_msg = format_msg(notification.description, user)
msg = @@message_factory.join_request_approved(
msg = @@message_factory.band_recording_saved(
join_request.id,
music_session.id,
music_session.creator.name,
@ -576,11 +582,11 @@ module JamRuby
user.photo_url,
notification_msg
)
puts ""
@@mq_router.server_publish_to_session(music_session, msg, sender = {:client_id => connection.client_id})
end
def send_recording_master_mix_complete()
def send_recording_master_mix_complete(recording)
end
def send_band_invitation(band, band_invitation, sender, receiver)
@ -622,7 +628,7 @@ puts ""
notification.target_user_id = receiver.id
notification.save
notification_msg = format_msg(notification.description, sender)
notification_msg = format_msg(notification.description, sender, band)
if receiver.online
msg = @@message_factory.band_invitation_accepted(
@ -656,14 +662,16 @@ puts ""
notification.band_id = band.id
notification.description = NotificationTypes::BAND_SESSION_JOIN
notification.target_user_id = receiver.id
notifications << notification
notification.save
# notifications << notification
bf.follower.online ? online_followers << bf.follower : offline_followers << bf.follower
end
end
unless notifications.empty?
Notification.import notifications
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)

View File

@ -7,6 +7,7 @@
var logger = context.JK.logger;
var userId;
var user = null;
var rest = context.JK.Rest();
var instrument_logo_map = context.JK.getInstrumentIconMap24();
@ -24,7 +25,7 @@
function beforeShow(data) {
userId = data.id;
user = null;
user = null;
}
function afterShow(data) {
@ -46,78 +47,69 @@
$('.profile-nav a.#profile-about-link').addClass('active');
}
function getUser() {
if (user === null) {
var url = "/api/users/" + userId;
$.ajax({
type: "GET",
dataType: "json",
url: url,
async: false,
processData:false,
success: function(response) {
user = response;
},
error: function(jqXHR, textStatus, errorMessage) {
user = null;
app.ajaxError(jqXHR, textStatus, errorMessage);
}
});
function getUser() {
if (user === null) {
rest.getUserDetail({"id": userId})
.done(function(response) {
user = response;
})
.fail(app.ajaxError);
}
return user;
}
return user;
}
function isMusician() {
if (getUser()) {
return user.musician === true;
function isMusician() {
if (getUser()) {
return user.musician === true;
}
return false;
}
return false;
}
function isCurrentUser() {
return userId === context.JK.currentUserId;
}
function isCurrentUser() {
return userId === context.JK.currentUserId;
}
function configureUserType() {
if (isMusician()) {
$('#profile-history-link').show();
$('#profile-bands-link').show();
$('#profile-instruments').show();
$('#profile-session-stats').show();
$('#profile-recording-stats').show();
function configureUserType() {
if (isMusician()) {
$('#profile-history-link').show();
$('#profile-bands-link').show();
$('#profile-instruments').show();
$('#profile-session-stats').show();
$('#profile-recording-stats').show();
// $('#profile-following-stats').hide();
// $('#profile-favorites-stats').hide();
// $('#profile-following-stats').hide();
// $('#profile-favorites-stats').hide();
$('#btn-add-friend').show();
$('#btn-add-friend').show();
$('.profile-social-left').show();
$('#profile-type-label').text('musician');
$('#profile-location-label').text('Location');
$('#profile-type-label').text('musician');
$('#profile-location-label').text('Location');
}
else {
$('#profile-history-link').hide();
$('#profile-bands-link').hide();
$('#profile-instruments').hide();
$('#profile-session-stats').hide();
$('#profile-recording-stats').hide();
} else {
$('#profile-history-link').hide();
$('#profile-bands-link').hide();
$('#profile-instruments').hide();
$('#profile-session-stats').hide();
$('#profile-recording-stats').hide();
// $('#profile-following-stats').show();
// $('#profile-favorites-stats').show();
$('#btn-add-friend').hide();
// $('#profile-following-stats').show();
// $('#profile-favorites-stats').show();
$('#btn-add-friend').hide();
$('.profile-social-left').hide();
$('#profile-type-label').text('fan');
$('#profile-location-label').text('Presence');
}
$('#profile-type-label').text('fan');
$('#profile-location-label').text('Presence');
}
if (isCurrentUser()) {
if (isCurrentUser()) {
$('#btn-profile-edit').show();
} else {
}
else {
$('#btn-profile-edit').hide();
}
}
}
/****************** MAIN PORTION OF SCREEN *****************/
// events for main screen
@ -168,7 +160,7 @@
}
function isFriend() {
return getUser() ? user.is_friend : false;
return getUser() ? user.is_friend : false;
}
function friendRequestCallback() {
@ -338,18 +330,18 @@
text = user.follower_count > 1 || user.follower_count === 0 ? " Followers" : " Follower";
$('#profile-follower-stats').html(user.follower_count + text);
if (isMusician()) {
if (isMusician()) {
text = user.session_count > 1 || user.session_count === 0 ? " Sessions" : " Session";
$('#profile-session-stats').html(user.session_count + text);
text = user.recording_count > 1 || user.recording_count === 0 ? " Recordings" : " Recording";
$('#profile-recording-stats').html(user.recording_count + text);
} else {
} else {
text = " Following";
$('#profile-following-stats').html(user.following_count + text);
text = user.favorite_count > 1 || user.favorite_count === 0 ? " Favorites" : " Favorite";
$('#profile-favorite-stats').html(user.favorite_count + text);
}
}
$('#profile-biography').html(user.biography);
}
@ -383,31 +375,31 @@
}
function bindSocial() {
if (isMusician()) {
// FRIENDS
var url = "/api/users/" + userId + "/friends";
$.ajax({
type: "GET",
dataType: "json",
url: url,
async: false,
processData:false,
success: function(response) {
$.each(response, function(index, val) {
var template = $('#template-profile-social').html();
var friendHtml = context.JK.fillTemplate(template, {
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
userName: val.name,
location: val.location,
type: "Friends"
});
if (isMusician()) {
// FRIENDS
var url = "/api/users/" + userId + "/friends";
$.ajax({
type: "GET",
dataType: "json",
url: url,
async: false,
processData:false,
success: function(response) {
$.each(response, function(index, val) {
var template = $('#template-profile-social').html();
var friendHtml = context.JK.fillTemplate(template, {
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
userName: val.name,
location: val.location,
type: "Friends"
});
$('#profile-social-friends').append(friendHtml);
});
},
error: app.ajaxError
});
}
$('#profile-social-friends').append(friendHtml);
});
},
error: app.ajaxError
});
}
// FOLLOWINGS (USERS)
url = "/api/users/" + userId + "/followings";
@ -614,6 +606,7 @@
var newFollowing = {};
newFollowing.band_id = bandId;
logger.debug("Following band " + bandId);
var url = "/api/users/" + context.JK.currentUserId + "/followings";
$.ajax({

View File

@ -23,6 +23,7 @@ class ApiUsersController < ApiController
{:band_musicians => :user},
:bands, :instruments])
.find(params[:id])
respond_with @user, responder: ApiResponder, :status => 200
end