2018-07-18 12:03:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-28 02:26:52 -05:00
|
|
|
module WikiPages
|
|
|
|
class CreateService < WikiPages::BaseService
|
|
|
|
def execute
|
2020-05-13 08:07:54 -04:00
|
|
|
wiki = Wiki.for_container(container, current_user)
|
|
|
|
page = WikiPage.new(wiki)
|
2016-02-28 02:26:52 -05:00
|
|
|
|
2021-07-07 02:08:23 -04:00
|
|
|
wiki.capture_git_error(event_action) do
|
|
|
|
page.create(@params)
|
2016-02-28 02:26:52 -05:00
|
|
|
end
|
|
|
|
|
2020-08-17 14:10:01 -04:00
|
|
|
if page.persisted?
|
2021-07-07 02:08:23 -04:00
|
|
|
execute_hooks(page)
|
2020-08-17 14:10:01 -04:00
|
|
|
ServiceResponse.success(payload: { page: page })
|
|
|
|
else
|
|
|
|
ServiceResponse.error(message: _('Could not create wiki page'), payload: { page: page })
|
|
|
|
end
|
2016-02-28 02:26:52 -05:00
|
|
|
end
|
2020-03-24 08:09:42 -04:00
|
|
|
|
|
|
|
def usage_counter_action
|
|
|
|
:create
|
|
|
|
end
|
|
|
|
|
|
|
|
def external_action
|
|
|
|
'create'
|
|
|
|
end
|
|
|
|
|
|
|
|
def event_action
|
2020-05-28 11:08:02 -04:00
|
|
|
:created
|
2020-03-24 08:09:42 -04:00
|
|
|
end
|
2016-02-28 02:26:52 -05:00
|
|
|
end
|
|
|
|
end
|