Skip to content

Commit

Permalink
When creating or updating an app do the ssl certificate generation im…
Browse files Browse the repository at this point in the history
…mediately
  • Loading branch information
mlandauer committed Jun 7, 2022
1 parent 43e04ff commit df33758
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/services/app_services/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call
app = App.new(@attributes.merge(team: current_admin.team))
Pundit.authorize(current_admin, app, :create?)
if app.save
# TODO: kick off the generation of a certificate in the background here
SetupCustomTrackingDomainSSLWorker.perform_async(app.id) if app.custom_tracking_domain.present?
success!
else
fail!
Expand Down
2 changes: 1 addition & 1 deletion app/services/app_services/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def call
attributes[:custom_tracking_domain_ssl_enabled] = false
end

# TODO: If we're updating the custom_tracking_domain then also start generation of certificate
if app.update(attributes)
SetupCustomTrackingDomainSSLWorker.perform_async(app.id) if app.custom_tracking_domain.present?
success!
else
fail!
Expand Down
12 changes: 12 additions & 0 deletions lib/setup_custom_tracking_domain_ssl_worker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

# For Sidekiq
class SetupCustomTrackingDomainSSLWorker
include Sidekiq::Worker

def perform(app_id)
app = App.find(app_id)
AppServices::SetupCustomTrackingDomainSSL.call(app: app)
# TODO: Check whether that worked
end
end

0 comments on commit df33758

Please sign in to comment.