gitlab-org--gitlab-foss/app/services/wiki_pages/base_service.rb
Gabriel Mazetto aaaed331ba Fix hook data for Wiki Page event
Added "wiki" section and removed "repository"
2016-05-31 11:24:58 -03:00

26 lines
710 B
Ruby

module WikiPages
class BaseService < ::BaseService
def hook_data(page, action)
hook_data = {
object_kind: page.class.name.underscore,
user: current_user.hook_attrs,
project: @project.hook_attrs,
wiki: @project.wiki.hook_attrs,
object_attributes: page.hook_attrs
}
page_url = Gitlab::UrlBuilder.build(page)
hook_data[:object_attributes].merge!(url: page_url, action: action)
hook_data
end
private
def execute_hooks(page, action = 'create')
page_data = hook_data(page, action)
@project.execute_hooks(page_data, :wiki_page_hooks)
@project.execute_services(page_data, :wiki_page_hooks)
end
end
end