Skip to content

Commit

Permalink
Pass createTime as part of the join call (#2488)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored Jan 28, 2021
1 parent 6ee92c8 commit 062525d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/controllers/concerns/bbb_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def join_path(room, name, options = {}, uid = nil)
join_opts = {}
join_opts[:userID] = uid if uid
join_opts[:join_via_html5] = true
join_opts[:createTime] = room.last_session.to_datetime.strftime("%Q")

bbb_server.join_meeting_url(room.bbb_id, name, password, join_opts)
end
Expand Down Expand Up @@ -88,7 +89,7 @@ def start_session(room, options = {})
end

unless meeting[:messageKey] == 'duplicateWarning'
room.update_attributes(sessions: room.sessions + 1, last_session: DateTime.now)
room.update_attributes(sessions: room.sessions + 1, last_session: DateTime.strptime(meeting[:createTime].to_s, "%Q"))
end
rescue BigBlueButton::BigBlueButtonException => e
puts "BigBlueButton failed on create: #{e.key}: #{e.message}"
Expand Down
14 changes: 10 additions & 4 deletions spec/concerns/bbb_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
context "#start_session" do
it "should update latest session info" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:create_meeting).and_return(
messageKey: ""
messageKey: "",
createTime: "1611793449622"
)

expect do
Expand All @@ -57,17 +58,22 @@
context "#join_path" do
it "should return correct join URL for user" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_meeting_info).and_return(
attendeePW: @room.attendee_pw
attendeePW: @room.attendee_pw,
)
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:create_meeting).and_return(
messageKey: "",
createTime: "1611793449622"
)

endpoint = Rails.configuration.bigbluebutton_endpoint
secret = Rails.configuration.bigbluebutton_secret
fullname = "fullName=Example"
fullname = "&fullName=Example"
join_via_html5 = "&join_via_html5=true"
meeting_id = "&meetingID=#{@room.bbb_id}"
password = "&password=#{@room.attendee_pw}"
time = "createTime=1611793449622"

query = fullname + join_via_html5 + meeting_id + password
query = time + fullname + join_via_html5 + meeting_id + password
checksum_string = "join#{query + secret}"

checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*")
Expand Down
8 changes: 8 additions & 0 deletions spec/controllers/rooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ def random_valid_room_params
@user = create(:user)
@owner = create(:user)
@room = @owner.main_room
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:create_meeting).and_return(
messageKey: "",
createTime: "1611793449622"
)
end

it "should use account name if user is logged in and meeting running" do
Expand Down Expand Up @@ -521,6 +525,10 @@ def random_valid_room_params
moderatorPW: "modpass",
attendeePW: "attpass",
)
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:create_meeting).and_return(
messageKey: "",
createTime: "1611793449622"
)
end

it "should redirect to join path if owner" do
Expand Down

0 comments on commit 062525d

Please sign in to comment.