VRFS-1668 clean up notifications / fix comment notification for session info page

This commit is contained in:
Brian Smith 2014-05-27 22:35:26 -04:00
parent 860704f874
commit c7fc7bdc22
3 changed files with 29 additions and 16 deletions

View File

@ -330,6 +330,7 @@ module JamRuby
# next 3 methods are used for the right sidebar on the session info page
# retrieve users that have approved RSVPs
def approved_rsvps
users = User.find_by_sql(%Q{select u.id, u.photo_url, u.first_name, u.last_name, rs.instrument_id
from rsvp_slots rs
@ -360,9 +361,9 @@ module JamRuby
users_collapsed_instruments
end
# get all slots for this session and perform a set difference with all chosen slots;
# this will return those that are not filled yet
def open_slots
# get all slots for this session and perform a set difference with all chosen slots;
# this will return those that are not filled yet
RsvpSlot.find_by_sql(%Q{select rs.*
from rsvp_slots rs
where rs.music_session_id = '#{self.id}'
@ -376,10 +377,11 @@ module JamRuby
)
end
# retrieve users that have invitations but have not submitted an RSVP request for this session
def pending_invitations
Invitation.find_by_sql(%Q{select u.id, u.photo_url, u.first_name, u.last_name
from invitations i
inner join users u on u.id = i.receiver_id
User.find_by_sql(%Q{select u.id, u.email, u.photo_url, u.first_name, u.last_name
from users u
inner join invitations i on u.id = i.receiver_id
left join rsvp_requests rr on rr.user_id = i.receiver_id
where i.music_session_id = '#{self.id}'
and rr.user_id is null})

View File

@ -756,13 +756,14 @@ module JamRuby
def send_scheduled_session_cancelled(music_session)
return if music_session.nil?
# TODO: notify invitees who have not RSVP'ed
rsvp_requests = RsvpRequest.index(music_session)
target_users = rsvp_requests.map { |r| r.user }
rsvp_requests.each do |rsvp|
target_user = rsvp.user
# remove the creator from the array
target_users = target_users.uniq - [music_session.creator]
target_users.each do |target_user|
source_user = music_session.creator
notification = Notification.new
@ -799,9 +800,13 @@ module JamRuby
return if music_session.nil?
rsvp_requests = RsvpRequest.index(music_session)
target_users = rsvp_requests.map { |r| r.user }
pending_invites = music_session.pending_invitations
rsvp_requests.each do |rsvp|
target_user = rsvp.user
# remove the creator from the array
target_users = target_users.uniq.concat(pending_invites) - [music_session.creator]
target_users.each do |target_user|
source_user = music_session.creator
notification = Notification.new
@ -838,9 +843,12 @@ module JamRuby
return if music_session.nil?
rsvp_requests = RsvpRequest.index(music_session)
target_users = rsvp_requests.map { |r| r.user }
rsvp_requests.each do |rsvp|
target_user = rsvp.user
# remove the creator from the array
target_users = target_users.uniq - [music_session.creator]
target_users.each do |target_user|
source_user = music_session.creator
notification = Notification.new
@ -877,9 +885,13 @@ module JamRuby
return if music_session.nil? || comment.blank?
rsvp_requests = RsvpRequest.index(music_session)
target_users = rsvp_requests.map { |r| r.user }
pending_invites = music_session.pending_invitations
rsvp_requests.each do |rsvp|
target_user = rsvp.user
# remove the creator from the array
target_users = target_users.uniq.concat(pending_invites) - [creator]
target_users.each do |target_user|
source_user = creator
notification = Notification.new

View File

@ -45,7 +45,6 @@
}
function registerScheduledSessionComment() {
console.log("registering session comment on web layout");
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SCHEDULED_SESSION_COMMENT, function(header, payload) {
logger.debug("Handling SCHEDULED_SESSION_COMMENT msg " + JSON.stringify(payload));
app.notify({