diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index e7eb81c2..8714b9a6 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -77,9 +77,6 @@ class RoomsController < ApplicationController opts = default_meeting_options opts[:user_is_moderator] = true - @room.sessions += 1 - @room.save - redirect_to @room.join_path(current_user, opts) end diff --git a/app/models/room.rb b/app/models/room.rb index 019e8c4e..ccc137a3 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -25,6 +25,19 @@ class Room < ApplicationRecord bbb.is_meeting_running?(bbb_id) end + # Retrieves all the users in a room. + def participants + begin + res = bbb.get_meeting_info(bbb_id, nil) + res[:attendees].map do |att| + User.find_by(uid: att[:userID], name: att[:fullName]) + end + rescue BigBlueButton::BigBlueButtonException => exc + # The meeting is most likely not running. + [] + end + end + # Determines the invite URL for the room. def invite_path "/r/#{uid}" @@ -40,6 +53,10 @@ class Room < ApplicationRecord moderatorOnlyMessage: options[:moderator_message] } + # Increment room sessions. + self.sessions += 1 + self.save + #meeting_options.merge!( #{ "meta_room-id": options[:room_owner], # "meta_meeting-name": options[:meeting_name]} @@ -55,7 +72,7 @@ class Room < ApplicationRecord # Returns a URL to join a user into a meeting. def join_path(user, options = {}) - user = user.name if user.is_a?(User) + username = user.name if user.is_a?(User) # Create the meeting if it isn't running. start_session(options) unless is_running? @@ -83,7 +100,7 @@ class Room < ApplicationRecord end # Generate the join URL. - bbb.join_meeting_url(bbb_id, user, password) + bbb.join_meeting_url(bbb_id, username, password, {userID: user.uid}) end # Fetches all recordings for a meeting. diff --git a/app/models/user.rb b/app/models/user.rb index 545a4ffd..6c7f0ab1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -88,8 +88,9 @@ class User < ApplicationRecord private - # Initializes a room for the user. + # Initializes a room for the user and assign a BigBlueButton user id. def initialize_main_room + self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}" self.main_room = Room.create!(owner: self, name: firstname + "'s Room") self.save end diff --git a/app/views/rooms/join.html.erb b/app/views/rooms/join.html.erb index 31e9f92d..e60a7681 100644 --- a/app/views/rooms/join.html.erb +++ b/app/views/rooms/join.html.erb @@ -34,3 +34,5 @@ + +<%= @room.participants %> diff --git a/app/views/shared/components/_room_block.html.erb b/app/views/shared/components/_room_block.html.erb index 9ec6a7bb..9cb1e620 100644 --- a/app/views/shared/components/_room_block.html.erb +++ b/app/views/shared/components/_room_block.html.erb @@ -24,6 +24,9 @@ <%= button_to root_path, class: "dropdown-item" do %> Copy Link <% end %> + <%= button_to root_path, class: "dropdown-item" do %> + Room Settings + <% end %> <% if room != current_user.main_room %> <%= button_to make_home_path(room), class: "dropdown-item" do %> Make Home Room