2018-11-05 23:45:35 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-20 11:12:06 -04:00
|
|
|
module Gitlab
|
|
|
|
module DataBuilder
|
|
|
|
module WikiPage
|
|
|
|
extend self
|
|
|
|
|
|
|
|
def build(wiki_page, user, action)
|
|
|
|
wiki = wiki_page.wiki
|
|
|
|
|
2020-05-13 08:07:54 -04:00
|
|
|
# TODO: group hooks https://gitlab.com/gitlab-org/gitlab/-/issues/216904
|
|
|
|
return {} if wiki.container.is_a?(Group)
|
|
|
|
|
2017-07-20 11:12:06 -04:00
|
|
|
{
|
|
|
|
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),
|
2021-06-03 08:10:18 -04:00
|
|
|
action: action,
|
|
|
|
diff_url: Gitlab::UrlBuilder.build(wiki_page, action: :diff, version_id: wiki_page.version.id)
|
2017-07-20 11:12:06 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|