2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Pages
|
|
|
|
class DeleteService < BaseService
|
|
|
|
def execute
|
2021-09-04 01:27:46 +05:30
|
|
|
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
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
publish_deleted_event
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
DestroyPagesDeploymentsWorker.perform_async(project.id)
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def publish_deleted_event
|
|
|
|
event = Pages::PageDeletedEvent.new(data: {
|
|
|
|
project_id: project.id,
|
2022-08-13 15:12:31 +05:30
|
|
|
namespace_id: project.namespace_id,
|
|
|
|
root_namespace_id: project.root_namespace.id
|
2022-07-23 23:45:48 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
Gitlab::EventStore.publish(event)
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|