add recording events to other meeting pages under room

This commit is contained in:
Zachary Chai 2017-01-31 15:06:04 -05:00
parent 02f59c49e6
commit 77fd74dd8f
5 changed files with 40 additions and 16 deletions

View File

@ -56,6 +56,7 @@ class BbbController < ApplicationController
wait_for_moderator: true, wait_for_moderator: true,
meeting_recorded: true, meeting_recorded: true,
meeting_name: meeting_name, meeting_name: meeting_name,
room_owner: params[:room_id],
user_is_moderator: current_user == user user_is_moderator: current_user == user
} }
else else
@ -117,7 +118,11 @@ class BbbController < ApplicationController
load_room! load_room!
# bbb_res = bbb_get_recordings "#{@user.encrypted_id}-#{params[:id]}" # bbb_res = bbb_get_recordings "#{@user.encrypted_id}-#{params[:id]}"
bbb_res = bbb_get_recordings "#{@user.encrypted_id}" options = { "meta_room-id": @user.encrypted_id }
if params[:id]
options["meta_meeting-name"] = params[:id]
end
bbb_res = bbb_get_recordings(options)
render_bbb_response bbb_res, bbb_res[:recordings] render_bbb_response bbb_res, bbb_res[:recordings]
end end
@ -127,7 +132,7 @@ class BbbController < ApplicationController
metadata = params.select{ |k, v| k.match(/^meta_/) } metadata = params.select{ |k, v| k.match(/^meta_/) }
bbb_res = bbb_update_recordings(params[:record_id], published, metadata) bbb_res = bbb_update_recordings(params[:record_id], published, metadata)
if bbb_res[:returncode] if bbb_res[:returncode]
RecordingUpdatesJob.perform_later(@user.encrypted_id, params[:record_id]) RecordingUpdatesJob.perform_later(@user.encrypted_id, params[:record_id], params[:id])
end end
render_bbb_response bbb_res render_bbb_response bbb_res
end end
@ -136,7 +141,7 @@ class BbbController < ApplicationController
def delete_recordings def delete_recordings
bbb_res = bbb_delete_recordings(params[:record_id]) bbb_res = bbb_delete_recordings(params[:record_id])
if bbb_res[:returncode] if bbb_res[:returncode]
RecordingDeletesJob.perform_later(@user.encrypted_id, params[:record_id]) RecordingDeletesJob.perform_later(@user.encrypted_id, params[:record_id], params[:id])
end end
render_bbb_response bbb_res render_bbb_response bbb_res
end end
@ -161,7 +166,7 @@ class BbbController < ApplicationController
def authorize_recording_owner! def authorize_recording_owner!
load_and_authorize_room_owner! load_and_authorize_room_owner!
recordings = bbb_get_recordings(params[:room_id])[:recordings] recordings = bbb_get_recordings({recordID: params[:record_id]})[:recordings]
recordings.each do |recording| recordings.each do |recording|
if recording[:recordID] == params[:record_id] if recording[:recordID] == params[:record_id]
return true return true
@ -194,7 +199,7 @@ class BbbController < ApplicationController
# the webhook event doesn't have all the data we need, so we need # the webhook event doesn't have all the data we need, so we need
# to send a getRecordings anyway # to send a getRecordings anyway
# TODO: if the webhooks included all data in the event we wouldn't need this # TODO: if the webhooks included all data in the event we wouldn't need this
rec_info = bbb_get_recordings(token, record_id) rec_info = bbb_get_recordings({recordID: record_id})
rec_info = rec_info[:recordings].first rec_info = rec_info[:recordings].first
RecordingCreatedJob.perform_later(token, parse_recording_for_view(rec_info)) RecordingCreatedJob.perform_later(token, parse_recording_for_view(rec_info))

View File

@ -19,16 +19,21 @@ class RecordingDeletesJob < ApplicationJob
queue_as :default queue_as :default
def perform(room, record_id) def perform(room, record_id, meeting=nil)
tries = 0 tries = 0
sleep_time = 2 sleep_time = 2
while tries < 4 while tries < 4
bbb_res = bbb_get_recordings(nil, record_id) bbb_res = bbb_get_recordings({recordID: record_id})
if !bbb_res[:recordings] || bbb_res[:messageKey] == 'noRecordings' if !bbb_res[:recordings] || bbb_res[:messageKey] == 'noRecordings'
full_id = room
full_id += "-#{recording[:metadata][:"meeting-name"]}"
ActionCable.server.broadcast "#{room}_recording_updates_channel", ActionCable.server.broadcast "#{room}_recording_updates_channel",
action: 'delete', action: 'delete',
id: record_id id: record_id
ActionCable.server.broadcast "#{full_id}_recording_updates_channel",
action: 'delete',
id: record_id
break break
end end
sleep sleep_time sleep sleep_time

View File

@ -19,13 +19,20 @@ class RecordingUpdatesJob < ApplicationJob
queue_as :default queue_as :default
def perform(room, record_id) def perform(room, record_id, meeting=nil)
bbb_res = bbb_get_recordings(nil, record_id) bbb_res = bbb_get_recordings({recordID: record_id})
recording = bbb_res[:recordings].first recording = bbb_res[:recordings].first
full_id = room
full_id += "-#{recording[:metadata][:"meeting-name"]}"
ActionCable.server.broadcast "#{room}_recording_updates_channel", ActionCable.server.broadcast "#{room}_recording_updates_channel",
action: 'update', action: 'update',
id: record_id, id: record_id,
published: recording[:published], published: recording[:published],
listed: bbb_is_recording_listed(recording) listed: bbb_is_recording_listed(recording)
ActionCable.server.broadcast "#{full_id}_recording_updates_channel",
action: 'update',
id: record_id,
published: recording[:published],
listed: bbb_is_recording_listed(recording)
end end
end end

View File

@ -47,6 +47,7 @@ module BbbApi
options[:wait_for_moderator] ||= false options[:wait_for_moderator] ||= false
options[:meeting_logout_url] ||= nil options[:meeting_logout_url] ||= nil
options[:meeting_name] ||= meeting_token options[:meeting_name] ||= meeting_token
options[:room_owner] ||= nil
if !bbb if !bbb
return call_invalid_res return call_invalid_res
@ -81,6 +82,12 @@ module BbbApi
{ "meta_#{BbbApi::META_HOOK_URL}": options[:hook_url] } { "meta_#{BbbApi::META_HOOK_URL}": options[:hook_url] }
) if options[:hook_url] ) if options[:hook_url]
# these parameters are used to filter recordings by room and meeting
meeting_options.merge!(
{ "meta_room-id": options[:room_owner],
"meta_meeting-name": options[:meeting_name]}
) if options[:room_owner]
if Rails.configuration.use_webhooks if Rails.configuration.use_webhooks
webhook_register(options[:hook_url], meeting_id) webhook_register(options[:hook_url], meeting_id)
end end
@ -114,13 +121,9 @@ module BbbApi
response_data = bbb_exception_res exc response_data = bbb_exception_res exc
end end
def bbb_get_recordings(meeting_id, record_id=nil) def bbb_get_recordings(options={})
options={} if options[:meetingID]
if record_id options[:meetingID] = bbb_meeting_id(options[:meetingID])
options[:recordID] = record_id
end
if meeting_id
options[:meetingID] = bbb_meeting_id(meeting_id)
end end
res = bbb_safe_execute :get_recordings, options res = bbb_safe_execute :get_recordings, options

View File

@ -32,10 +32,14 @@ Rails.application.routes.draw do
patch '/rooms/:room_id/recordings/:record_id', to: 'bbb#update_recordings', defaults: {format: 'json'} patch '/rooms/:room_id/recordings/:record_id', to: 'bbb#update_recordings', defaults: {format: 'json'}
delete '/rooms/:room_id/recordings/:record_id', to: 'bbb#delete_recordings', defaults: {format: 'json'} delete '/rooms/:room_id/recordings/:record_id', to: 'bbb#delete_recordings', defaults: {format: 'json'}
get '/rooms/:room_id', to: 'landing#resource', resource: 'rooms' get '/rooms/:room_id', to: 'landing#resource', resource: 'rooms'
get '/rooms/:room_id/recordings', to: 'bbb#recordings', defaults: {format: 'json'} get '/rooms/:room_id/recordings', to: 'bbb#recordings', defaults: {format: 'json'}
get '/rooms/:room_id/:id', to: 'landing#resource', resource: 'rooms' get '/rooms/:room_id/:id', to: 'landing#resource', resource: 'rooms'
delete '/rooms/:room_id/:id/end', to: 'bbb#end', defaults: {format: 'json'} delete '/rooms/:room_id/:id/end', to: 'bbb#end', defaults: {format: 'json'}
get '/rooms/:room_id/:id/recordings', to: 'bbb#recordings', defaults: {format: 'json'}
patch '/rooms/:room_id/:id/recordings/:record_id', to: 'bbb#update_recordings', defaults: {format: 'json'}
delete '/rooms/:room_id/:id/recordings/:record_id', to: 'bbb#delete_recordings', defaults: {format: 'json'}
get '/:resource/:id', to: 'landing#resource', as: :resource get '/:resource/:id', to: 'landing#resource', as: :resource
get '/:resource/:id/join', to: 'bbb#join', as: :bbb_join, defaults: {format: 'json'} get '/:resource/:id/join', to: 'bbb#join', as: :bbb_join, defaults: {format: 'json'}