Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base_service.rb « wiki_pages « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 14317ea65c8454e6d834736953d65ba8146b5cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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