2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
module WikiPages
|
|
|
|
class CreateService < WikiPages::BaseService
|
|
|
|
def execute
|
2020-05-24 23:13:21 +05:30
|
|
|
wiki = Wiki.for_container(container, current_user)
|
|
|
|
page = WikiPage.new(wiki)
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
if page.create(@params)
|
2020-04-22 19:07:51 +05:30
|
|
|
execute_hooks(page)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
if page.persisted?
|
|
|
|
ServiceResponse.success(payload: { page: page })
|
|
|
|
else
|
|
|
|
ServiceResponse.error(message: _('Could not create wiki page'), payload: { page: page })
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
def usage_counter_action
|
|
|
|
:create
|
|
|
|
end
|
|
|
|
|
|
|
|
def external_action
|
|
|
|
'create'
|
|
|
|
end
|
|
|
|
|
|
|
|
def event_action
|
2020-06-23 00:09:42 +05:30
|
|
|
:created
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|