Module: Gitlab::DataBuilder::WikiPage

Extended by:
WikiPage
Included in:
WikiPage
Defined in:
lib/gitlab/data_builder/wiki_page.rb

Instance Method Summary collapse

Instance Method Details

#build(wiki_page, user, action) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/data_builder/wiki_page.rb', line 8

def build(wiki_page, user, action)
  wiki = wiki_page.wiki

  # TODO: group hooks https://gitlab.com/gitlab-org/gitlab/-/issues/216904
  return {} if wiki.container.is_a?(Group)

  {
    object_kind: wiki_page.class.name.underscore,
    user: user.hook_attrs,
    project: wiki.project.hook_attrs,
    wiki: wiki.hook_attrs,
    object_attributes: wiki_page.hook_attrs.merge(
      url: Gitlab::UrlBuilder.build(wiki_page),
      action: action,
      diff_url: Gitlab::UrlBuilder.build(wiki_page, action: :diff, version_id: wiki_page.version.id)
    )
  }
end