2022-11-25 23:54:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PagesDomains
|
|
|
|
class UpdateService < BaseService
|
|
|
|
def execute(domain)
|
|
|
|
return unless authorized?
|
|
|
|
|
|
|
|
return false unless domain.update(params)
|
|
|
|
|
|
|
|
publish_event(domain)
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def authorized?
|
|
|
|
current_user.can?(:update_pages, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def publish_event(domain)
|
|
|
|
event = PagesDomainUpdatedEvent.new(
|
|
|
|
data: {
|
|
|
|
project_id: project.id,
|
|
|
|
namespace_id: project.namespace_id,
|
|
|
|
root_namespace_id: project.root_namespace.id,
|
2023-03-17 16:20:25 +05:30
|
|
|
domain_id: domain.id,
|
2022-11-25 23:54:43 +05:30
|
|
|
domain: domain.domain
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
Gitlab::EventStore.publish(event)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|