Commit 44ab8830 authored by Stan Hu's avatar Stan Hu

Support an allow list

This makes it possible to sync group conversations without a special
`[REC]` in the title.
parent 2a644f9c
......@@ -6,7 +6,7 @@ limited and costly, but we continue do this to enable all team members to
view the videos.
NOTE: The script will **only** copy meetings that have `[REC]` in the
meeting title.
meeting title. However, `zoom_sync.yml` can be configured with an [allow list](#allow-list).
NOTE: This script no longer purges videos from Zoom, and it does not
retain state. Because of this, the script will scan yesterday's videos and
......@@ -36,6 +36,8 @@ api_key: <YOUR API KEY>
api_secret: <YOUR API SECRET>
```
Environment variables take precedence over the `zoom_sync.yml` values.
If `GOOGLE_DRIVE_SERVICE_ACCOUNT_KEY` is not available, the script will
attempt to load `config.json`. If that file does not exist, the Google
API will attempt to obtain to retrieve the credentials from your
......@@ -56,6 +58,20 @@ existing Google Cloud account. An example JSON:
}
```
## Allow List
`zoom_sync.yml` can also specify a list of recordings that match a given
e-mail address and topic:
```yaml
---
allow_list:
- email: someone@gitlab.com
regex: Group Conversation
- email: someone@gitlab.com
regex: Important Topic
```
## Run-time parameters
If you need to sync a meeting that was created previous to the current
......
......@@ -201,13 +201,14 @@ end
# rubocop:disable Metrics/ClassLength
class ZoomSyncher
attr_reader :client, :gdrive_client
attr_reader :config, :client, :gdrive_client
MAX_FILE_SIZE_BYTES = 2_000_000_000 # 2 GB
REC_REGEX = /\[\s*REC\s*\]/i.freeze
def initialize
@client = ZoomClient.new(load_zoom_config)
@config = load_zoom_config
@client = ZoomClient.new(@config)
@gdrive_client = GoogleDriveClient.new(load_gdrive_config, load_gdrive_id)
end
......@@ -226,8 +227,7 @@ class ZoomSyncher
puts "Scanning recordings for #{user['email']}"
client.recordings(user_id: host_id, from: start_date, to: end_date).each do |recording|
username = user['email']
sync_recording(recording, username)
sync_recording(recording, user_email)
end
# Zoom rate limits API requests, so pause between users
......@@ -236,8 +236,18 @@ class ZoomSyncher
end
end
def sync_recording(item, prefix)
unless item['topic'].match(REC_REGEX)
def sync?(item, email)
return true if item['topic'].match(REC_REGEX)
config['allow_list'].each do |entry|
return true if email == entry['email'] && item['topic'].match(entry['regex'])
end
false
end
def sync_recording(item, email)
unless sync?(item, email)
puts "Skipping '#{item['topic']}' as it doesn't include [REC]"
return
end
......@@ -264,7 +274,7 @@ class ZoomSyncher
end
ext = file_extension(file_type)
folder = subfolder(prefix, topic, file_type)
folder = subfolder(email, topic, file_type)
filename = sanitize_filename("#{topic}-#{event_date}-#{uuid}-#{index}") + ".#{ext}"
video_url = file['download_url'] + "?access_token=#{client.access_token}"
file_size = file['file_size']
......@@ -297,14 +307,19 @@ class ZoomSyncher
private
def load_zoom_config
config = YAML.load_file('zoom_sync.yml') if File.exist?('zoom_sync.yml')
config ||= {}
if ENV['ZOOM_API_KEY'] && ENV['ZOOM_API_SECRET']
{
'api_key' => ENV['ZOOM_API_KEY'],
'api_secret' => ENV['ZOOM_API_SECRET']
}
else
YAML.load_file('zoom_sync.yml')
config.merge!(
{
'api_key' => ENV['ZOOM_API_KEY'],
'api_secret' => ENV['ZOOM_API_SECRET']
}
)
end
config
end
# Returns a config object that responds to client_id, etc.:
......
---
allow_list:
- email: peopleops@gitlab.com
regex: Group Conversation
- email: peopleops@gitlab.com
regex: AMA
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment