Merge pull request #126 from zach-chai/fix_notifications

add user waiting notifications back to main room
This commit is contained in:
Zachary Chai 2017-02-16 14:30:35 -05:00 committed by GitHub
commit 71bc125a61
5 changed files with 20 additions and 10 deletions

View File

@ -24,10 +24,14 @@
}; };
var enableMeetingUpdates = function() { var enableMeetingUpdates = function() {
var meetingId = ''
if (!$(".page-wrapper.rooms").data('main-room')) {
meetingId = $(".page-wrapper.rooms").data('id');
}
App.meeting_update = App.cable.subscriptions.create({ App.meeting_update = App.cable.subscriptions.create({
channel: 'MeetingUpdatesChannel', channel: 'MeetingUpdatesChannel',
admin_id: $(".page-wrapper.rooms").data('admin-id'), admin_id: $(".page-wrapper.rooms").data('admin-id'),
meeting_id: $(".page-wrapper.rooms").data('id') meeting_id: meetingId
}, },
{ {
received: function(data) { received: function(data) {
@ -46,7 +50,7 @@
showAlert(I18n.meeting_ended, 4000); showAlert(I18n.meeting_ended, 4000);
} else if (data.action === 'user_waiting') { } else if (data.action === 'user_waiting') {
// show a browser notification only to the owner // show a browser notification only to the owner
if (GreenLight.user.roomOwner) { if (isRoomOwner()) {
showNotification(I18n.user_waiting_title, { showNotification(I18n.user_waiting_title, {
body: I18n.user_waiting_body.replace(/%{user}/, data.user) body: I18n.user_waiting_body.replace(/%{user}/, data.user)
}); });
@ -68,9 +72,7 @@
} }
if ($("body[data-controller=landing]").get(0)) { if ($("body[data-controller=landing]").get(0)) {
if ($("body[data-action=rooms]").get(0)) { if ($("body[data-action=rooms]").get(0)) {
if (!$(".page-wrapper.rooms").data('main-room')) { enableMeetingUpdates();
enableMeetingUpdates();
}
} }
} }
}); });

View File

@ -68,10 +68,14 @@ var showNotification = function(title, options) {
} }
}; };
var isRoomOwner = function() {
return $('body').data('current-user') === $('.page-wrapper.rooms').data('admin-id')
}
// For now there are notifications only for users signed in and when they // For now there are notifications only for users signed in and when they
// are in their room's page // are in their room's page
$(document).on("turbolinks:load", function() { $(document).on("turbolinks:load", function() {
if (GreenLight.user.roomOwner) { if (isRoomOwner()) {
Notification.requestPermission(); Notification.requestPermission();
} }
}); });

View File

@ -78,8 +78,8 @@ class BbbController < ApplicationController
) )
# the user can join the meeting # the user can join the meeting
if bbb_res[:returncode] && user if user
if current_user == user if bbb_res[:returncode] && current_user == user
JoinMeetingJob.perform_later(user.encrypted_id, params[:id]) JoinMeetingJob.perform_later(user.encrypted_id, params[:id])
# user will be waiting for a moderator # user will be waiting for a moderator

View File

@ -19,6 +19,8 @@ class NotifyUserWaitingJob < ApplicationJob
def perform(room, meeting, user) def perform(room, meeting, user)
ActionCable.server.broadcast "#{room}-#{meeting}_meeting_updates_channel", ActionCable.server.broadcast "#{room}-#{meeting}_meeting_updates_channel",
{ action: 'user_waiting', user: user } { action: 'user_waiting', user: user }
ActionCable.server.broadcast "#{room}_meeting_updates_channel",
{ action: 'user_waiting', user: user }
end end
end end

View File

@ -45,7 +45,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
</head> </head>
<body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>" data-resource="<%= params[:resource] %>" <body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>"
data-resource="<%= params[:resource] %>"
data-current-user="<%= current_user.try(:encrypted_id) %>"
style="background-image:url(<%= image_path('greenlight_background.png') if params[:controller] == 'landing' %>);"> style="background-image:url(<%= image_path('greenlight_background.png') if params[:controller] == 'landing' %>);">
<!-- Messages --> <!-- Messages -->
<div id='alerts'> <div id='alerts'>