canvas_connect 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org/'
2
2
 
3
3
  gemspec
@@ -36,9 +36,7 @@ class AdobeConnectConference < WebConference
36
36
  #
37
37
  # Returns conference status as a symbol (either :active or :closed).
38
38
  def conference_status
39
- if meeting_exists? && end_at.present? && Time.now < end_at
40
- :active
41
- elsif meeting_exists?
39
+ if meeting_exists?
42
40
  :active
43
41
  else
44
42
  :closed
@@ -53,13 +51,18 @@ class AdobeConnectConference < WebConference
53
51
  # Returns a meeting URL string.
54
52
  def admin_join_url(admin, _ = nil)
55
53
  user = add_host(admin)
56
- settings = { :username => user.username, :password => user.password,
57
- :domain => CanvasConnect.config[:domain] }
58
54
 
59
- service = AdobeConnect::Service.new(settings)
60
- service.log_in
55
+ if config[:use_sis_ids] == "no"
56
+ settings = { :username => user.username, :password => user.password,
57
+ :domain => CanvasConnect.config[:domain] }
58
+
59
+ service = AdobeConnect::Service.new(settings)
60
+ service.log_in
61
61
 
62
- "#{meeting_url}?session=#{service.session}"
62
+ "#{meeting_url}?session=#{service.session}"
63
+ else
64
+ meeting_url
65
+ end
63
66
  end
64
67
 
65
68
  # Public: Add a participant to the conference and create a meeting URL.
@@ -73,8 +76,10 @@ class AdobeConnectConference < WebConference
73
76
  def participant_join_url(user, _ = nil)
74
77
  if grants_right?(user, nil, :initiate)
75
78
  admin_join_url(user)
76
- else
79
+ elsif config[:use_sis_ids] == "no"
77
80
  "#{meeting_url}?guestName=#{URI.escape(user.name)}"
81
+ else
82
+ meeting_url
78
83
  end
79
84
  end
80
85
 
@@ -84,11 +89,14 @@ class AdobeConnectConference < WebConference
84
89
  # Returns an SCO-ID string.
85
90
  def find_conference_key
86
91
  unless conference_key.present?
87
- self.conference_key = meeting_folder.
88
- contents.
89
- xpath("//sco[name=#{meeting_name.inspect}]").
90
- attr('sco-id').
91
- value
92
+ meeting_node = meeting_folder.contents.xpath("//sco[name=#{meeting_name.inspect}]")
93
+ # if meeting node exists, get that value
94
+ if meeting_node.present?
95
+ self.conference_key = meeting_node.attr('sco-id').value
96
+ else
97
+ # meeting node not found (by name)
98
+ raise CanvasConnect::MeetingNotFound, "Meeting with name '#{meeting_name}' not found"
99
+ end
92
100
  end
93
101
 
94
102
  conference_key
@@ -100,8 +108,21 @@ class AdobeConnectConference < WebConference
100
108
  #
101
109
  # Returns the CanvasConnect::ConnectUser.
102
110
  def add_host(user)
103
- options = { first_name: user.first_name, last_name: user.last_name,
104
- email: connect_username(user), username: connect_username(user), uuid: user.uuid }
111
+ options = config[:use_sis_ids] == "yes" ?
112
+ {
113
+ first_name: user.first_name,
114
+ last_name: user.last_name,
115
+ email: user.email,
116
+ username: user.sis_pseudonym_for(user.account).try(:sis_user_id),
117
+ uuid: user.uuid
118
+ } :
119
+ {
120
+ first_name: user.first_name,
121
+ last_name: user.last_name,
122
+ email: connect_username(user),
123
+ username: connect_username(user),
124
+ uuid: user.uuid
125
+ }
105
126
 
106
127
  connect_user = AdobeConnect::User.find(options) || AdobeConnect::User.create(options)
107
128
  connect_service.permissions_update(
@@ -142,11 +163,13 @@ class AdobeConnectConference < WebConference
142
163
  #
143
164
  # Returns nothing.
144
165
  def create_meeting
166
+ url_id = meeting_url_suffix
167
+
145
168
  params = { :type => 'meeting',
146
169
  :name => meeting_name,
147
170
  :folder_id => meeting_folder.id,
148
171
  :date_begin => start_at.iso8601,
149
- :url_path => meeting_url_suffix }
172
+ :url_path => url_id }
150
173
  params[:end_at] = end_at.iso8601 if end_at.present?
151
174
 
152
175
  result = connect_service.sco_update(params)
@@ -161,6 +184,9 @@ class AdobeConnectConference < WebConference
161
184
  return nil
162
185
  end
163
186
 
187
+ # if made it here, meeting was successfully created. Cache the meeting_url_suffix being used.
188
+ self.meeting_url_id = url_id
189
+
164
190
  sco_id = result.body.at_xpath('//sco')['sco-id']
165
191
  make_meeting_public(sco_id)
166
192
  end
@@ -180,7 +206,7 @@ class AdobeConnectConference < WebConference
180
206
  #
181
207
  # Returns a boolean.
182
208
  def meeting_exists?
183
- result = connect_service.sco_by_url(:url_path => meeting_url_suffix)
209
+ result = connect_service.sco_by_url(:url_path => meeting_url_id)
184
210
  result.body.xpath('//status[@code="ok"]').present?
185
211
  end
186
212
 
@@ -189,11 +215,7 @@ class AdobeConnectConference < WebConference
189
215
  end
190
216
 
191
217
  def meeting_url
192
- @cached_meeting_url ||= generate_meeting_url
193
- end
194
-
195
- def meeting_url_suffix
196
- @cached_meeting_url_suffix ||= generate_meeting_url_suffix
218
+ "#{config[:domain]}/#{meeting_url_id}"
197
219
  end
198
220
 
199
221
  # Internal: Get and cache a reference to the remote folder.
@@ -226,17 +248,32 @@ class AdobeConnectConference < WebConference
226
248
  "#{course_code}: #{self.title} [#{self.id}]"
227
249
  end
228
250
 
229
- # Internal: Generate the base URL for the meeting.
251
+ # Internal: Get the unique ID to identify the meeting in an Adobe url.
252
+ #
253
+ # Returns a string or nil.
254
+ def meeting_url_id
255
+ # Return the stored setting value if present. If missing, return the legacy generated format.
256
+ settings[:meeting_url_id] || meeting_url_suffix_legacy
257
+ end
258
+
259
+ # Internal: Track the unique ID to identify the meeting in an Adobe url.
230
260
  #
231
- # Returns a meeting string.
232
- def generate_meeting_url
233
- "#{config[:domain]}/#{meeting_url_suffix}"
261
+ # Returns nothing
262
+ def meeting_url_id=(value)
263
+ settings[:meeting_url_id] = value
264
+ end
265
+
266
+ # Internal: Generate a URL suffix for this conference. Uses a more globally unique approach.
267
+ #
268
+ # Returns a URL suffix string of format "canvas-meeting-:root_acount_global_id-:id-:created_at_as_integer".
269
+ def meeting_url_suffix
270
+ "canvas-mtg-#{self.context.root_account.global_id}-#{self.id}-#{self.created_at.to_i}"
234
271
  end
235
272
 
236
- # Internal: Generate a URL suffix for this conference.
273
+ # Internal: Generate a URL suffix for this conference. Uses the legacy approach with overly simple uniqueness
237
274
  #
238
275
  # Returns a URL suffix string of format "canvas-meeting-:id".
239
- def generate_meeting_url_suffix
276
+ def meeting_url_suffix_legacy
240
277
  "canvas-meeting-#{self.id}"
241
278
  end
242
279
  end
@@ -32,6 +32,15 @@
32
32
  <%= f.password_field :password, :autocomplete => false %><br>
33
33
  </td>
34
34
  </tr>
35
+ <tr>
36
+ <td><%= f.label :use_sis_ids, "Use SIS IDs" %></td>
37
+ <td>
38
+ <%= f.check_box "use_sis_ids", {}, 'yes', 'no' %><br />
39
+ <small class="help-text">
40
+ <%= t(:use_sis_ids_description, "Use a user's SIS as their Connect login ID") %>
41
+ </small>
42
+ </td>
43
+ <tr>
35
44
  </tbody>
36
45
  </table>
37
46
  <% end %>
@@ -21,7 +21,7 @@ module Canvas
21
21
  module Validators
22
22
  module AdobeConnectValidator
23
23
  # Public: An array of allowed plugin settings.
24
- REQUIRED_KEYS = %w{domain login password meeting_container}
24
+ REQUIRED_KEYS = %w{domain login password meeting_container use_sis_ids}
25
25
 
26
26
  # Public: Validate setting input for this plugin.
27
27
  #
@@ -22,6 +22,7 @@ require 'canvas_connect/version'
22
22
  module CanvasConnect
23
23
  class ConnectionError < StandardError; end
24
24
  class MeetingFolderError < StandardError; end
25
+ class MeetingNotFound < StandardError; end
25
26
 
26
27
  # Public: Configure as a Canvas plugin.
27
28
  #
@@ -1,3 +1,3 @@
1
1
  module CanvasConnect
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -28,8 +28,8 @@ describe AdobeConnectConference do
28
28
  }
29
29
 
30
30
  before(:each) do
31
- AdobeConnectConference.stubs(:config).returns(CONNECT_CONFIG)
32
31
  @conference = AdobeConnectConference.new
32
+ @conference.stubs(:config).returns(CONNECT_CONFIG)
33
33
  end
34
34
 
35
35
  subject { AdobeConnectConference.new }
@@ -37,11 +37,17 @@ describe AdobeConnectConference do
37
37
  context 'with an admin participant' do
38
38
  before(:each) do
39
39
  @user = User.new(:name => 'Don Draper')
40
+ AdobeConnect::Service.stubs(:user_session).returns('CookieValue')
41
+ @conference.expects(:add_host).with(@user).returns(@user)
40
42
  end
41
43
 
42
- it 'should generate an admin url' do
43
- CanvasConnect::Service.stubs(:user_session).returns('CookieValue')
44
- @conference.expects(:add_host).with(@user).returns(@user)
44
+ it 'should generate an admin url using unique format if stored' do
45
+ stored_url = 'canvas-mtg-ACCOUNT_ID-ID-CREATED_SECONDS'
46
+ @conference.settings[:meeting_url_id] = stored_url
47
+ @conference.admin_join_url(@user).should == "http://connect.example.com/#{stored_url}"
48
+ end
49
+
50
+ it 'should generate an admin url using legacy format' do
45
51
  @conference.admin_join_url(@user).should == "http://connect.example.com/canvas-meeting-#{@conference.id}"
46
52
  end
47
53
  end
metadata CHANGED
@@ -1,32 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Zach Pendleton
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-05-09 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 0.9.6
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 0.9.6
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: adobe_connect
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -65,26 +70,28 @@ files:
65
70
  - spec_canvas/models/adobe_connect_conference_spec.rb
66
71
  homepage: http://instructure.com
67
72
  licenses: []
68
- metadata: {}
69
73
  post_install_message:
70
74
  rdoc_options: []
71
75
  require_paths:
72
76
  - app
73
77
  - lib
74
78
  required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
75
80
  requirements:
76
- - - '>='
81
+ - - ! '>='
77
82
  - !ruby/object:Gem::Version
78
83
  version: '0'
79
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
80
86
  requirements:
81
- - - '>='
87
+ - - ! '>='
82
88
  - !ruby/object:Gem::Version
83
89
  version: '0'
84
90
  requirements: []
85
91
  rubyforge_project:
86
- rubygems_version: 2.0.0
92
+ rubygems_version: 1.8.25
87
93
  signing_key:
88
- specification_version: 4
94
+ specification_version: 3
89
95
  summary: Adobe Connect integration for Instructure Canvas (http://instructure.com).
90
96
  test_files: []
97
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: b78cf0edc21638b06e639c666bcd9256646dd93a
4
- data.tar.gz: 3f92a2cf1aa6fa71844742663d0a520c3f9398fb
5
- SHA512:
6
- metadata.gz: b0b9419da7ee66e6f63f8b99166eaac2fc6144931329de7350321b452c16d90a5c443316a601da462c17260ee2d4a7482b61d6c4cee19f4be0a609abb39caf70
7
- data.tar.gz: f1a7c1a1df733b26493ac64f1e3e462a7c925784a2d3fbcfb0da721c9433adc94ceb9e7f2b34a50ed87eed3b9713e30dcf053cfb99b6b0a6a6bac41aded6a83f