join with specific id

This commit is contained in:
joshua-arts 2018-06-03 14:57:30 -04:00
parent 140547d035
commit 79949b4aa6
5 changed files with 26 additions and 6 deletions

View File

@ -77,9 +77,6 @@ class RoomsController < ApplicationController
opts = default_meeting_options opts = default_meeting_options
opts[:user_is_moderator] = true opts[:user_is_moderator] = true
@room.sessions += 1
@room.save
redirect_to @room.join_path(current_user, opts) redirect_to @room.join_path(current_user, opts)
end end

View File

@ -25,6 +25,19 @@ class Room < ApplicationRecord
bbb.is_meeting_running?(bbb_id) bbb.is_meeting_running?(bbb_id)
end 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. # Determines the invite URL for the room.
def invite_path def invite_path
"/r/#{uid}" "/r/#{uid}"
@ -40,6 +53,10 @@ class Room < ApplicationRecord
moderatorOnlyMessage: options[:moderator_message] moderatorOnlyMessage: options[:moderator_message]
} }
# Increment room sessions.
self.sessions += 1
self.save
#meeting_options.merge!( #meeting_options.merge!(
#{ "meta_room-id": options[:room_owner], #{ "meta_room-id": options[:room_owner],
# "meta_meeting-name": options[:meeting_name]} # "meta_meeting-name": options[:meeting_name]}
@ -55,7 +72,7 @@ class Room < ApplicationRecord
# Returns a URL to join a user into a meeting. # Returns a URL to join a user into a meeting.
def join_path(user, options = {}) 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. # Create the meeting if it isn't running.
start_session(options) unless is_running? start_session(options) unless is_running?
@ -83,7 +100,7 @@ class Room < ApplicationRecord
end end
# Generate the join URL. # Generate the join URL.
bbb.join_meeting_url(bbb_id, user, password) bbb.join_meeting_url(bbb_id, username, password, {userID: user.uid})
end end
# Fetches all recordings for a meeting. # Fetches all recordings for a meeting.

View File

@ -88,8 +88,9 @@ class User < ApplicationRecord
private private
# Initializes a room for the user. # Initializes a room for the user and assign a BigBlueButton user id.
def initialize_main_room 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.main_room = Room.create!(owner: self, name: firstname + "'s Room")
self.save self.save
end end

View File

@ -34,3 +34,5 @@
</div> </div>
</div> </div>
</div> </div>
<%= @room.participants %>

View File

@ -24,6 +24,9 @@
<%= button_to root_path, class: "dropdown-item" do %> <%= button_to root_path, class: "dropdown-item" do %>
<i class="dropdown-icon fe fe-link"></i> Copy Link <i class="dropdown-icon fe fe-link"></i> Copy Link
<% end %> <% end %>
<%= button_to root_path, class: "dropdown-item" do %>
<i class="dropdown-icon fas fa-cog"></i> Room Settings
<% end %>
<% if room != current_user.main_room %> <% if room != current_user.main_room %>
<%= button_to make_home_path(room), class: "dropdown-item" do %> <%= button_to make_home_path(room), class: "dropdown-item" do %>
<i class="dropdown-icon fas fa-home"></i> Make Home Room <i class="dropdown-icon fas fa-home"></i> Make Home Room