amazon-chime-sdk-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +87 -0
- data/.rspec +2 -0
- data/.travis.yml +47 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +25 -0
- data/LICENSE +21 -0
- data/README.md +1109 -0
- data/Rakefile +20 -0
- data/amazon-chime-sdk-rails.gemspec +29 -0
- data/gemfiles/Gemfile.rails-5.0 +25 -0
- data/gemfiles/Gemfile.rails-5.1 +25 -0
- data/gemfiles/Gemfile.rails-5.2 +25 -0
- data/gemfiles/Gemfile.rails-6.0 +25 -0
- data/lib/amazon-chime-sdk-rails.rb +37 -0
- data/lib/chime_sdk/config.rb +90 -0
- data/lib/chime_sdk/controller/attendees.rb +128 -0
- data/lib/chime_sdk/controller/common.rb +202 -0
- data/lib/chime_sdk/controller/meetings.rb +192 -0
- data/lib/chime_sdk/meeting_coordinator.rb +184 -0
- data/lib/chime_sdk/version.rb +4 -0
- data/lib/generators/chime_sdk/controllers_generator.rb +104 -0
- data/lib/generators/chime_sdk/install_generator.rb +27 -0
- data/lib/generators/chime_sdk/js_generator.rb +67 -0
- data/lib/generators/chime_sdk/views_generator.rb +43 -0
- data/lib/generators/templates/chime_sdk.rb +28 -0
- data/lib/generators/templates/controllers/README +35 -0
- data/lib/generators/templates/controllers/meeting_attendees_controller.rb +106 -0
- data/lib/generators/templates/controllers/meetings_controller.rb +146 -0
- data/lib/generators/templates/views/meetings/index.html.erb +27 -0
- data/lib/generators/templates/views/meetings/show.html.erb +136 -0
- data/spec/factories/rooms.rb +5 -0
- data/spec/factories/users.rb +8 -0
- data/spec/generators/controllers_generator_spec.rb +113 -0
- data/spec/generators/install_generator_spec.rb +24 -0
- data/spec/generators/js_generator_spec.rb +26 -0
- data/spec/generators/views_generator_spec.rb +46 -0
- data/spec/rails_app/Rakefile +15 -0
- data/spec/rails_app/app/assets/config/manifest.js +2 -0
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/assets/javascripts/.keep +0 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_app/app/assets/stylesheets/scaffolds.scss +65 -0
- data/spec/rails_app/app/controllers/api/meeting_attendees_controller.rb +3 -0
- data/spec/rails_app/app/controllers/api/meetings_controller.rb +3 -0
- data/spec/rails_app/app/controllers/api/rooms_controller.rb +3 -0
- data/spec/rails_app/app/controllers/application_controller.rb +11 -0
- data/spec/rails_app/app/controllers/entries_controller.rb +47 -0
- data/spec/rails_app/app/controllers/meeting_attendees_controller.rb +121 -0
- data/spec/rails_app/app/controllers/meetings_controller.rb +162 -0
- data/spec/rails_app/app/controllers/rooms_controller.rb +76 -0
- data/spec/rails_app/app/controllers/spa_controller.rb +6 -0
- data/spec/rails_app/app/javascript/App.vue +50 -0
- data/spec/rails_app/app/javascript/channels/consumer.js +6 -0
- data/spec/rails_app/app/javascript/channels/index.js +5 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +84 -0
- data/spec/rails_app/app/javascript/components/meetings/Index.vue +100 -0
- data/spec/rails_app/app/javascript/components/meetings/Meeting.vue +178 -0
- data/spec/rails_app/app/javascript/components/rooms/Index.vue +53 -0
- data/spec/rails_app/app/javascript/components/rooms/Show.vue +91 -0
- data/spec/rails_app/app/javascript/packs/application.js +17 -0
- data/spec/rails_app/app/javascript/packs/spa.js +14 -0
- data/spec/rails_app/app/javascript/router/index.js +74 -0
- data/spec/rails_app/app/javascript/store/index.js +37 -0
- data/spec/rails_app/app/models/application_record.rb +3 -0
- data/spec/rails_app/app/models/entry.rb +5 -0
- data/spec/rails_app/app/models/room.rb +12 -0
- data/spec/rails_app/app/models/user.rb +6 -0
- data/spec/rails_app/app/views/devise/registrations/new.html.erb +34 -0
- data/spec/rails_app/app/views/layouts/_header.html.erb +20 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +18 -0
- data/spec/rails_app/app/views/meetings/index.html.erb +28 -0
- data/spec/rails_app/app/views/meetings/show.html.erb +136 -0
- data/spec/rails_app/app/views/rooms/_form.html.erb +22 -0
- data/spec/rails_app/app/views/rooms/_room.json.jbuilder +7 -0
- data/spec/rails_app/app/views/rooms/edit.html.erb +6 -0
- data/spec/rails_app/app/views/rooms/index.html.erb +27 -0
- data/spec/rails_app/app/views/rooms/index.json.jbuilder +1 -0
- data/spec/rails_app/app/views/rooms/new.html.erb +5 -0
- data/spec/rails_app/app/views/rooms/show.html.erb +42 -0
- data/spec/rails_app/app/views/rooms/show.json.jbuilder +1 -0
- data/spec/rails_app/app/views/spa/index.html.erb +1 -0
- data/spec/rails_app/babel.config.js +72 -0
- data/spec/rails_app/bin/bundle +114 -0
- data/spec/rails_app/bin/rails +9 -0
- data/spec/rails_app/bin/rake +9 -0
- data/spec/rails_app/bin/setup +36 -0
- data/spec/rails_app/bin/spring +17 -0
- data/spec/rails_app/bin/webpack +18 -0
- data/spec/rails_app/bin/webpack-dev-server +18 -0
- data/spec/rails_app/bin/yarn +11 -0
- data/spec/rails_app/config.ru +5 -0
- data/spec/rails_app/config/application.rb +21 -0
- data/spec/rails_app/config/boot.rb +4 -0
- data/spec/rails_app/config/cable.yml +10 -0
- data/spec/rails_app/config/credentials.yml.enc +1 -0
- data/spec/rails_app/config/database.yml +25 -0
- data/spec/rails_app/config/environment.rb +14 -0
- data/spec/rails_app/config/environments/development.rb +62 -0
- data/spec/rails_app/config/environments/production.rb +112 -0
- data/spec/rails_app/config/environments/test.rb +49 -0
- data/spec/rails_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/rails_app/config/initializers/assets.rb +15 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/chime_sdk.rb +28 -0
- data/spec/rails_app/config/initializers/content_security_policy.rb +30 -0
- data/spec/rails_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/rails_app/config/initializers/devise.rb +311 -0
- data/spec/rails_app/config/initializers/devise_token_auth.rb +60 -0
- data/spec/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails_app/config/initializers/inflections.rb +16 -0
- data/spec/rails_app/config/initializers/mime_types.rb +4 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_app/config/locales/devise.en.yml +65 -0
- data/spec/rails_app/config/locales/en.yml +33 -0
- data/spec/rails_app/config/puma.rb +38 -0
- data/spec/rails_app/config/routes.rb +24 -0
- data/spec/rails_app/config/secrets.yml +8 -0
- data/spec/rails_app/config/spring.rb +6 -0
- data/spec/rails_app/config/storage.yml +34 -0
- data/spec/rails_app/config/webpack/development.js +5 -0
- data/spec/rails_app/config/webpack/environment.js +7 -0
- data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
- data/spec/rails_app/config/webpack/production.js +5 -0
- data/spec/rails_app/config/webpack/test.js +5 -0
- data/spec/rails_app/config/webpacker.yml +97 -0
- data/spec/rails_app/db/migrate/20200912140231_devise_create_users.rb +45 -0
- data/spec/rails_app/db/migrate/20200912140352_add_tokens_to_users.rb +12 -0
- data/spec/rails_app/db/migrate/20200912140657_create_rooms.rb +9 -0
- data/spec/rails_app/db/migrate/20200912140749_create_entries.rb +10 -0
- data/spec/rails_app/db/schema.rb +49 -0
- data/spec/rails_app/db/seeds.rb +41 -0
- data/spec/rails_app/log/.keep +0 -0
- data/spec/rails_app/package.json +23 -0
- data/spec/rails_app/postcss.config.js +12 -0
- data/spec/rails_app/public/404.html +67 -0
- data/spec/rails_app/public/422.html +67 -0
- data/spec/rails_app/public/500.html +66 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/robots.txt +1 -0
- data/spec/rails_app/tmp/.keep +0 -0
- data/spec/requests/atendees_spec.rb +182 -0
- data/spec/requests/meetings_spec.rb +433 -0
- data/spec/spec_helper.rb +35 -0
- metadata +400 -0
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require File.expand_path('../spec/rails_app/config/application', __FILE__)
|
5
|
+
Rails.application.load_tasks
|
6
|
+
|
7
|
+
require 'yard'
|
8
|
+
desc 'Generate documentation for amazon-chime-sdk-rails plugin.'
|
9
|
+
YARD::Rake::YardocTask.new do |t|
|
10
|
+
t.files = ['lib/**/*.rb']
|
11
|
+
end
|
12
|
+
|
13
|
+
# Define dummy module for Rake tasks
|
14
|
+
require 'devise_token_auth'
|
15
|
+
unless defined?(DeviseTokenAuth::Concerns::User)
|
16
|
+
module DeviseTokenAuth::Concerns
|
17
|
+
module User
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require "chime_sdk/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "amazon-chime-sdk-rails"
|
7
|
+
s.version = ChimeSdk::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Shota Yamazaki"]
|
10
|
+
s.email = ["shota.yamazaki.8@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/simukappu/amazon-chime-sdk-rails"
|
12
|
+
s.summary = "Server-side implementation of Amazon Chime SDK for Ruby on Rails application"
|
13
|
+
s.description = "amazon-chime-sdk-rails provides server-side API implementation for Amazon Chime SDK as wrapper functions of AWS SDK for Ruby, and basic controller implementation for Ruby on Rails application."
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.required_ruby_version = '>= 2.2.2'
|
20
|
+
|
21
|
+
s.add_dependency 'railties', '>= 5.0.0'
|
22
|
+
s.add_dependency 'aws-sdk-chime', '>= 1.0.0'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rspec-rails', '>= 4.0.1'
|
25
|
+
s.add_development_dependency 'factory_bot_rails', '>= 6.1.0'
|
26
|
+
s.add_development_dependency 'ammeter', '>= 1.1.4'
|
27
|
+
s.add_development_dependency 'yard', '>= 0.9.25'
|
28
|
+
s.add_development_dependency 'devise_token_auth', '>= 1.1.4'
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec path: '../'
|
4
|
+
|
5
|
+
# Bundle Rails
|
6
|
+
gem 'rails', '~> 5.0.0'
|
7
|
+
|
8
|
+
gem 'sqlite3', '~> 1.3.0'
|
9
|
+
gem 'puma'
|
10
|
+
gem 'sass-rails'
|
11
|
+
gem 'webpacker'
|
12
|
+
gem 'turbolinks'
|
13
|
+
gem 'jbuilder'
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'web-console'
|
17
|
+
gem 'listen'
|
18
|
+
gem 'spring'
|
19
|
+
gem 'spring-watcher-listen'
|
20
|
+
end
|
21
|
+
|
22
|
+
group :test do
|
23
|
+
# gem 'coveralls', require: false
|
24
|
+
gem 'coveralls_reborn', require: false
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec path: '../'
|
4
|
+
|
5
|
+
# Bundle Rails
|
6
|
+
gem 'rails', '~> 5.1.0'
|
7
|
+
|
8
|
+
gem 'sqlite3'
|
9
|
+
gem 'puma'
|
10
|
+
gem 'sass-rails'
|
11
|
+
gem 'webpacker'
|
12
|
+
gem 'turbolinks'
|
13
|
+
gem 'jbuilder'
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'web-console'
|
17
|
+
gem 'listen'
|
18
|
+
gem 'spring'
|
19
|
+
gem 'spring-watcher-listen'
|
20
|
+
end
|
21
|
+
|
22
|
+
group :test do
|
23
|
+
# gem 'coveralls', require: false
|
24
|
+
gem 'coveralls_reborn', require: false
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec path: '../'
|
4
|
+
|
5
|
+
# Bundle Rails
|
6
|
+
gem 'rails', '~> 5.2.0'
|
7
|
+
|
8
|
+
gem 'sqlite3'
|
9
|
+
gem 'puma'
|
10
|
+
gem 'sass-rails'
|
11
|
+
gem 'webpacker'
|
12
|
+
gem 'turbolinks'
|
13
|
+
gem 'jbuilder'
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'web-console'
|
17
|
+
gem 'listen'
|
18
|
+
gem 'spring'
|
19
|
+
gem 'spring-watcher-listen'
|
20
|
+
end
|
21
|
+
|
22
|
+
group :test do
|
23
|
+
# gem 'coveralls', require: false
|
24
|
+
gem 'coveralls_reborn', require: false
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec path: '../'
|
4
|
+
|
5
|
+
# Bundle Rails
|
6
|
+
gem 'rails', '~> 6.0.0'
|
7
|
+
|
8
|
+
gem 'sqlite3'
|
9
|
+
gem 'puma'
|
10
|
+
gem 'sass-rails'
|
11
|
+
gem 'webpacker'
|
12
|
+
gem 'turbolinks'
|
13
|
+
gem 'jbuilder'
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'web-console'
|
17
|
+
gem 'listen'
|
18
|
+
gem 'spring'
|
19
|
+
gem 'spring-watcher-listen'
|
20
|
+
end
|
21
|
+
|
22
|
+
group :test do
|
23
|
+
# gem 'coveralls', require: false
|
24
|
+
gem 'coveralls_reborn', require: false
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Top level namespace of amazon-chime-sdk-rails, server-side implementation of Amazon Chime SDK for Ruby on Rails application.
|
2
|
+
module ChimeSdk
|
3
|
+
extend ActiveSupport::Autoload
|
4
|
+
|
5
|
+
autoload :Config , 'chime_sdk/config'
|
6
|
+
autoload :MeetingCoordinator, 'chime_sdk/meeting_coordinator'
|
7
|
+
|
8
|
+
# Returns configuration object of ChimeSdk.
|
9
|
+
def self.config
|
10
|
+
@config ||= ChimeSdk::Config.new
|
11
|
+
end
|
12
|
+
|
13
|
+
# Sets global configuration options for ChimeSdk.
|
14
|
+
# Available options and their defaults are in the example below:
|
15
|
+
# @example Initializer for Rails
|
16
|
+
# ChimeSdk.configure do |config|
|
17
|
+
# config.appication_name = 'chime-sdk-rails'
|
18
|
+
# config.media_region = 'us-east-1'
|
19
|
+
# config.prefix = "#{config.application_name}-#{Rails.env}-"
|
20
|
+
# config.max_meeting_results = 10
|
21
|
+
# config.max_attendee_results = 10
|
22
|
+
# config.create_meeting_with_attendee = true
|
23
|
+
# config.create_attendee_from_meeting = true
|
24
|
+
# config.create_meeting_by_get_request = false
|
25
|
+
# end
|
26
|
+
def self.configure
|
27
|
+
yield(config) if block_given?
|
28
|
+
end
|
29
|
+
|
30
|
+
# Load AWS SDK for Amazon Chime
|
31
|
+
require 'aws-sdk-chime'
|
32
|
+
|
33
|
+
# Load ChimeSdk helpers
|
34
|
+
require 'chime_sdk/controller/common'
|
35
|
+
require 'chime_sdk/controller/meetings'
|
36
|
+
require 'chime_sdk/controller/attendees'
|
37
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module ChimeSdk
|
2
|
+
# Class used to initialize configuration object.
|
3
|
+
class Config
|
4
|
+
# @overload application_name
|
5
|
+
# Return application name for unique key and metadata of Chime SDK meetings and attendees.
|
6
|
+
# @return [Boolean] application name for unique key and metadata of Chime SDK meetings and attendees
|
7
|
+
# @overload application_name=(value)
|
8
|
+
# Set application name for unique key and metadata of Chime SDK meetings and attendees.
|
9
|
+
# @param [Boolean] application_name The new application_name
|
10
|
+
# @return [Boolean] application name for unique key and metadata of Chime SDK meetings and attendees
|
11
|
+
attr_accessor :application_name
|
12
|
+
|
13
|
+
# @overload media_region
|
14
|
+
# Return media region to host Chime SDK meetings.
|
15
|
+
# @return [Boolean] Media region to host Chime SDK meetings
|
16
|
+
# @overload media_region=(value)
|
17
|
+
# Set media region to host Chime SDK meetings.
|
18
|
+
# @param [Boolean] media_region The new media_region
|
19
|
+
# @return [Boolean] Media region to host Chime SDK meetings
|
20
|
+
attr_accessor :media_region
|
21
|
+
|
22
|
+
# @overload prefix
|
23
|
+
# Return prefix to make unique key of Chime SDK meetings and attendees.
|
24
|
+
# @return [Boolean] Prefix to make unique key of Chime SDK meetings and attendees
|
25
|
+
# @overload prefix=(value)
|
26
|
+
# Set prefix to make unique key of Chime SDK meetings and attendees.
|
27
|
+
# @param [Boolean] prefix The new prefix
|
28
|
+
# @return [Boolean] Prefix to make unique key of Chime SDK meetings and attendees
|
29
|
+
attr_accessor :prefix
|
30
|
+
|
31
|
+
# @overload max_meeting_results
|
32
|
+
# Return default max_results value used in list_meetings API.
|
33
|
+
# @return [Boolean] Default max_results value used in list_meetings API
|
34
|
+
# @overload max_meeting_results=(value)
|
35
|
+
# Set default max_results value used in list_meetings API.
|
36
|
+
# @param [Boolean] max_meeting_results The new max_meeting_results
|
37
|
+
# @return [Boolean] Default max_results value used in list_meetings API
|
38
|
+
attr_accessor :max_meeting_results
|
39
|
+
|
40
|
+
# @overload max_attendee_results
|
41
|
+
# Return default max_results value used in list_attendees API.
|
42
|
+
# @return [Boolean] Default max_results value used in list_attendees API
|
43
|
+
# @overload max_attendee_results=(value)
|
44
|
+
# Set default max_results value used in list_attendees API.
|
45
|
+
# @param [Boolean] max_attendee_results The new max_attendee_results
|
46
|
+
# @return [Boolean] Default max_results value used in list_attendees API
|
47
|
+
attr_accessor :max_attendee_results
|
48
|
+
|
49
|
+
# @overload create_meeting_with_attendee
|
50
|
+
# Return whether the application creates meeting with attendee in meetings#create action.
|
51
|
+
# @return [Boolean] Whether the application creates meeting with attendee in meetings#create action
|
52
|
+
# @overload create_meeting_with_attendee=(value)
|
53
|
+
# Set whether the application creates meeting with attendee in meetings#create action.
|
54
|
+
# @param [Boolean] create_meeting_with_attendee The new create_meeting_with_attendee
|
55
|
+
# @return [Boolean] Whether the application creates meeting with attendee in meetings#create action
|
56
|
+
attr_accessor :create_meeting_with_attendee
|
57
|
+
|
58
|
+
# @overload create_attendee_from_meeting
|
59
|
+
# Return whether the application creates attendee from meeting in meetings#show action.
|
60
|
+
# @return [Boolean] Whether the application creates attendee from meeting in meetings#show action
|
61
|
+
# @overload create_attendee_from_meeting=(value)
|
62
|
+
# Set whether the application creates attendee from meeting in meetings#show action.
|
63
|
+
# @param [Boolean] create_attendee_from_meeting The new create_attendee_from_meeting
|
64
|
+
# @return [Boolean] Whether the application creates attendee from meeting in meetings#show action
|
65
|
+
attr_accessor :create_attendee_from_meeting
|
66
|
+
|
67
|
+
# @overload create_meeting_by_get_request
|
68
|
+
# Return whether the application creates meeting in meetings#index action by HTTP GET request.
|
69
|
+
# @return [Boolean] Whether the application creates meeting in meetings#index action by HTTP GET request
|
70
|
+
# @overload create_meeting_by_get_request=(value)
|
71
|
+
# Set whether the application creates meeting in meetings#index action by HTTP GET request.
|
72
|
+
# @param [Boolean] create_meeting_by_get_request The new create_meeting_by_get_request
|
73
|
+
# @return [Boolean] Whether the application creates meeting in meetings#index action by HTTP GET request
|
74
|
+
attr_accessor :create_meeting_by_get_request
|
75
|
+
|
76
|
+
# Initialize configuration for ChimeSdk.
|
77
|
+
# These configuration can be overridden in initializer.
|
78
|
+
# @return [Config] A new instance of Config
|
79
|
+
def initialize
|
80
|
+
@application_name = 'chime-sdk-rails'
|
81
|
+
@media_region = 'us-east-1'
|
82
|
+
@prefix = "#{@application_name}-#{Rails.env}-"
|
83
|
+
@max_meeting_results = 10
|
84
|
+
@max_attendee_results = 10
|
85
|
+
@create_meeting_with_attendee = true
|
86
|
+
@create_attendee_from_meeting = true
|
87
|
+
@create_meeting_by_get_request = false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module ChimeSdk
|
2
|
+
module Controller
|
3
|
+
# Attendees controller implementation by amazon-chime-sdk-rails.
|
4
|
+
module Attendees
|
5
|
+
# Controller implementation to be included in custom attendees controllers.
|
6
|
+
module Mixin
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
include ChimeSdk::Controller::Common
|
11
|
+
include ActionController::MimeResponds
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /meetings/:meeting_id/attendees
|
15
|
+
def index
|
16
|
+
list_attendees
|
17
|
+
render json: { attendees: @attendees }
|
18
|
+
end
|
19
|
+
|
20
|
+
# GET /meetings/:meeting_id/attendees/:attendee_id
|
21
|
+
def show
|
22
|
+
get_attendee
|
23
|
+
render json: @attendee
|
24
|
+
end
|
25
|
+
|
26
|
+
# POST /meetings/:meeting_id/attendees
|
27
|
+
def create
|
28
|
+
create_attendee
|
29
|
+
render status: 201, json: @attendee
|
30
|
+
end
|
31
|
+
|
32
|
+
# DELETE /meetings/:meeting_id/attendees/:attendee_id
|
33
|
+
def destroy
|
34
|
+
delete_attendee
|
35
|
+
head 204
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
# Override the following functions in your controllers
|
40
|
+
# :nocov:
|
41
|
+
|
42
|
+
# Request parameter representing meeting id such as params[:meeting_id].
|
43
|
+
# Configure it depending on your application routes.
|
44
|
+
# @api protected
|
45
|
+
# @return [String, Integer] Meeting id from request parameter
|
46
|
+
def meeting_id_param
|
47
|
+
params[:meeting_id]
|
48
|
+
end
|
49
|
+
|
50
|
+
# Request parameter representing attendee id such as params[:id].
|
51
|
+
# Configure it depending on your application routes.
|
52
|
+
# @api protected
|
53
|
+
# @return [String, Integer] Attendee id from request parameter
|
54
|
+
def attendee_id_param
|
55
|
+
params[:id]
|
56
|
+
end
|
57
|
+
|
58
|
+
# Unique attendee request id to identify attendee by Amazon Chime.
|
59
|
+
# Configure it depending on your application resources to identify attendee.
|
60
|
+
# For example, set "User-#{current_user.id}" by User model.
|
61
|
+
# @api protected
|
62
|
+
# @return [String] Unique attendee request id to identify attendee by Amazon Chime
|
63
|
+
def attendee_request_id
|
64
|
+
"default"
|
65
|
+
end
|
66
|
+
|
67
|
+
# Path for meetings#index action such as meetings_path.
|
68
|
+
# Configure it depending on your application routes.
|
69
|
+
# @api protected
|
70
|
+
# @param [Hash] params Request parameters for path method
|
71
|
+
# @return [String] Path for meetings#index action such as meetings_path
|
72
|
+
def meeting_resources_path(params = {})
|
73
|
+
meetings_path(params)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Path for meetings#show action such as meeting_path(meeting_id).
|
77
|
+
# Configure it depending on your application routes.
|
78
|
+
# @api protected
|
79
|
+
# @param [String] meeting_id Meeting id
|
80
|
+
# @param [Hash] params Request parameters for path method
|
81
|
+
# @return [String] Path for meetings#show action such as meeting_path(meeting_id)
|
82
|
+
def meeting_resource_path(meeting_id, params = {})
|
83
|
+
meeting_path(meeting_id, params)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Path for attendees#index action such as attendees_path(meeting_id).
|
87
|
+
# Configure it depending on your application routes.
|
88
|
+
# @api protected
|
89
|
+
# @param [String] meeting_id Meeting id
|
90
|
+
# @param [Hash] params Request parameters for path method
|
91
|
+
# @return [String] Path for attendees#index action such as attendees_path(meeting_id)
|
92
|
+
def attendee_resources_path(meeting_id, params = {})
|
93
|
+
attendees_path(meeting_id, params)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Path for attendees#show action such as attendee_path(meeting_id, attendee_id).
|
97
|
+
# Configure it depending on your application routes.
|
98
|
+
# @api protected
|
99
|
+
# @param [String] meeting_id Meeting id
|
100
|
+
# @param [String] attendee_id Attendee id
|
101
|
+
# @param [Hash] params Request parameters for path method
|
102
|
+
# @return [String] Path for attendees#index action such as attendees_path(meeting_id)
|
103
|
+
def attendee_resource_path(meeting_id, attendee_id, params = {})
|
104
|
+
attendee_path(meeting_id, attendee_id, params)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Optional attendee tags to pass to Amazon Chime.
|
108
|
+
# This is an optional parameter and configure it depending on your application.
|
109
|
+
# @api protected
|
110
|
+
# @return [Array<Hash>] Optional tags for attendees
|
111
|
+
def optional_attendee_tags
|
112
|
+
[]
|
113
|
+
end
|
114
|
+
|
115
|
+
# Appication metadata that attendees API returns as JSON response included in attendee resource.
|
116
|
+
# This is an optional parameter and configure it depending on your application.
|
117
|
+
# @api protected
|
118
|
+
# @param [Hash] attendee Attendee JSON object as hash
|
119
|
+
# @return [Hash] Appication metadata for attendees
|
120
|
+
def application_attendee_metadata(attendee)
|
121
|
+
{}
|
122
|
+
end
|
123
|
+
|
124
|
+
# :nocov:
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
module ChimeSdk
|
2
|
+
# Controllers implementation by amazon-chime-sdk-rails.
|
3
|
+
module Controller
|
4
|
+
# Common implementation for controllers.
|
5
|
+
module Common
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
rescue_from Aws::Chime::Errors::ForbiddenException, with: :render_forbidden
|
10
|
+
rescue_from Aws::Chime::Errors::NotFoundException, with: :render_resource_not_found
|
11
|
+
rescue_from Aws::Chime::Errors::ValidationException, with: :render_resource_not_found
|
12
|
+
|
13
|
+
class ::String
|
14
|
+
# Convets to boolean.
|
15
|
+
# Returns true for 'true', '1', 'yes', 'on' and 't'.
|
16
|
+
# Returns false for 'false', '0', 'no', 'off' and 'f'.
|
17
|
+
# @param [Boolean] default Default value to return when the String is not interpretable
|
18
|
+
# @return [Boolean] Convered boolean value
|
19
|
+
def to_boolean(default = nil)
|
20
|
+
return true if ['true', '1', 'yes', 'on', 't'].include? self
|
21
|
+
return false if ['false', '0', 'no', 'off', 'f'].include? self
|
22
|
+
return default
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
# Return meeting id from @meeting object or meeting id param.
|
29
|
+
# @api protected
|
30
|
+
# @return [String] Meeting id
|
31
|
+
def meeting_id
|
32
|
+
@meeting ? @meeting[:Meeting][:MeetingId] : meeting_id_param
|
33
|
+
end
|
34
|
+
|
35
|
+
# Return attendee id from @attendee object or attendee id param.
|
36
|
+
# @api protected
|
37
|
+
# @return [String] Attendee id
|
38
|
+
def attendee_id
|
39
|
+
@attendee ? @attendee[:Attendee][:AttendeeId] : attendee_id_param
|
40
|
+
end
|
41
|
+
|
42
|
+
# List meetings by MeetingCoordinator.
|
43
|
+
# @api protected
|
44
|
+
# @return [Array<Hash>] Meeting list
|
45
|
+
def list_meetings
|
46
|
+
@meetings = ChimeSdk::MeetingCoordinator.list_meetings(prefix_filter: meeting_request_id)
|
47
|
+
@meetings = @meetings.map { |meeting| merge_application_meeting_metadata(meeting) }
|
48
|
+
end
|
49
|
+
|
50
|
+
# Create meeting by MeetingCoordinator.
|
51
|
+
# @api protected
|
52
|
+
# @return [Hash] Created meeting
|
53
|
+
def create_meeting
|
54
|
+
@meeting = ChimeSdk::MeetingCoordinator.create_meeting(meeting_request_id, tags: meeting_tags)
|
55
|
+
@meeting = merge_application_meeting_metadata(@meeting)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Get meeting by MeetingCoordinator.
|
59
|
+
# @api protected
|
60
|
+
# @return [Hash] Meeting
|
61
|
+
def get_meeting
|
62
|
+
@meeting = ChimeSdk::MeetingCoordinator.get_meeting(meeting_id)
|
63
|
+
@meeting = merge_application_meeting_metadata(@meeting)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Delete meeting by MeetingCoordinator.
|
67
|
+
# @api protected
|
68
|
+
# @return [void]
|
69
|
+
def delete_meeting
|
70
|
+
ChimeSdk::MeetingCoordinator.delete_meeting(meeting_id)
|
71
|
+
end
|
72
|
+
|
73
|
+
# List attendees by MeetingCoordinator.
|
74
|
+
# @api protected
|
75
|
+
# @return [Array<Hash>] Attendee list
|
76
|
+
def list_attendees
|
77
|
+
@attendees = ChimeSdk::MeetingCoordinator.list_attendees(meeting_id)
|
78
|
+
@attendees = @attendees.map { |attendee| merge_application_attendee_metadata(attendee) }
|
79
|
+
end
|
80
|
+
|
81
|
+
# Create attendee by MeetingCoordinator.
|
82
|
+
# @api protected
|
83
|
+
# @return [Hash] Created attendee
|
84
|
+
def create_attendee
|
85
|
+
@attendee = ChimeSdk::MeetingCoordinator.create_attendee(meeting_id, attendee_request_id, tags: attendee_tags)
|
86
|
+
@attendee = merge_application_attendee_metadata(@attendee)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Get attendee by MeetingCoordinator.
|
90
|
+
# @api protected
|
91
|
+
# @return [Hash] Attendee
|
92
|
+
def get_attendee
|
93
|
+
@attendee = ChimeSdk::MeetingCoordinator.get_attendee(meeting_id, attendee_id)
|
94
|
+
@attendee = merge_application_attendee_metadata(@attendee)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Delete attendee by MeetingCoordinator.
|
98
|
+
# @api protected
|
99
|
+
# @return [void]
|
100
|
+
def delete_attendee
|
101
|
+
ChimeSdk::MeetingCoordinator.delete_attendee(meeting_id, attendee_id)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Create meeting with attendee by MeetingCoordinator.
|
105
|
+
# @api protected
|
106
|
+
# @return [Hash] Created meeting
|
107
|
+
def create_meeting_with_attendee
|
108
|
+
create_meeting
|
109
|
+
create_attendee_from_meeting
|
110
|
+
@meeting
|
111
|
+
end
|
112
|
+
|
113
|
+
# Create attendee from meeting by MeetingCoordinator.
|
114
|
+
# @api protected
|
115
|
+
# @return [Hash] Created attendee
|
116
|
+
def create_attendee_from_meeting
|
117
|
+
create_attendee
|
118
|
+
@meeting = @meeting.merge(@attendee)
|
119
|
+
@meeting = merge_application_attendee_metadata(@meeting)
|
120
|
+
@meeting = merge_application_attendee_metadata(@meeting)
|
121
|
+
@attendee = merge_application_attendee_metadata(@attendee)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Return common tags for meetings and attendees.
|
125
|
+
# @api protected
|
126
|
+
# @return [Array<Hash>] Common tags
|
127
|
+
def tags
|
128
|
+
[
|
129
|
+
{
|
130
|
+
key: "Application",
|
131
|
+
value: ChimeSdk.config.application_name
|
132
|
+
},
|
133
|
+
{
|
134
|
+
key: "Environment",
|
135
|
+
value: Rails.env
|
136
|
+
}
|
137
|
+
]
|
138
|
+
end
|
139
|
+
|
140
|
+
# Return tags for meetings from defined optional_meeting_tags.
|
141
|
+
# @api protected
|
142
|
+
# @return [Array<Hash>] Tags for meetings
|
143
|
+
def meeting_tags
|
144
|
+
tags + optional_meeting_tags
|
145
|
+
end
|
146
|
+
|
147
|
+
# Return tags for attendees from defined optional_attendee_tags.
|
148
|
+
# @api protected
|
149
|
+
# @return [Array<Hash>] Tags for attendees
|
150
|
+
def attendee_tags
|
151
|
+
tags + optional_attendee_tags
|
152
|
+
end
|
153
|
+
|
154
|
+
# Merge application metadata into meeting instance and return.
|
155
|
+
# @api protected
|
156
|
+
# @param [Hash] meeting Meeting JSON object as hash
|
157
|
+
# @return [Hash] Merged meeting
|
158
|
+
def merge_application_meeting_metadata(meeting)
|
159
|
+
meeting[:Meeting][:ApplicationMetadata] = application_meeting_metadata(meeting)
|
160
|
+
meeting
|
161
|
+
end
|
162
|
+
|
163
|
+
# Merge application metadata into attendee instance and return.
|
164
|
+
# @api protected
|
165
|
+
# @param [Hash] attendee Attendee JSON object as hash
|
166
|
+
# @return [Hash] Merged attendee
|
167
|
+
def merge_application_attendee_metadata(attendee)
|
168
|
+
attendee[:Attendee][:ApplicationMetadata] = application_attendee_metadata(attendee)
|
169
|
+
attendee
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns error response as Hash
|
173
|
+
# @api protected
|
174
|
+
# @return [Hash] Error message
|
175
|
+
def error_response(error_info = {})
|
176
|
+
{ gem: "chime-sdk-rails", error: error_info }
|
177
|
+
end
|
178
|
+
|
179
|
+
# Render Forbidden error with 403 status
|
180
|
+
# @api protected
|
181
|
+
# @return [void]
|
182
|
+
def render_forbidden(error = nil)
|
183
|
+
message_type = error.respond_to?(:message) ? error.message : error
|
184
|
+
respond_to do |format|
|
185
|
+
format.html { redirect_to meeting_resources_path, notice: "Forbidden: #{message_type}" }
|
186
|
+
format.json { render status: 403, json: error_response(code: 403, message: "Forbidden", type: message_type) }
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# Render Resource Not Found error with 404 status
|
191
|
+
# @api protected
|
192
|
+
# @return [void]
|
193
|
+
def render_resource_not_found(error = nil)
|
194
|
+
message_type = error.respond_to?(:message) ? error.message : error
|
195
|
+
respond_to do |format|
|
196
|
+
format.html { redirect_to meeting_resources_path, notice: "Resource not found: #{message_type}" }
|
197
|
+
format.json { render status: 404, json: error_response(code: 404, message: "Resource not found", type: message_type) }
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|