Skip to content
Snippets Groups Projects
Verified Commit 38931205 authored by tribut's avatar tribut :man_dancing:
Browse files

Switch back to a simple config for filedrop

Also account for absolute/relative paths
parent 271a22f4
Branches
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ module Pretalx
queue_as :default
include ActionView::Helpers
def import_schedule(conference, url, filedrop_config)
def import_schedule(conference, url, filedrop_url)
response = HTTParty.get(url)
response.success? or return Rails.logger.error "Failed to fetch schedule from #{url}"
......@@ -17,7 +17,7 @@ module Pretalx
schedule.dig('schedule', 'conference', 'rooms') &&
schedule.dig('schedule', 'conference', 'days')
filedrop_index = fetch_filedrop_index(filedrop_config)
filedrop_index = fetch_filedrop_index(filedrop_url)
# We keep a local hash of the stages, because the sessions reference stages by name instead of id
stages = {}
......@@ -62,7 +62,7 @@ module Pretalx
end
end
session.recorded = !session_data.fetch('do_not_record', false)
update_filedrop_data(session, filedrop_index[session.ref_id], filedrop_config) if filedrop_index[session.ref_id]
update_filedrop_data(session, filedrop_index[session.ref_id], filedrop_url) if filedrop_index[session.ref_id]
session.save!
end
end
......@@ -83,14 +83,12 @@ module Pretalx
private
def fetch_filedrop_index(filedrop_config)
if !filedrop_config || !filedrop_config['url']
return {}
end
def fetch_filedrop_index(filedrop_url)
return {} unless filedrop_url
begin
response = HTTParty.get(
filedrop_config['url'] + "/",
filedrop_url,
basic_auth: {
username: fetch_credential("filedrop_user"),
password: fetch_credential("filedrop_password") },
......@@ -112,7 +110,7 @@ module Pretalx
end
end
def update_filedrop_data(session, filedrop_data, filedrop_config)
def update_filedrop_data(session, filedrop_data, filedrop_url)
existing_comments = session.filedrop_comments.pluck(:body)
new_comments = filedrop_data["comments"]&.pluck("body") || []
......@@ -142,7 +140,9 @@ module Pretalx
session.filedrop_files.find_or_initialize_by(name: file_data['name'], checksum: file_data['meta']['hash']).tap do |file|
file.size = file_data['meta']['size']
file.orig_created = parse_datetime_or_nil(file_data['meta']['created'])
file.download(filedrop_config['url'] + file_data['url']) unless filedrop_config.fetch('skip_downloads', false)
uri = URI(filedrop_url.chomp("/"))
uri.path = path.start_with?("/") ? path : [uri.path, path].join("/")
file.download(uri)
file.save
end
end
......
......@@ -56,10 +56,7 @@ Conference.find_or_create_by(slug: "38c3").tap do |c|
c.ends_at = DateTime.parse("30 December 2024 19:00 CET")
c.data = {
"schedule_url" => "https://api.events.ccc.de/congress/2024/assembly/6840c453-af5c-413c-8127-adcbdcd98e9e/schedule.json",
"filedrop" => {
"url" => "https://speakers.c3lingo.org"
}
"filedrop_url" => "https://speakers.c3lingo.org/"
}
c.import_job_class = "pretalx"
c.location = "Congress Center Hamburg"
......@@ -73,10 +70,7 @@ Conference.find_or_create_by(slug: "38c3-more").tap do |c|
c.ends_at = DateTime.parse("30 December 2024 19:00 CET")
c.data = {
"schedule_url" => "https://api.events.ccc.de/congress/2024/assembly/6840c453-af5c-413c-8127-adcbdcd98e9e/schedule.json",
"filedrop" => {
"url" => "https://speakers.c3lingo.org",
"skip_downloads" => true
}
"filedrop_url" => "https://speakers.c3lingo.org/"
}
c.import_job_class = "pretalx"
c.location = "Congress Center Hamburg"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment