Taskme update

This commit is contained in:
Senad Uka
2020-06-30 05:08:23 +02:00
parent 1cd125382f
commit 71ad502cc1
210 changed files with 6316 additions and 766 deletions

View File

@@ -1,8 +1,13 @@
# frozen_string_literal: true
require './lib/zoom_wrapper_monkeypatch'
class ZoomGateway
class AuthenticationError < StandardError; end
class MeetingExpired < StandardError; end
class UserNotFound < StandardError; end
class TooManyHosts < StandardError; end
class UserAlreadyExists < StandardError; end
class << self
def USER_TYPE_NAME
@@ -20,12 +25,24 @@ class ZoomGateway
end
def HOST_ROLE
"#{self.USER_TYPE_NAME}-directme-host"
self.host_role_name(self.USER_TYPE_NAME)
end
def ACCOUNT_NUMBER
ENV['ZOOM_ACCOUNT_NUMBER']
end
def enable_recordings?
ENV['ZOOM_ENABLE_RECORDINGS'] == 'true'
end
def apply_limits?
self.USER_TYPE_NAME == 'pro'
end
def host_role_name(user_type_name)
"#{user_type_name}-directme-host"
end
end
def initialize
@@ -33,12 +50,14 @@ class ZoomGateway
end
def create_meeting(host_id, **kwargs)
recording_type = self.class.enable_recordings? ? 'cloud' : 'none'
meeting = @client.meeting_create({ user_id: host_id,
topic: kwargs[:topic],
type: 1, # Instant meeting
settings: {
host_video: true,
participant_video: true
participant_video: true,
auto_recording: recording_type,
} })
meeting["id"]
end
@@ -50,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)
@@ -67,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"]}]
@@ -78,6 +116,10 @@ class ZoomGateway
@client.user_delete(id: host_id)
end
def delete_recording(meeting_id, recording_id)
@client.recording_delete(meeting_id: meeting_id, recording_id: recording_id)
end
private
def parse_zoom_error(error)
@@ -87,6 +129,8 @@ class ZoomGateway
raise UserNotFound, error.message
elsif error.status_code == 3001
raise MeetingExpired, error.message
elsif error.status_code == 1005
raise UserAlreadyExists, error.message
else
raise error
end