From 63fbc27bca99ee0fffed6ee74824aab8a8ea7031 Mon Sep 17 00:00:00 2001 From: Zachary Chai Date: Fri, 17 Feb 2017 14:52:12 -0500 Subject: [PATCH] update recording notify to work with new workflow --- app/controllers/bbb_controller.rb | 5 +++-- app/jobs/recording_created_job.rb | 4 +++- app/mailers/notification_mailer.rb | 2 +- config/routes.rb | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index 19704e6e..c44e8923 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -202,6 +202,7 @@ class BbbController < ApplicationController if eventName == "publish_ended" if event['payload'] && event['payload']['metadata'] && event['payload']['meeting_id'] token = event['payload']['metadata'][META_TOKEN] + room_id = event['payload']['metadata']['room-id'] record_id = event['payload']['meeting_id'] # the webhook event doesn't have all the data we need, so we need @@ -209,11 +210,11 @@ class BbbController < ApplicationController # TODO: if the webhooks included all data in the event we wouldn't need this rec_info = bbb_get_recordings({recordID: record_id}) rec_info = rec_info[:recordings].first - RecordingCreatedJob.perform_later(token, parse_recording_for_view(rec_info)) + RecordingCreatedJob.perform_later(token, room_id, parse_recording_for_view(rec_info)) # send an email to the owner of this recording, if defined if Rails.configuration.mail_notifications - owner = User.find_by(encrypted_id: token) + owner = User.find_by(encrypted_id: room_id) RecordingReadyEmailJob.perform_later(owner) if owner.present? end diff --git a/app/jobs/recording_created_job.rb b/app/jobs/recording_created_job.rb index c38370d8..c03d6c86 100644 --- a/app/jobs/recording_created_job.rb +++ b/app/jobs/recording_created_job.rb @@ -19,8 +19,10 @@ class RecordingCreatedJob < ApplicationJob queue_as :default - def perform(room, recording) + def perform(token, room, recording) ActionCable.server.broadcast "#{room}_recording_updates_channel", { action: 'create' }.merge(recording) + ActionCable.server.broadcast "#{token}_recording_updates_channel", + { action: 'create' }.merge(recording) end end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 9c73a0bd..d2710d61 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -19,7 +19,7 @@ class NotificationMailer < ActionMailer::Base def recording_ready_email(user) @user = user - @room_url = resource_url(resource: "rooms", id: user.encrypted_id) + @room_url = meeting_room_url(resource: 'rooms', id: user.encrypted_id) mail(to: user.email, subject: t('.subject')) end end diff --git a/config/routes.rb b/config/routes.rb index 002f365d..430a34f9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,11 +43,11 @@ Rails.application.routes.draw do get '/:id/wait', to: 'landing#wait_for_moderator' get '/:id/session_status_refresh', to: 'landing#session_status_refresh' end + post '/:room_id/:id/callback', to: 'bbb#callback' #, defaults: {format: 'json'} # routes shared between meetings and rooms get '/(:room_id)/:id/join', to: 'bbb#join', defaults: {room_id: nil, format: 'json'} get '/(:room_id)/:id', to: 'landing#resource', as: :meeting_room, defaults: {room_id: nil} - post '/:id/callback', to: 'bbb#callback' #, defaults: {format: 'json'} end root to: 'landing#index', :resource => 'meetings'