Compare commits
3 Commits
send-error
...
update-def
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60fc1d467d | ||
|
|
219bc5abd1 | ||
|
|
f5068a3a7e |
@@ -0,0 +1,9 @@
|
||||
class ChangeExistingZoomUsersSettings < ActiveRecord::DataMigration
|
||||
def up
|
||||
gateway = ZoomGateway.new
|
||||
|
||||
ZoomUser.find_each do |zu|
|
||||
gateway.update_user_settings zu.api_id
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -9,20 +9,6 @@ SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||
|
||||
|
||||
--
|
||||
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
||||
|
||||
|
||||
--
|
||||
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require './lib/zoom_wrapper_monkeypatch'
|
||||
|
||||
class ZoomGateway
|
||||
class AuthenticationError < StandardError; end
|
||||
class MeetingExpired < StandardError; end
|
||||
@@ -65,6 +69,23 @@ class ZoomGateway
|
||||
parse_zoom_error(e)
|
||||
end
|
||||
|
||||
# Update user with custom settings
|
||||
def update_user_settings(user_id)
|
||||
custom_defaults = {
|
||||
id: user_id,
|
||||
in_meeting: {
|
||||
auto_saving_chat: true,
|
||||
co_host: true,
|
||||
non_verbal_feedback: true,
|
||||
breakout_room: true,
|
||||
group_hd: true,
|
||||
far_end_camera_control: true,
|
||||
allow_live_streaming: true
|
||||
}
|
||||
}
|
||||
@client.user_settings_update custom_defaults
|
||||
end
|
||||
|
||||
def create_host(host_email)
|
||||
# Find role
|
||||
host_role = @client.roles_list["roles"].try(:select) { |r| r["name"] == self.class.HOST_ROLE }.try(:first)
|
||||
@@ -82,6 +103,8 @@ class ZoomGateway
|
||||
type: self.class.USER_TYPE
|
||||
})
|
||||
|
||||
update_user_settings(host_user["id"])
|
||||
|
||||
# Assign role to user
|
||||
@client.roles_assign role_id: host_role["id"], members: [{id: host_user["id"]}]
|
||||
|
||||
|
||||
25
lib/zoom_wrapper_monkeypatch.rb
Normal file
25
lib/zoom_wrapper_monkeypatch.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Zoom
|
||||
module Actions
|
||||
module User
|
||||
def user_settings_update(*args)
|
||||
params = Zoom::Params.new(Utils.extract_options!(args))
|
||||
permitted_in_meeting_params = %i[
|
||||
auto_saving_chat
|
||||
co_host
|
||||
non_verbal_feedback
|
||||
breakout_room
|
||||
group_hd
|
||||
far_end_camera_control
|
||||
allow_live_streaming
|
||||
]
|
||||
permitted_params = { in_meeting: permitted_in_meeting_params }
|
||||
params.require(:id).permit permitted_params
|
||||
request_body = params.except(:id).to_json
|
||||
resp = self.class.patch("/users/#{params[:id]}/settings", body: request_body, headers: request_headers)
|
||||
Utils.parse_response resp
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,7 @@ RSpec.describe ZoomGateway do
|
||||
let(:host_user_hash) { {"email" => "user1@directme", "id" => "host_user_id"} }
|
||||
let(:roles_members_response) { {"members" => [host_user_hash]} }
|
||||
let(:user_create_response) { {"id" => "new_host_id"} }
|
||||
let(:user_settings_update_response) { "User settings updated" }
|
||||
let(:roles_assign_response) { {"ids" => ["new_host_id"]} }
|
||||
let(:meeting_hash) { {"id" => "meeting_id", "start_url" => "https://start_url", "join_url" => "https://join_url"} }
|
||||
let(:gateway) { ZoomGateway.new }
|
||||
@@ -121,7 +122,9 @@ RSpec.describe ZoomGateway do
|
||||
it "returns new host id" do
|
||||
allow_any_instance_of(Zoom.new.class).to receive(:user_create).and_return(user_create_response)
|
||||
allow_any_instance_of(Zoom.new.class).to receive(:roles_assign).and_return(roles_assign_response)
|
||||
allow_any_instance_of(Zoom.new.class).to receive(:user_settings_update).and_return(user_settings_update_response)
|
||||
|
||||
expect_any_instance_of(Zoom.new.class).to receive(:user_settings_update)
|
||||
expect(gateway.create_host("host-email@address")).to eq("new_host_id")
|
||||
end
|
||||
|
||||
|
||||
60
spec/lib/zoom_wrapper_monkeypatch_spec.rb
Normal file
60
spec/lib/zoom_wrapper_monkeypatch_spec.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Zoom::Actions::User do
|
||||
let(:wrapper) { Zoom.new }
|
||||
|
||||
describe '.update_user_settings' do
|
||||
it 'raises exception if id param is missing' do
|
||||
params = {
|
||||
in_meeting: {
|
||||
not_allowed_param: 1
|
||||
}
|
||||
}
|
||||
|
||||
expect do
|
||||
wrapper.user_settings_update(params)
|
||||
end.to raise_exception(Zoom::ParameterMissing)
|
||||
end
|
||||
|
||||
it 'raises exception if not allowed param is present' do
|
||||
params = {
|
||||
id: 'dw3-3sd33',
|
||||
in_meeting: {
|
||||
not_allowed_param: 1
|
||||
}
|
||||
}
|
||||
|
||||
expect do
|
||||
wrapper.user_settings_update(params)
|
||||
end.to raise_exception(Zoom::ParameterNotPermitted)
|
||||
end
|
||||
|
||||
it 'sends PATCH request to the Zoom API endpoint' do
|
||||
params = {
|
||||
id: 'zoom-120-id',
|
||||
in_meeting: {
|
||||
auto_saving_chat: true,
|
||||
co_host: true,
|
||||
non_verbal_feedback: true,
|
||||
breakout_room: true,
|
||||
group_hd: true,
|
||||
far_end_camera_control: true,
|
||||
allow_live_streaming: true
|
||||
}
|
||||
}
|
||||
|
||||
allow(Zoom::Utils).to receive(:parse_response).and_return 'Success!'
|
||||
|
||||
path = "/users/#{params[:id]}/settings"
|
||||
body_params = { body: params.except(:id).to_json }
|
||||
allow(wrapper.class)
|
||||
.to receive(:patch)
|
||||
.with(path, hash_including(body_params))
|
||||
.and_return({})
|
||||
|
||||
mock_response = wrapper.user_settings_update params
|
||||
expect(mock_response).to eq 'Success!'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user