Class: BigbluebuttonServer
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BigbluebuttonServer
- Includes:
- ActiveModel::ForbiddenAttributesProtection
- Defined in:
- app/models/bigbluebutton_server.rb
Instance Attribute Summary collapse
-
#meetings ⇒ Object
readonly
Array of
BigbluebuttonMeeting
.
Class Method Summary collapse
-
.default ⇒ Object
Helper to get the default server.
Instance Method Summary collapse
-
#api ⇒ Object
Returns the API object (
BigBlueButton::BigBlueButtonAPI
defined inbigbluebutton-api-ruby
) associated with this server. -
#check_url ⇒ Object
Returns the URL to the
/check
request in the server. -
#config_with_initialize ⇒ Object
In case there’s no config created yet, build one.
-
#fetch_meetings ⇒ Object
Fetches the meetings currently created in the server (running or not).
-
#fetch_recordings(filter = nil, full_sync = false) ⇒ Object
Sends a call to the BBB server to get the list of recordings and updates the database with these recordings.
-
#send_delete_recordings(ids) ⇒ Object
Sends a call to the BBB server to delete a recording or a set or recordings.
-
#send_publish_recordings(ids, publish) ⇒ Object
Sends a call to the BBB server to publish or unpublish a recording or a set of recordings.
- #set_api_version_from_server ⇒ Object
- #to_param ⇒ Object
Instance Attribute Details
#meetings ⇒ Object (readonly)
Array of BigbluebuttonMeeting
47 48 49 |
# File 'app/models/bigbluebutton_server.rb', line 47 def meetings @meetings end |
Class Method Details
.default ⇒ Object
Helper to get the default server
70 71 72 |
# File 'app/models/bigbluebutton_server.rb', line 70 def self.default self.first end |
Instance Method Details
#api ⇒ Object
Returns the API object (BigBlueButton::BigBlueButtonAPI
defined in bigbluebutton-api-ruby
) associated with this server.
76 77 78 79 80 81 82 |
# File 'app/models/bigbluebutton_server.rb', line 76 def api return @api if @api.present? version = self.version version = set_api_version_from_server if version.blank? @api = BigBlueButton::BigBlueButtonApi.new(self.url, self.secret, version.to_s, false) end |
#check_url ⇒ Object
Returns the URL to the /check
request in the server.
181 182 183 |
# File 'app/models/bigbluebutton_server.rb', line 181 def check_url self.api.check_url end |
#config_with_initialize ⇒ Object
In case there’s no config created yet, build one.
64 65 66 |
# File 'app/models/bigbluebutton_server.rb', line 64 def config_with_initialize config_without_initialize || build_config(server: self) end |
#fetch_meetings ⇒ Object
Fetches the meetings currently created in the server (running or not).
Using the response, updates meetings
with a list of BigbluebuttonMeeting
objects.
Triggers API call: getMeetings
.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/models/bigbluebutton_server.rb', line 90 def fetch_meetings response = self.api.get_meetings # updates the information in the rooms that are currently in BBB @meetings = [] response[:meetings].each do |attr| room = BigbluebuttonRoom.find_by(meetingid: attr[:meetingID]) # TODO: there might be more attributes returned by the API, review them all if room.nil? attrs = { meetingid: attr[:meetingID], name: attr[:meetingID], attendee_api_password: attr[:attendeePW], moderator_api_password: attr[:moderatorPW], external: true, private: true } room = BigbluebuttonRoom.new(attrs) else room.update_attributes(attendee_api_password: attr[:attendeePW], moderator_api_password: attr[:moderatorPW]) end room.running = attr[:running] room.update_current_meeting_record @meetings << room end end |
#fetch_recordings(filter = nil, full_sync = false) ⇒ Object
Sends a call to the BBB server to get the list of recordings and updates the database with these recordings.
- filter
-
filters to be used, uses the same format accepted by BigBlueButtonApi::get_recordings. Can filter by meetingID and/or metadata values.
Triggers API call: getRecordings
.
153 154 155 156 157 158 159 160 |
# File 'app/models/bigbluebutton_server.rb', line 153 def fetch_recordings(filter=nil, full_sync=false) filter ||= {} logger.info "Fetching recordings for the server #{self.inspect} with filter: #{filter.inspect}" recordings = self.api.get_recordings(filter) if recordings and recordings[:recordings] BigbluebuttonRecording.sync(self, recordings[:recordings], full_sync) end end |
#send_delete_recordings(ids) ⇒ Object
Sends a call to the BBB server to delete a recording or a set or recordings.
- ids
-
IDs of the recordings that will be affected. Accepts the same format accepted by BigBlueButtonApi::delete_recordings
Triggers API call: deleteRecordings
.
142 143 144 |
# File 'app/models/bigbluebutton_server.rb', line 142 def send_delete_recordings(ids) self.api.delete_recordings(ids) end |
#send_publish_recordings(ids, publish) ⇒ Object
Sends a call to the BBB server to publish or unpublish a recording or a set of recordings.
- ids
-
IDs of the recordings that will be affected. Accepts the same format accepted by BigBlueButtonApi::publish_recordings
- publish
-
Publish or unpublish the recordings?
Triggers API call: publishRecordings
.
126 127 128 129 130 131 132 133 134 135 |
# File 'app/models/bigbluebutton_server.rb', line 126 def send_publish_recordings(ids, publish) self.api.publish_recordings(ids, publish) # Update #published in all recordings ids = ids.split(",") if ids.instance_of?(String) # "id1,id2" to ["id1", "id2"] ids.each do |id| recording = BigbluebuttonRecording.find_by_recordid(id.strip) recording.update_attributes(:published => publish) unless recording.nil? end end |
#set_api_version_from_server ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'app/models/bigbluebutton_server.rb', line 166 def set_api_version_from_server begin # creating the object with version=nil makes the gem fetch the version from the server api = BigBlueButton::BigBlueButtonApi.new(self.url, self.secret, nil, false) self.version = api.version rescue BigBlueButton::BigBlueButtonException # we just ignore errors in case the server is not responding # in these cases, the version will be fetched later on Rails.logger.error "Could not fetch the API version from the server #{self.id}. The URL probably incorrect." self.version = nil end self.version end |
#to_param ⇒ Object
162 163 164 |
# File 'app/models/bigbluebutton_server.rb', line 162 def to_param self.param end |