VRFS-933 notification bug fixes
This commit is contained in:
parent
5d2ef909ce
commit
18d8ff8d3f
|
|
@ -110,7 +110,6 @@
|
|||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -272,19 +272,21 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, follower)
|
||||
|
||||
if user.online
|
||||
msg = @@message_factory.new_user_follower(
|
||||
user.id,
|
||||
follower.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
if follower.id != user.id
|
||||
if user.online
|
||||
msg = @@message_factory.new_user_follower(
|
||||
user.id,
|
||||
follower.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(user.id, msg)
|
||||
@@mq_router.publish_to_user(user.id, msg)
|
||||
|
||||
else
|
||||
UserMailer.new_user_follower(user.email, notification_msg)
|
||||
else
|
||||
UserMailer.new_user_follower(user.email, notification_msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -298,31 +300,29 @@ module JamRuby
|
|||
notification.description = NotificationTypes::NEW_BAND_FOLLOWER
|
||||
notification.source_user_id = follower.id
|
||||
notification.target_user_id = bm.user_id
|
||||
# notifications << notification
|
||||
notification.band_id = band.id
|
||||
notification.save
|
||||
|
||||
notification_msg = format_msg(notification.description, follower, band)
|
||||
|
||||
if bm.user.online
|
||||
msg = @@message_factory.new_user_follower(
|
||||
bm.user_id,
|
||||
follower.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
# this protects against sending the notification to a band member who decides to follow the band
|
||||
if follower.id != bm.user.id
|
||||
if bm.user.online
|
||||
msg = @@message_factory.new_user_follower(
|
||||
bm.user_id,
|
||||
follower.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(bm.user_id, msg)
|
||||
@@mq_router.publish_to_user(bm.user_id, msg)
|
||||
|
||||
else
|
||||
UserMailer.new_band_follower(bm.user.email, notification_msg)
|
||||
else
|
||||
UserMailer.new_band_follower(bm.user.email, notification_msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# unless notifications.empty?
|
||||
# Notification.import notifications
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
def send_session_invitation(receiver, sender, session_id)
|
||||
|
|
@ -460,52 +460,44 @@ module JamRuby
|
|||
friends = Friendship.where(:friend_id => user.id)
|
||||
user_followers = UserFollower.where(:user_id => user.id)
|
||||
|
||||
friend_users = friends.map { |fu| fu.friend }
|
||||
# construct an array of User objects representing friends and followers
|
||||
friend_users = friends.map { |fu| fu.user }
|
||||
follower_users = user_followers.map { |uf| uf.follower }
|
||||
friends_and_followers = friend_users.concat(follower_users)
|
||||
friends_and_followers = friend_users.concat(follower_users).uniq
|
||||
|
||||
unless friends_and_followers.empty?
|
||||
# remove anyone in the session
|
||||
friends_and_followers = friends_and_followers - music_session.users
|
||||
notifications, online_ff, offline_ff = [], [], []
|
||||
notification_msg = format_msg(NotificationTypes::MUSICIAN_SESSION_JOIN, user)
|
||||
|
||||
friends_and_followers = friends_and_followers - music_session.users
|
||||
friends_and_followers.each do |ff|
|
||||
if (ff.musician && music_session.musician_access) || (!ff.musician && music_session.fan_access)
|
||||
notification = Notification.new
|
||||
notification.description = NotificationTypes::MUSICIAN_SESSION_JOIN
|
||||
notification.source_user_id = user.id
|
||||
notification.target_user_id = ff.id
|
||||
notification.save
|
||||
|
||||
notifications, online_ff, offline_ff = []
|
||||
if ff.online
|
||||
msg = @@message_factory.musician_session_join(
|
||||
ff.id,
|
||||
music_session.id,
|
||||
user.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
friends_and_followers.each do |ff|
|
||||
if (ff.musician && music_session.musician_access) || (!ff.musician && music_session.fan_access)
|
||||
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
|
||||
@@mq_router.publish_to_user(ff.id, msg)
|
||||
else
|
||||
offline_ff << ff
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# unless notifications.empty?
|
||||
# Notification.import notifications
|
||||
# end
|
||||
|
||||
notification_msg = format_msg(NotificationTypes::MUSICIAN_SESSION_JOIN, user)
|
||||
|
||||
# send real-time notifications
|
||||
unless online_ff.empty?
|
||||
msg = @@message_factory.musician_session_join(
|
||||
receiver.id,
|
||||
music_session.id,
|
||||
user.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_friends(online_ff.map! {|f| f.id}, msg, user.id)
|
||||
end
|
||||
|
||||
# send email notifications
|
||||
unless offline_ff.empty?
|
||||
UserMailer.musician_session_join(offline_ff.map! {|f| f.email}, msg)
|
||||
end
|
||||
# send email notifications
|
||||
unless offline_ff.empty?
|
||||
UserMailer.musician_session_join(offline_ff.map! {|f| f.email}, notification_msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -517,111 +509,89 @@ module JamRuby
|
|||
|
||||
band_followers = BandFollower.where(:band_id => band.id)
|
||||
|
||||
unless band_followers.empty?
|
||||
notifications, online_followers, offline_followers = []
|
||||
notifications, online_followers, offline_followers = [], [], []
|
||||
notification_msg = format_msg(NotificationTypes::BAND_SESSION_JOIN, nil, band)
|
||||
|
||||
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
|
||||
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 = bf.follower.id
|
||||
notification.save
|
||||
|
||||
if bf.follower.online
|
||||
msg = @@message_factory.band_session_join(
|
||||
bf.follower.id,
|
||||
music_session.id,
|
||||
band.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(bf.follower.id, msg)
|
||||
else
|
||||
offline_followers << bf.follower
|
||||
end
|
||||
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
|
||||
# send email notifications
|
||||
unless offline_followers.empty?
|
||||
UserMailer.band_session_join(offline_followers.map! {|f| f.email}, notification_msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def send_musician_recording_saved(recording)
|
||||
|
||||
if music_session.musician_access || music_session.fan_access
|
||||
user = recording.owner
|
||||
|
||||
user = recording.owner
|
||||
friends = Friendship.where(:friend_id => user.id)
|
||||
user_followers = UserFollower.where(:user_id => user.id)
|
||||
|
||||
friends = Friendship.where(:friend_id => user.id)
|
||||
user_followers = UserFollower.where(:user_id => user.id)
|
||||
# construct an array of User objects representing friends and followers
|
||||
friend_users = friends.map { |fu| fu.friend }
|
||||
follower_users = user_followers.map { |uf| uf.follower }
|
||||
friends_and_followers = friend_users.concat(follower_users).uniq
|
||||
|
||||
friend_users = friends.map { |fu| fu.friend }
|
||||
follower_users = user_followers.map { |uf| uf.follower }
|
||||
friends_and_followers = friend_users.concat(follower_users)
|
||||
notifications, online_ff, offline_ff = [], [], []
|
||||
notification_msg = format_msg(NotificationTypes::MUSICIAN_RECORDING_SAVED, user)
|
||||
|
||||
unless friends_and_followers.empty?
|
||||
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
|
||||
|
||||
friends_and_followers = friends_and_followers - music_session.users
|
||||
if ff.online
|
||||
msg = @@message_factory.musician_recording_saved(
|
||||
ff.id,
|
||||
recording.id,
|
||||
user.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
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
|
||||
@@mq_router.publish_to_user(ff.id, notification_msg)
|
||||
else
|
||||
offline_ff << ff
|
||||
end
|
||||
end
|
||||
|
||||
# send email notifications
|
||||
unless offline_ff.empty?
|
||||
UserMailer.musician_recording_saved(offline_ff.map! {|f| f.email}, notification_msg)
|
||||
end
|
||||
end
|
||||
|
||||
def send_band_recording_saved(recording)
|
||||
|
||||
band_followers = BandFollower.where(:band_id => band.id)
|
||||
notification_msg = format_msg(NotificationTypes::BAND_RECORDING_SAVED, nil, recording.band)
|
||||
|
||||
band_followers.each do |bf|
|
||||
notification = Notification.new
|
||||
|
|
@ -630,34 +600,26 @@ module JamRuby
|
|||
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
|
||||
if bf.follower.online
|
||||
msg = @@message_factory.band_recording_saved(
|
||||
bf.follower.id,
|
||||
recording.id,
|
||||
band.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
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)
|
||||
@@mq_router.publish_to_user(of.id, notification_msg)
|
||||
else
|
||||
offline_followers << bf.follower
|
||||
end
|
||||
end
|
||||
|
||||
# send email notifications
|
||||
unless offline_followers.empty?
|
||||
UserMailer.band_recording_saved(offline_followers.map! {|f| f.email}, msg)
|
||||
UserMailer.band_recording_saved(offline_followers.map! {|f| f.email}, notification_msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -778,7 +740,6 @@ module JamRuby
|
|||
|
||||
@@mq_router.server_publish_to_session(music_session, msg, sender = {:client_id => client_id})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -618,6 +618,7 @@
|
|||
data: JSON.stringify(newFollowing),
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
logger.debug("following band " + bandId);
|
||||
renderBands(); // refresh stats
|
||||
configureBandFollowingButton(true, bandId);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -193,6 +193,26 @@
|
|||
$notification.find('#div-actions').hide();
|
||||
}
|
||||
|
||||
else if (type === context.JK.MessageType.MUSICIAN_SESSION_JOIN || type === context.JK.MessageType.BAND_SESSION_JOIN) {
|
||||
var $action_btn = $notification.find('#btn-notification-action');
|
||||
$action_btn.text('LISTEN');
|
||||
$action_btn.click(function() {
|
||||
listenToSession({ "session_id": payload.session_id, "notification_id": payload.notification_id });
|
||||
});
|
||||
}
|
||||
|
||||
else if (type === context.JK.MessageType.MUSICIAN_RECORDING_SAVED || type === context.JK.MessageType.BAND_RECORDING_SAVED) {
|
||||
var $action_btn = $notification.find('#btn-notification-action');
|
||||
$action_btn.text('LISTEN');
|
||||
$action_btn.click(function() {
|
||||
listenToRecording({ "recording_id": payload.recording_id, "notification_id": payload.notification_id });
|
||||
});
|
||||
}
|
||||
|
||||
else if (type === context.JK.MessageType.RECORDING_MASTER_MIX_COMPLETE) {
|
||||
$notification.find('#div-actions').hide();
|
||||
}
|
||||
|
||||
else if (type === context.JK.MessageType.BAND_INVITATION) {
|
||||
var $action_btn = $notification.find('#btn-notification-action');
|
||||
$action_btn.text('ACCEPT');
|
||||
|
|
@ -757,7 +777,8 @@
|
|||
}
|
||||
|
||||
function listenToSession(args) {
|
||||
var sessionId = args.session_id;
|
||||
deleteNotification(args.notification_id);
|
||||
context.location = '#/session/' + args.session_id;
|
||||
}
|
||||
|
||||
function registerMusicianRecordingSaved() {
|
||||
|
|
@ -802,7 +823,8 @@
|
|||
}
|
||||
|
||||
function listenToRecording(args) {
|
||||
var recordingId = args.recording_id;
|
||||
deleteNotification(args.notification_id);
|
||||
context.location = '#/recording/' + args.recording_id;
|
||||
}
|
||||
|
||||
function registerRecordingStarted() {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ MusicSessionManager < BaseManager
|
|||
music_session.legal_terms = legal_terms
|
||||
|
||||
#genres = genres
|
||||
@log.debug "Genres class: " + genres.class.to_s()
|
||||
@log.debug "Genres class: " + genres.class.to_s
|
||||
|
||||
unless genres.nil?
|
||||
genres.each do |genre_id|
|
||||
|
|
@ -105,8 +105,14 @@ MusicSessionManager < BaseManager
|
|||
|
||||
connection = ConnectionManager.new.join_music_session(user, client_id, music_session, as_musician, tracks) do |db_conn, connection|
|
||||
if as_musician && music_session.musician_access
|
||||
|
||||
# send to session participants
|
||||
Notification.send_session_join(music_session, connection, user)
|
||||
Notification.send_musician_session_join(music_session, connection, user)
|
||||
|
||||
# send "musician joined session" notification only if it's not a band session since there will be a "band joined session" notification
|
||||
if music_session.band.nil?
|
||||
Notification.send_musician_session_join(music_session, connection, user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue