bigbluebutton_rails 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitignore +2 -0
  2. data/.rvmrc +6 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.rdoc +9 -0
  5. data/Gemfile +18 -0
  6. data/Gemfile.lock +85 -65
  7. data/README.rdoc +23 -0
  8. data/Rakefile +17 -6
  9. data/app/controllers/bigbluebutton/rooms_controller.rb +79 -58
  10. data/app/controllers/bigbluebutton/servers_controller.rb +41 -24
  11. data/app/models/bigbluebutton_room.rb +45 -5
  12. data/app/models/bigbluebutton_server.rb +5 -7
  13. data/app/views/bigbluebutton/rooms/external.html.erb +24 -0
  14. data/app/views/bigbluebutton/rooms/join_mobile.html.erb +1 -1
  15. data/app/views/bigbluebutton/servers/_activity_list.html.erb +7 -7
  16. data/app/views/bigbluebutton/servers/activity.html.erb +1 -1
  17. data/bigbluebutton_rails.gemspec +2 -12
  18. data/config/locales/en.yml +3 -0
  19. data/lib/bigbluebutton_rails/rails/routes.rb +12 -6
  20. data/lib/bigbluebutton_rails/utils.rb +8 -0
  21. data/lib/bigbluebutton_rails/version.rb +1 -1
  22. data/lib/bigbluebutton_rails.rb +1 -0
  23. data/spec/bigbluebutton_rails_spec.rb +13 -0
  24. data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +114 -0
  25. data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +167 -0
  26. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +213 -457
  27. data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +148 -0
  28. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +50 -76
  29. data/spec/factories/bigbluebutton_room.rb +1 -0
  30. data/spec/models/bigbluebutton_room_spec.rb +141 -17
  31. data/spec/models/bigbluebutton_server_spec.rb +27 -36
  32. data/spec/rails_app/app/controllers/application_controller.rb +4 -3
  33. data/spec/rails_app/config/initializers/rack_hotfix.rb +13 -0
  34. data/spec/rails_app/features/join_external_bigbluebutton_rooms.feature +19 -0
  35. data/spec/rails_app/features/manage_bigbluebutton_rooms.feature +3 -3
  36. data/spec/rails_app/features/manage_bigbluebutton_servers.feature +2 -2
  37. data/spec/rails_app/features/step_definitions/bigbluebutton_room_steps.rb +29 -3
  38. data/spec/rails_app/features/step_definitions/bigbluebutton_server_steps.rb +2 -7
  39. data/spec/rails_app/features/step_definitions/common_steps.rb +15 -2
  40. data/spec/rails_app/features/step_definitions/web_steps.rb +7 -3
  41. data/spec/rails_app/features/support/application_controller.rb +12 -0
  42. data/spec/rails_app/features/support/content.rb +10 -0
  43. data/spec/rails_app/features/support/env.rb +4 -4
  44. data/spec/rails_app/features/support/env_gem.rb +2 -1
  45. data/spec/rails_app/features/support/forms.rb +12 -0
  46. data/spec/rails_app/features/support/paths.rb +17 -8
  47. data/spec/rails_app/features/support/selectors.rb +57 -0
  48. data/spec/rails_app/features/support/within.rb +7 -0
  49. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +60 -52
  50. data/spec/routing/bigbluebutton/servers_routing_spec.rb +8 -8
  51. data/spec/spec_helper.rb +5 -0
  52. data/spec/support/controllers/bigbluebutton/rooms_controller.rb +7 -0
  53. data/spec/support/matchers/shoulda/be_boolean.rb +1 -1
  54. data/spec/support/shared_examples/rooms_controller.rb +37 -0
  55. metadata +24 -110
  56. data/spec/rails_app/app/helpers/application_helper.rb +0 -2
data/.gitignore CHANGED
@@ -5,3 +5,5 @@ pkg
5
5
  log
6
6
  *.gem
7
7
  spec/integration_conf.yml
8
+ coverage/
9
+ rails_best_practices_output.html
data/.rvmrc ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ if [ -e '.rvmrc_custom' ]; then
3
+ source .rvmrc_custom;
4
+ else
5
+ rvm --create use 1.9.2@bigbluebutton_rails;
6
+ fi
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ script: "bundle exec rake setup:rails_app setup:rails_app:db spec"
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.0.6
2
+
3
+ * After fetch_meetings, the rooms that are not found in the DB are *not* saved by default anymore.
4
+ * New action to join external rooms (rooms that are not in the DB but exist in the BBB server).
5
+ * Fixed some errors and warnings for Ruby 1.8.
6
+ * Some changes in the logic of RoomsController#auth to enable a user to join a room that has a blank password.
7
+ * Improvements in the mobile_join view to show a link that includes user authentication. But the QR code is still a bare link to the BBB server.
8
+ * Made some improvements based on tips by rails_best_practices and increased the test coverage to 100% for almost all classes.
9
+
1
10
  == 0.0.5
2
11
 
3
12
  * URLs for both servers and rooms are now defined with a string attribute (called "param") instead of the model ID.
data/Gemfile CHANGED
@@ -2,3 +2,21 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ group :development, :test do
6
+ gem "rspec-rails"
7
+ gem "factory_girl"
8
+ gem "sqlite3-ruby"
9
+ gem "generator_spec"
10
+ gem "shoulda-matchers"
11
+ gem "forgery"
12
+ gem "cucumber-rails"
13
+ gem "database_cleaner"
14
+ gem "rdoc"
15
+ gem "rails_best_practices"
16
+ end
17
+
18
+ group :test do
19
+ if RUBY_VERSION >= "1.9"
20
+ gem 'simplecov', '>= 0.4.0', :require => false
21
+ end
22
+ end
data/Gemfile.lock CHANGED
@@ -1,20 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bigbluebutton_rails (0.0.5)
5
- bigbluebutton-api-ruby (~> 0.0.10)
4
+ bigbluebutton_rails (0.0.6)
5
+ bigbluebutton-api-ruby (~> 0.0.11)
6
6
  rails (>= 3.0.3)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
11
  abstract (1.0.0)
12
- actionmailer (3.0.6)
13
- actionpack (= 3.0.6)
14
- mail (~> 2.2.15)
15
- actionpack (3.0.6)
16
- activemodel (= 3.0.6)
17
- activesupport (= 3.0.6)
12
+ actionmailer (3.0.9)
13
+ actionpack (= 3.0.9)
14
+ mail (~> 2.2.19)
15
+ actionpack (3.0.9)
16
+ activemodel (= 3.0.9)
17
+ activesupport (= 3.0.9)
18
18
  builder (~> 2.1.2)
19
19
  erubis (~> 2.6.6)
20
20
  i18n (~> 0.5.0)
@@ -22,21 +22,21 @@ GEM
22
22
  rack-mount (~> 0.6.14)
23
23
  rack-test (~> 0.5.7)
24
24
  tzinfo (~> 0.3.23)
25
- activemodel (3.0.6)
26
- activesupport (= 3.0.6)
25
+ activemodel (3.0.9)
26
+ activesupport (= 3.0.9)
27
27
  builder (~> 2.1.2)
28
28
  i18n (~> 0.5.0)
29
- activerecord (3.0.6)
30
- activemodel (= 3.0.6)
31
- activesupport (= 3.0.6)
32
- arel (~> 2.0.2)
29
+ activerecord (3.0.9)
30
+ activemodel (= 3.0.9)
31
+ activesupport (= 3.0.9)
32
+ arel (~> 2.0.10)
33
33
  tzinfo (~> 0.3.23)
34
- activeresource (3.0.6)
35
- activemodel (= 3.0.6)
36
- activesupport (= 3.0.6)
37
- activesupport (3.0.6)
38
- arel (2.0.9)
39
- bigbluebutton-api-ruby (0.0.10)
34
+ activeresource (3.0.9)
35
+ activemodel (= 3.0.9)
36
+ activesupport (= 3.0.9)
37
+ activesupport (3.0.9)
38
+ arel (2.0.10)
39
+ bigbluebutton-api-ruby (0.0.11)
40
40
  nokogiri (~> 1.4.0)
41
41
  builder (2.1.2)
42
42
  capybara (1.0.0)
@@ -46,63 +46,73 @@ GEM
46
46
  rack-test (>= 0.5.4)
47
47
  selenium-webdriver (~> 0.2.0)
48
48
  xpath (~> 0.1.4)
49
- childprocess (0.1.9)
49
+ childprocess (0.2.0)
50
50
  ffi (~> 1.0.6)
51
- cucumber (0.10.7)
51
+ colored (1.2)
52
+ cucumber (1.0.2)
52
53
  builder (>= 2.1.2)
53
54
  diff-lcs (>= 1.1.2)
54
- gherkin (~> 2.4.0)
55
+ gherkin (~> 2.4.5)
55
56
  json (>= 1.4.6)
56
57
  term-ansicolor (>= 1.0.5)
57
- cucumber-rails (0.5.2)
58
- capybara (>= 1.0.0.rc1)
59
- cucumber (>= 0.10.5)
60
- nokogiri (>= 1.4.4)
61
- rack-test (>= 0.5.7)
58
+ cucumber-rails (1.0.2)
59
+ capybara (>= 1.0.0)
60
+ cucumber (~> 1.0.0)
61
+ nokogiri (>= 1.4.6)
62
62
  database_cleaner (0.6.7)
63
63
  diff-lcs (1.1.2)
64
64
  erubis (2.6.6)
65
65
  abstract (>= 1.0.0)
66
- factory_girl (1.3.3)
66
+ factory_girl (2.0.2)
67
67
  ffi (1.0.9)
68
- forgery (0.3.7)
68
+ forgery (0.3.12)
69
69
  nokogiri (~> 1.4)
70
- generator_spec (0.8.2)
70
+ generator_spec (0.8.3)
71
71
  rails (~> 3.0)
72
72
  rspec-rails
73
- gherkin (2.4.0)
73
+ gherkin (2.4.5)
74
74
  json (>= 1.4.6)
75
+ haml (3.1.2)
75
76
  i18n (0.5.0)
76
- json (1.5.2)
77
- json_pure (1.5.2)
78
- mail (2.2.15)
77
+ json (1.5.3)
78
+ json_pure (1.5.3)
79
+ mail (2.2.19)
79
80
  activesupport (>= 2.3.6)
80
81
  i18n (>= 0.4.0)
81
82
  mime-types (~> 1.16)
82
83
  treetop (~> 1.4.8)
83
84
  mime-types (1.16)
84
- nokogiri (1.4.4)
85
- polyglot (0.3.1)
85
+ nokogiri (1.4.7)
86
+ polyglot (0.3.2)
86
87
  rack (1.2.3)
87
88
  rack-mount (0.6.14)
88
89
  rack (>= 1.0.0)
89
90
  rack-test (0.5.7)
90
91
  rack (>= 1.0)
91
- rails (3.0.6)
92
- actionmailer (= 3.0.6)
93
- actionpack (= 3.0.6)
94
- activerecord (= 3.0.6)
95
- activeresource (= 3.0.6)
96
- activesupport (= 3.0.6)
92
+ rails (3.0.9)
93
+ actionmailer (= 3.0.9)
94
+ actionpack (= 3.0.9)
95
+ activerecord (= 3.0.9)
96
+ activeresource (= 3.0.9)
97
+ activesupport (= 3.0.9)
97
98
  bundler (~> 1.0)
98
- railties (= 3.0.6)
99
- railties (3.0.6)
100
- actionpack (= 3.0.6)
101
- activesupport (= 3.0.6)
99
+ railties (= 3.0.9)
100
+ rails_best_practices (0.10.1)
101
+ activesupport
102
+ colored
103
+ erubis
104
+ haml
105
+ i18n
106
+ ruby-progressbar
107
+ ruby_parser
108
+ railties (3.0.9)
109
+ actionpack (= 3.0.9)
110
+ activesupport (= 3.0.9)
102
111
  rake (>= 0.8.7)
112
+ rdoc (~> 3.4)
103
113
  thor (~> 0.14.4)
104
- rake (0.8.7)
105
- rdoc (3.6.1)
114
+ rake (0.9.2)
115
+ rdoc (3.9.1)
106
116
  rspec (2.6.0)
107
117
  rspec-core (~> 2.6.0)
108
118
  rspec-expectations (~> 2.6.0)
@@ -116,21 +126,29 @@ GEM
116
126
  activesupport (~> 3.0)
117
127
  railties (~> 3.0)
118
128
  rspec (~> 2.6.0)
129
+ ruby-progressbar (0.0.10)
130
+ ruby_parser (2.0.6)
131
+ sexp_processor (~> 3.0)
119
132
  rubyzip (0.9.4)
120
- selenium-webdriver (0.2.1)
121
- childprocess (>= 0.1.7)
133
+ selenium-webdriver (0.2.2)
134
+ childprocess (>= 0.1.9)
122
135
  ffi (>= 1.0.7)
123
136
  json_pure
124
137
  rubyzip
125
- shoulda-matchers (1.0.0.beta2)
126
- sqlite3 (1.3.3)
138
+ sexp_processor (3.0.5)
139
+ shoulda-matchers (1.0.0.beta3)
140
+ simplecov (0.4.2)
141
+ simplecov-html (~> 0.4.4)
142
+ simplecov-html (0.4.5)
143
+ sqlite3 (1.3.4)
127
144
  sqlite3-ruby (1.3.3)
128
145
  sqlite3 (>= 1.3.3)
129
- term-ansicolor (1.0.5)
146
+ term-ansicolor (1.0.6)
130
147
  thor (0.14.6)
131
- treetop (1.4.9)
148
+ treetop (1.4.10)
149
+ polyglot
132
150
  polyglot (>= 0.3.1)
133
- tzinfo (0.3.28)
151
+ tzinfo (0.3.29)
134
152
  xpath (0.1.4)
135
153
  nokogiri (~> 1.3)
136
154
 
@@ -139,12 +157,14 @@ PLATFORMS
139
157
 
140
158
  DEPENDENCIES
141
159
  bigbluebutton_rails!
142
- cucumber-rails (~> 0.5.2)
143
- database_cleaner (~> 0.6.7)
144
- factory_girl (~> 1.3.2)
145
- forgery (~> 0.3.7)
146
- generator_spec (~> 0.8.2)
147
- rdoc (~> 3.6.0)
148
- rspec-rails (~> 2.6.0)
149
- shoulda-matchers (~> 1.0.0.beta)
150
- sqlite3-ruby (~> 1.3.3)
160
+ cucumber-rails
161
+ database_cleaner
162
+ factory_girl
163
+ forgery
164
+ generator_spec
165
+ rails_best_practices
166
+ rdoc
167
+ rspec-rails
168
+ shoulda-matchers
169
+ simplecov (>= 0.4.0)
170
+ sqlite3-ruby
data/README.rdoc CHANGED
@@ -1,4 +1,5 @@
1
1
  = BigBlueButton on Rails
2
+ http://travis-ci.org/mconf/bigbluebutton_rails.png {(more...)}[http://travis-ci.org/#!/mconf/bigbluebutton_rails]
2
3
 
3
4
  {BigBlueButton}[http://bigbluebutton.org] integration for Ruby on Rails 3.
4
5
 
@@ -181,6 +182,28 @@ Run the tests:
181
182
  rake spec
182
183
  rake cucumber
183
184
 
185
+ Or simply:
186
+
187
+ rake
188
+
184
189
  Develop. :)
185
190
 
186
191
  If you want your code to be integrated in this repository, please create a branch with your modifications and submit a pull request.
192
+
193
+ === Test Coverage
194
+
195
+ Coverage is analyzed by default when you run:
196
+
197
+ rake spec
198
+
199
+ Run it and look at the file <tt>coverage/index.html</tt>.
200
+
201
+ === Best Practices
202
+
203
+ We use the gem <tt>rails_best_practices</tt> to get some nice tips on how to improve the code.
204
+
205
+ Run:
206
+
207
+ rake best_practices
208
+
209
+ And look at the file <tt>rails_best_practices_output.html</tt> to see the tips.
data/Rakefile CHANGED
@@ -30,23 +30,25 @@ end
30
30
  desc 'Setup RailsApp used in tests.'
31
31
  namespace :setup do
32
32
  task :rails_app do |app|
33
- cd "spec/rails_app/"
33
+ cd File.join(File.dirname(__FILE__), "spec", "rails_app")
34
34
  sh "rails destroy bigbluebutton_rails:install"
35
35
  sh "rails generate bigbluebutton_rails:install"
36
+ cd File.dirname(__FILE__)
36
37
  end
37
38
 
38
39
  namespace :rails_app do |app|
39
40
  task :db do
41
+ cd File.join(File.dirname(__FILE__), "spec", "rails_app")
40
42
  # base
41
- cd "spec/rails_app/"
42
43
  sh "rake db:drop:all"
43
44
  sh "rake db:create:all"
44
- # test
45
- sh "rake db:migrate RAILS_ENV=test"
46
- sh "rake db:test:prepare RAILS_ENV=test"
47
45
  # development
48
46
  sh "rake db:migrate RAILS_ENV=development"
49
47
  sh "rake db:seed RAILS_ENV=development"
48
+ # test
49
+ sh "rake db:migrate RAILS_ENV=test"
50
+ sh "rake db:test:prepare RAILS_ENV=test"
51
+ cd File.dirname(__FILE__)
50
52
  end
51
53
  end
52
54
  end
@@ -57,7 +59,9 @@ task :cucumber do
57
59
  sh %{ cucumber features/ }
58
60
  end
59
61
  puts "* Dummy app features"
60
- sh %{ cd spec/rails_app; cucumber features/ }
62
+ cd File.join(File.dirname(__FILE__), "spec", "rails_app")
63
+ sh "cucumber features/"
64
+ cd File.dirname(__FILE__)
61
65
  end
62
66
 
63
67
  task :notes do
@@ -88,3 +92,10 @@ namespace :spec do
88
92
  sh "rails destroy bigbluebutton_rails:install 0.0.4"
89
93
  end
90
94
  end
95
+
96
+ task :best_practices do |app|
97
+ sh "rails_best_practices -f html --spec &>/dev/null"
98
+ puts
99
+ puts "Output will be in the file rails_best_practices_output.html"
100
+ puts
101
+ end
@@ -1,10 +1,11 @@
1
- require 'bigbluebutton-api'
1
+ require 'bigbluebutton_api'
2
2
 
3
3
  class Bigbluebutton::RoomsController < ApplicationController
4
4
 
5
5
  before_filter :find_server
6
+ before_filter :find_room, :only => [:show, :edit, :update, :destroy, :join, :invite, :running, :end, :destroy, :end, :join_mobile]
6
7
  respond_to :html, :except => :running
7
- respond_to :json, :only => [:running, :show, :new, :index, :create, :update, :end, :destroy]
8
+ respond_to :json, :only => [:running, :show, :new, :index, :create, :update]
8
9
 
9
10
  def index
10
11
  # TODO restrict to rooms belonging to the selected server
@@ -12,7 +13,7 @@ class Bigbluebutton::RoomsController < ApplicationController
12
13
  end
13
14
 
14
15
  def show
15
- respond_with(@room = BigbluebuttonRoom.find_by_param(params[:id]))
16
+ respond_with(@room)
16
17
  end
17
18
 
18
19
  def new
@@ -20,14 +21,13 @@ class Bigbluebutton::RoomsController < ApplicationController
20
21
  end
21
22
 
22
23
  def edit
23
- respond_with(@room = BigbluebuttonRoom.find_by_param(params[:id]))
24
+ respond_with(@room)
24
25
  end
25
26
 
26
27
  def create
27
28
  @room = BigbluebuttonRoom.new(params[:bigbluebutton_room])
28
29
  @room.server = @server
29
30
 
30
- # TODO Generate a random meetingid everytime a room is created
31
31
  if !params[:bigbluebutton_room].has_key?(:meetingid) or
32
32
  params[:bigbluebutton_room][:meetingid].blank?
33
33
  @room.meetingid = @room.name
@@ -47,7 +47,7 @@ class Bigbluebutton::RoomsController < ApplicationController
47
47
  message = t('bigbluebutton_rails.rooms.notice.create.failure')
48
48
  redirect_to params[:redir_url], :error => message
49
49
  else
50
- render :action => "new"
50
+ render :new
51
51
  end
52
52
  }
53
53
  format.json { render :json => @room.errors.full_messages, :status => :unprocessable_entity }
@@ -56,8 +56,6 @@ class Bigbluebutton::RoomsController < ApplicationController
56
56
  end
57
57
 
58
58
  def update
59
- @room = BigbluebuttonRoom.find_by_param(params[:id])
60
-
61
59
  if !params[:bigbluebutton_room].has_key?(:meetingid) or
62
60
  params[:bigbluebutton_room][:meetingid].blank?
63
61
  params[:bigbluebutton_room][:meetingid] = params[:bigbluebutton_room][:name]
@@ -77,7 +75,7 @@ class Bigbluebutton::RoomsController < ApplicationController
77
75
  message = t('bigbluebutton_rails.rooms.notice.update.failure')
78
76
  redirect_to params[:redir_url], :error => message
79
77
  else
80
- render :action => "edit"
78
+ render :edit
81
79
  end
82
80
  }
83
81
  format.json { render :json => @room.errors.full_messages, :status => :unprocessable_entity }
@@ -86,8 +84,6 @@ class Bigbluebutton::RoomsController < ApplicationController
86
84
  end
87
85
 
88
86
  def destroy
89
- @room = BigbluebuttonRoom.find_by_param(params[:id])
90
-
91
87
  # TODO Destroy the room record even if end_meeting failed?
92
88
 
93
89
  error = false
@@ -119,8 +115,6 @@ class Bigbluebutton::RoomsController < ApplicationController
119
115
 
120
116
  # Used by logged users to join public rooms.
121
117
  def join
122
- @room = BigbluebuttonRoom.find_by_param(params[:id])
123
-
124
118
  role = bigbluebutton_role(@room)
125
119
  if role.nil?
126
120
  raise BigbluebuttonRails::RoomAccessDenied.new
@@ -136,8 +130,6 @@ class Bigbluebutton::RoomsController < ApplicationController
136
130
 
137
131
  # Used to join private rooms or to invited anonymous users (not logged)
138
132
  def invite
139
- @room = BigbluebuttonRoom.find_by_param(params[:id])
140
-
141
133
  respond_with @room do |format|
142
134
 
143
135
  role = bigbluebutton_role(@room)
@@ -156,9 +148,54 @@ class Bigbluebutton::RoomsController < ApplicationController
156
148
  end
157
149
 
158
150
  # Authenticates an user using name and password passed in the params from #invite
151
+ # Uses params[:id] to get the target room
159
152
  def auth
160
- @room = BigbluebuttonRoom.find_by_param(params[:id])
153
+ @room = BigbluebuttonRoom.find_by_param(params[:id]) unless params[:id].blank?
154
+ if @room.nil?
155
+ message = t('bigbluebutton_rails.rooms.errors.auth.wrong_params')
156
+ redirect_to request.referer, :notice => message
157
+ return
158
+ end
159
+
160
+ name = bigbluebutton_user.nil? ? params[:user][:name] : bigbluebutton_user.name
161
+ role = bigbluebutton_role(@room)
162
+ if role.nil?
163
+ raise BigbluebuttonRails::RoomAccessDenied.new
164
+ elsif role == :password
165
+ role = @room.user_role(params[:user])
166
+ end
167
+
168
+ unless role.nil? or name.nil?
169
+ join_internal(name, role, :invite)
170
+ else
171
+ flash[:error] = t('bigbluebutton_rails.rooms.errors.auth.failure')
172
+ render :invite, :status => :unauthorized
173
+ end
174
+ end
175
+
176
+ def external
177
+ if params[:meeting].blank?
178
+ message = t('bigbluebutton_rails.rooms.errors.external.blank_meetingid')
179
+ params[:redir_url] ||= bigbluebutton_server_rooms_path(@server)
180
+ redirect_to params[:redir_url], :notice => message
181
+ end
182
+ @room = BigbluebuttonRoom.new(:meetingid => params[:meeting])
183
+ end
184
+
185
+ # Authenticates an user using name and password passed in the params from #external
186
+ # Uses params[:meeting] to get the meetingID of the target room
187
+ def external_auth
188
+ @room = nil
189
+ if !params[:meeting].blank? && !params[:user].blank?
190
+ @server.fetch_meetings
191
+ @room = @server.meetings.select{ |r| r.meetingid == params[:meeting] }.first
192
+ else
193
+ message = t('bigbluebutton_rails.rooms.errors.auth.wrong_params')
194
+ redirect_to request.referer, :notice => message
195
+ return
196
+ end
161
197
 
198
+ # This is just to check if the room is not blocked, not to get the actual role
162
199
  raise BigbluebuttonRails::RoomAccessDenied.new if bigbluebutton_role(@room).nil?
163
200
 
164
201
  # if there's a user logged, use his name instead of the name in the params
@@ -166,16 +203,21 @@ class Bigbluebutton::RoomsController < ApplicationController
166
203
  role = @room.user_role(params[:user])
167
204
 
168
205
  unless role.nil? or name.nil?
169
- join_internal(name, role, :invite)
206
+ @room.fetch_meeting_info
207
+ if @room.is_running?
208
+ join_url = @room.join_url(name, role)
209
+ redirect_to(join_url)
210
+ else
211
+ flash[:error] = t('bigbluebutton_rails.rooms.errors.auth.not_running')
212
+ render :external
213
+ end
170
214
  else
171
215
  flash[:error] = t('bigbluebutton_rails.rooms.errors.auth.failure')
172
- render :action => "invite", :status => :unauthorized
216
+ render :external, :status => :unauthorized
173
217
  end
174
218
  end
175
219
 
176
220
  def running
177
- @room = BigbluebuttonRoom.find_by_param(params[:id])
178
-
179
221
  begin
180
222
  @room.fetch_is_running?
181
223
  rescue BigBlueButton::BigBlueButtonException => e
@@ -184,12 +226,9 @@ class Bigbluebutton::RoomsController < ApplicationController
184
226
  else
185
227
  render :json => { :running => "#{@room.is_running?}" }
186
228
  end
187
-
188
229
  end
189
230
 
190
231
  def end
191
- @room = BigbluebuttonRoom.find_by_param(params[:id])
192
-
193
232
  error = false
194
233
  begin
195
234
  @room.fetch_is_running?
@@ -225,13 +264,21 @@ class Bigbluebutton::RoomsController < ApplicationController
225
264
  end
226
265
 
227
266
  def join_mobile
228
- @room = BigbluebuttonRoom.find_by_param(params[:id])
229
- @join_url = @room.join_url(bigbluebutton_user.name, bigbluebutton_role(@room))
230
- @join_url.gsub!("http://", "bigbluebutton://")
267
+ @join_url = join_bigbluebutton_server_room_path(@server, @room, :mobile => '1')
268
+ @join_url.gsub!(/http:\/\//i, "bigbluebutton://")
269
+
270
+ # TODO: we can't use the mconf url because the mobile client scanning the qrcode is not
271
+ # logged. so we are using the full BBB url for now.
272
+ @qrcode_url = @room.join_url(bigbluebutton_user.name, bigbluebutton_role(@room))
273
+ @qrcode_url.gsub!("http://", "bigbluebutton://")
231
274
  end
232
275
 
233
276
  protected
234
277
 
278
+ def find_room
279
+ @room = BigbluebuttonRoom.find_by_param(params[:id])
280
+ end
281
+
235
282
  def find_server
236
283
  if params.has_key?(:server_id)
237
284
  @server = BigbluebuttonServer.find_by_param(params[:server_id])
@@ -241,45 +288,19 @@ class Bigbluebutton::RoomsController < ApplicationController
241
288
  end
242
289
 
243
290
  def join_internal(username, role, wait_action)
244
-
245
291
  begin
246
- @room.fetch_is_running?
247
-
248
- # if the current user is a moderator, create the room (if needed)
249
- # and join it
250
- if role == :moderator
251
-
252
- add_domain_to_logout_url(@room, request.protocol, request.host)
253
-
254
- @room.send_create unless @room.is_running?
255
- join_url = @room.join_url(username, role)
256
- redirect_to(join_url)
257
-
258
- # normal user only joins if the conference is running
259
- # if it's not, wait for a moderator to create the conference
292
+ url = @room.perform_join(username, role, request)
293
+ unless url.nil?
294
+ url.gsub!(/http:\/\//i, "bigbluebutton://") if BigbluebuttonRails::value_to_boolean(params[:mobile])
295
+ redirect_to(url)
260
296
  else
261
- if @room.is_running?
262
- join_url = @room.join_url(username, role)
263
- redirect_to(join_url)
264
- else
265
- flash[:error] = t('bigbluebutton_rails.rooms.errors.auth.not_running')
266
- render :action => wait_action
267
- end
297
+ flash[:error] = t('bigbluebutton_rails.rooms.errors.auth.not_running')
298
+ render wait_action
268
299
  end
269
-
270
300
  rescue BigBlueButton::BigBlueButtonException => e
271
301
  flash[:error] = e.to_s
272
302
  redirect_to request.referer
273
303
  end
274
304
  end
275
305
 
276
- def add_domain_to_logout_url(room, protocol, host)
277
- unless @room.logout_url.nil? or @room.logout_url =~ /^[a-z]+:\/\// # matches the protocol
278
- unless @room.logout_url =~ /^[a-z0-9]+([\-\.]{ 1}[a-z0-9]+)*/ # matches the host domain
279
- @room.logout_url = host + @room.logout_url
280
- end
281
- @room.logout_url = protocol + @room.logout_url
282
- end
283
- end
284
-
285
306
  end