debian-mirror-gitlab/app/services/wiki_pages/create_service.rb

34 lines
678 B
Ruby
Raw Normal View History

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
2021-09-30 23:02:18 +05:30
wiki.capture_git_error(event_action) do
page.create(@params)
2016-06-02 11:05:42 +05:30
end
2020-10-24 23:57:45 +05:30
if page.persisted?
2021-09-30 23:02:18 +05:30
execute_hooks(page)
2020-10-24 23:57:45 +05:30
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