summaryrefslogtreecommitdiff
path: root/app/services/wiki_pages
diff options
context:
space:
mode:
authorSebastian Klier <sebastian@sebastianklier.com>2016-02-28 15:26:52 +0800
committerSebastian Klier <sebastian@sebastianklier.com>2016-04-20 08:25:40 +0800
commit54661d3d44a7d98ed52680b074b2caed7aa33676 (patch)
treeb55ca87853bebdd44e8039b04f959a6d07f5213d /app/services/wiki_pages
parent9617c274ab301e4d2401b2d9a179f40649259d3c (diff)
downloadgitlab-ce-54661d3d44a7d98ed52680b074b2caed7aa33676.tar.gz
add slack notifications for wiki pages
update changelog
Diffstat (limited to 'app/services/wiki_pages')
-rw-r--r--app/services/wiki_pages/base_service.rb26
-rw-r--r--app/services/wiki_pages/create_service.rb13
-rw-r--r--app/services/wiki_pages/update_service.rb11
3 files changed, 50 insertions, 0 deletions
diff --git a/app/services/wiki_pages/base_service.rb b/app/services/wiki_pages/base_service.rb
new file mode 100644
index 00000000000..e4c0506e20c
--- /dev/null
+++ b/app/services/wiki_pages/base_service.rb
@@ -0,0 +1,26 @@
+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,
+ object_attributes: page.hook_attrs,
+ # DEPRECATED
+ repository: @project.hook_attrs.slice(:name, :url, :description, :homepage)
+ }
+ page_url = "#{Gitlab.config.gitlab.url}#{@project.wiki.wiki_base_path}/#{page.slug}"
+ 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
diff --git a/app/services/wiki_pages/create_service.rb b/app/services/wiki_pages/create_service.rb
new file mode 100644
index 00000000000..988c663b9d0
--- /dev/null
+++ b/app/services/wiki_pages/create_service.rb
@@ -0,0 +1,13 @@
+module WikiPages
+ class CreateService < WikiPages::BaseService
+ def execute
+ page = WikiPage.new(@project.wiki)
+
+ if page.create(@params)
+ execute_hooks(page, 'create')
+ end
+
+ page
+ end
+ end
+end
diff --git a/app/services/wiki_pages/update_service.rb b/app/services/wiki_pages/update_service.rb
new file mode 100644
index 00000000000..8f6a50da838
--- /dev/null
+++ b/app/services/wiki_pages/update_service.rb
@@ -0,0 +1,11 @@
+module WikiPages
+ class UpdateService < WikiPages::BaseService
+ def execute(page)
+ if page.update(@params[:content], @params[:format], @params[:message])
+ execute_hooks(page, 'update')
+ end
+
+ page
+ end
+ end
+end