2024-07-09 14:28:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Settings::BackgroundJobsController < ApplicationController
|
2025-08-23 10:28:25 -04:00
|
|
|
before_action :authenticate_self_hosted!
|
2025-02-15 05:32:52 -05:00
|
|
|
before_action :authenticate_admin!, unless: lambda {
|
|
|
|
|
%w[start_immich_import start_photoprism_import].include?(params[:job_name])
|
|
|
|
|
}
|
2024-07-09 14:28:59 -04:00
|
|
|
|
2025-08-23 10:07:15 -04:00
|
|
|
def index; end
|
2024-07-09 14:28:59 -04:00
|
|
|
|
|
|
|
|
def create
|
2024-08-21 12:40:54 -04:00
|
|
|
EnqueueBackgroundJob.perform_later(params[:job_name], current_user.id)
|
2024-07-09 17:50:19 -04:00
|
|
|
|
|
|
|
|
flash.now[:notice] = 'Job was successfully created.'
|
|
|
|
|
|
2025-02-15 05:32:52 -05:00
|
|
|
redirect_path =
|
|
|
|
|
case params[:job_name]
|
|
|
|
|
when 'start_immich_import', 'start_photoprism_import'
|
|
|
|
|
imports_path
|
|
|
|
|
else
|
|
|
|
|
settings_background_jobs_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
redirect_to redirect_path, notice: 'Job was successfully created.'
|
2024-07-09 14:28:59 -04:00
|
|
|
end
|
|
|
|
|
end
|