debian-mirror-gitlab/app/services/pages/delete_service.rb
2022-07-23 20:15:48 +02:00

30 lines
809 B
Ruby

# frozen_string_literal: true
module Pages
class DeleteService < BaseService
def execute
project.mark_pages_as_not_deployed
# project.pages_domains.delete_all will just nullify project_id:
# > If no :dependent option is given, then it will follow the default
# > strategy for `has_many :through` associations.
# > The default strategy is :nullify which sets the foreign keys to NULL.
PagesDomain.for_project(project).delete_all
publish_deleted_event
DestroyPagesDeploymentsWorker.perform_async(project.id)
end
private
def publish_deleted_event
event = Pages::PageDeletedEvent.new(data: {
project_id: project.id,
namespace_id: project.namespace_id
})
Gitlab::EventStore.publish(event)
end
end
end