VRFS-281 initial dev for notification framework
This commit is contained in:
parent
123b772d23
commit
eecbbdcbd4
|
|
@ -117,14 +117,15 @@
|
|||
$('div[layout=sidebar] div[user-id=' + val.id + ']').find('#btn-connect-friend').click(sendFriendRequest);
|
||||
});
|
||||
|
||||
// show header
|
||||
$('#sidebar-search-header').show();
|
||||
hidePanels();
|
||||
$('#sidebar-search-results').height(getHeight() + 'px');
|
||||
}
|
||||
|
||||
function hidePanels() {
|
||||
// hide panels
|
||||
$('[layout-panel="contents"]').hide();
|
||||
$('[layout-panel="contents"]').css({"height": "1px"});
|
||||
|
||||
// resize search results area
|
||||
$('#sidebar-search-results').height(getHeight() + 'px');
|
||||
}
|
||||
|
||||
function getHeight() {
|
||||
|
|
|
|||
|
|
@ -49,8 +49,9 @@ class ApiInvitationsController < ApiController
|
|||
|
||||
unless @invitation.errors.any?
|
||||
User.save_session_settings(current_user, music_session)
|
||||
invitation_notification = @message_factory.session_invitation(receiver.id, @invitation.id)
|
||||
@mq_router.publish_to_user(receiver.id, invitation_notification)
|
||||
|
||||
# send notification
|
||||
Notification.send_session_invitation(receiver.id, @invitation.id)
|
||||
respond_with @invitation, :responder => ApiResponder, :location => api_invitation_detail_url(@invitation)
|
||||
|
||||
else
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ class ApiJoinRequestsController < ApiController
|
|||
response.status = :unprocessable_entity
|
||||
respond_with @join_request
|
||||
else
|
||||
join_request_notification = @message_factory.join_request(music_session.id, @join_request.id, sender.name, text)
|
||||
@mq_router.server_publish_to_session(music_session, join_request_notification)
|
||||
# send notification
|
||||
Notification.send_join_request(music_session, @join_request, sender, text)
|
||||
respond_with @join_request, :responder => ApiResponder, :location => api_join_request_detail_url(@join_request)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ class ApiUsersController < ApiController
|
|||
:favorite_create, :favorite_destroy, # favorites
|
||||
:friend_request_index, :friend_request_show, :friend_request_create, :friend_request_update, # friend requests
|
||||
:friend_index, :friend_destroy, # friends
|
||||
:notification_index, # notifications
|
||||
:band_invitation_index, :band_invitation_show, :band_invitation_update, # band invitations
|
||||
:set_password]
|
||||
|
||||
|
|
@ -338,6 +339,12 @@ class ApiUsersController < ApiController
|
|||
respond_with responder: ApiResponder, :status => 204
|
||||
end
|
||||
|
||||
###################### NOTIFICATIONS ####################
|
||||
def notification_index
|
||||
@notifications = @user.formatted_notifications
|
||||
respond_with @notifications, responder: ApiResponder, :status => 200
|
||||
end
|
||||
|
||||
##################### BAND INVITATIONS ##################
|
||||
def band_invitation_index
|
||||
@invitations = @user.received_band_invitations
|
||||
|
|
|
|||
|
|
@ -121,6 +121,9 @@ SampleApp::Application.routes.draw do
|
|||
match '/users/:id/friends' => 'api_users#friend_index', :via => :get
|
||||
match '/users/:id/friends/:friend_id' => 'api_users#friend_destroy', :via => :delete
|
||||
|
||||
# notifications
|
||||
match '/users/:id/notifications' => 'api_users#notification_index', :via => :get
|
||||
|
||||
# user band invitations
|
||||
match '/users/:id/band_invitations' => 'api_users#band_invitation_index', :via => :get
|
||||
match '/users/:id/band_invitations/:invitation_id' => 'api_users#band_invitation_show', :via => :get, :as => 'api_user_band_invitation_detail'
|
||||
|
|
|
|||
|
|
@ -102,8 +102,9 @@ class MusicSessionManager < BaseManager
|
|||
else
|
||||
# send out notification to queue to the rest of the session
|
||||
# TODO: also this isn't necessarily a user leaving; it's a client leaving'
|
||||
user_joined = @message_factory.user_joined_music_session(connection.music_session.id, user.id, user.name)
|
||||
@mq_router.server_publish_to_session(connection.music_session, user_joined, sender = {:client_id => connection.client_id})
|
||||
|
||||
# send notification
|
||||
Notification.send_session_joined(connection, user)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -122,8 +123,9 @@ class MusicSessionManager < BaseManager
|
|||
# send out notification to queue to the rest of the session
|
||||
# TODO: we should rename the notification to music_session_participants_change or something
|
||||
# TODO: also this isn't necessarily a user leaving; it's a client leaving'
|
||||
user_left = @message_factory.user_left_music_session(music_session.id, user.id, user.first_name + " " + user.last_name)
|
||||
@mq_router.server_publish_to_session(music_session, user_left, sender = {:client_id => connection.client_id})
|
||||
|
||||
# send notification
|
||||
Notification.send_session_left(music_session, connection, user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue