Skip to content
Snippets Groups Projects
Unverified Commit 9fa385ca authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Pass avatar through to BigBlueButton (#3910)

* Pass avatar through to BigBlueButton

* remove unneeded change
parent ebe3afb0
No related branches found
No related tags found
No related merge requests found
......@@ -76,8 +76,8 @@ RSpec/AnyInstance:
Enabled: false
Metrics/CyclomaticComplexity:
Max: 10
Max: 13
Metrics/PerceivedComplexity:
Max: 10
Max: 13
......@@ -27,7 +27,12 @@ module Api
return render_error status: :bad_request unless e.key == 'idNotUnique'
end
render_data data: BigBlueButtonApi.new.join_meeting(room: @room, name: current_user.name, role: 'Moderator'), status: :created
render_data data: BigBlueButtonApi.new.join_meeting(
room: @room,
name: current_user.name,
avatar_url: current_user.avatar.attached? ? url_for(current_user.avatar) : nil,
role: 'Moderator'
), status: :created
end
# POST /api/v1/meetings/:friendly_id/status.json
......@@ -68,7 +73,14 @@ module Api
data[:status] = true
end
data[:joinUrl] = BigBlueButtonApi.new.join_meeting(room: @room, name: params[:name], role: bbb_role) if data[:status]
if data[:status]
data[:joinUrl] = BigBlueButtonApi.new.join_meeting(
room: @room,
name: current_user ? current_user.name : params[:name],
avatar_url: current_user&.avatar&.attached? ? url_for(current_user.avatar) : nil,
role: bbb_role
)
end
render_data data:, status: :ok
end
......
......@@ -23,13 +23,14 @@ class BigBlueButtonApi
end
end
def join_meeting(room:, name:, role:)
def join_meeting(room:, role:, name: nil, avatar_url: nil)
bbb_server.join_meeting_url(
room.meeting_id,
name,
'', # empty password -> use the role passed ing
{
role:,
avatarURL: avatar_url,
createTime: room.last_session&.to_datetime&.strftime('%Q')
}.compact
)
......
......@@ -39,7 +39,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
).and_call_original
expect_any_instance_of(MeetingStarter).to receive(:call)
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, role: 'Moderator')
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, avatar_url: nil, role: 'Moderator')
post :start, params: { friendly_id: room.friendly_id }
......@@ -78,7 +78,18 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
it 'makes a call to the BigBlueButtonApi to get the join url' do
expect_any_instance_of(BigBlueButtonApi)
.to receive(:join_meeting)
.with(room:, name: user.name, role: 'Moderator')
.with(room:, name: user.name, avatar_url: nil, role: 'Moderator')
post :start, params: { friendly_id: room.friendly_id }
end
it 'passes the users avatar (if they have one) to BigBlueButton' do
user.avatar.attach(io: fixture_file_upload('default-avatar.png'), filename: 'default-avatar.png', content_type: 'image/png')
avatar_url = Rails.application.routes.url_helpers.rails_blob_url(user.avatar, host: 'test.host')
expect_any_instance_of(BigBlueButtonApi)
.to receive(:join_meeting)
.with(room:, name: user.name, avatar_url:, role: 'Moderator')
post :start, params: { friendly_id: room.friendly_id }
end
......@@ -131,7 +142,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
describe '#status' do
it 'gets the joinUrl if the meeting is running' do
allow_any_instance_of(BigBlueButtonApi).to receive(:meeting_running?).and_return(true)
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, role: 'Viewer')
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, avatar_url: nil, role: 'Viewer')
post :status, params: { friendly_id: room.friendly_id, name: user.name }
expect(response).to have_http_status(:ok)
......@@ -149,11 +160,23 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
it 'joins as viewer if no access code is required nor provided' do
allow_any_instance_of(BigBlueButtonApi).to receive(:meeting_running?).and_return(true)
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, role: 'Viewer')
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, avatar_url: nil, role: 'Viewer')
post :status, params: { friendly_id: room.friendly_id, name: user.name }
expect(response).to have_http_status(:ok)
end
it 'passes the users avatar (if they have one) to BigBlueButton' do
allow_any_instance_of(BigBlueButtonApi).to receive(:meeting_running?).and_return(true)
user.avatar.attach(io: fixture_file_upload('default-avatar.png'), filename: 'default-avatar.png', content_type: 'image/png')
avatar_url = Rails.application.routes.url_helpers.rails_blob_url(user.avatar, host: 'test.host')
expect_any_instance_of(BigBlueButtonApi)
.to receive(:join_meeting)
.with(room:, name: user.name, avatar_url:, role: 'Viewer')
post :status, params: { friendly_id: room.friendly_id, name: user.name }
end
context 'Access codes required' do
let(:fake_room_settings_getter) { instance_double(RoomSettingsGetter) }
......@@ -165,7 +188,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
it 'joins as viewer if access code correspond to the viewer access code' do
allow_any_instance_of(BigBlueButtonApi).to receive(:meeting_running?).and_return(true)
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, role: 'Viewer')
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, avatar_url: nil, role: 'Viewer')
expect(RoomSettingsGetter).to receive(:new).with(
room_id: room.id, provider: 'greenlight', show_codes: true, current_user: user,
settings: %w[glRequireAuthentication glViewerAccessCode glModeratorAccessCode glAnyoneCanStart]
......@@ -180,7 +203,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
it 'joins as moderator if access code correspond to moderator access code' do
allow_any_instance_of(BigBlueButtonApi).to receive(:meeting_running?).and_return(true)
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, role: 'Moderator')
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, avatar_url: nil, role: 'Moderator')
expect(RoomSettingsGetter).to receive(:new).with(
room_id: room.id, provider: 'greenlight', show_codes: true, current_user: user,
settings: %w[glRequireAuthentication glViewerAccessCode glModeratorAccessCode glAnyoneCanStart]
......@@ -264,7 +287,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
it 'allows the user to join if they are signed in' do
allow_any_instance_of(BigBlueButtonApi).to receive(:meeting_running?).and_return(true)
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, role: 'Viewer')
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, avatar_url: nil, role: 'Viewer')
post :status, params: { friendly_id: room.friendly_id, name: user.name }
......@@ -286,7 +309,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
session[:user_id] = nil
allow_any_instance_of(BigBlueButtonApi).to receive(:meeting_running?).and_return(true)
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, role: 'Viewer')
expect_any_instance_of(BigBlueButtonApi).to receive(:join_meeting).with(room:, name: user.name, avatar_url: nil, role: 'Viewer')
post :status, params: { friendly_id: room.friendly_id, name: user.name }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment