diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-20 08:12:48 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-20 08:12:48 +0000 |
commit | d7127890546c317bd3469f18b9fb5e3a81554d48 (patch) | |
tree | 43e56856035dd219f4683c1f95573da180f1acda /app/controllers | |
parent | ca3fafb904c8293e978a3d7c8c5cafdec4031558 (diff) | |
parent | edd07e2363297d4e296505a8e82eb76b2a009f10 (diff) | |
download | gitlab-ce-d7127890546c317bd3469f18b9fb5e3a81554d48.tar.gz |
Merge branch 'slack_wiki_notifications' into 'master'
add slack notifications for wiki pages
## What does this MR do?
Lets the Slack service be configured to send notifications when wiki pages are created or edited.
## Are there points in the code the reviewer needs to double check?
I'm just starting to get familiar with the Gitlab codebase and I was unsure on how to get the wiki page url to pass it to the slack message, on whether or not I needed to refactor the create/update methods for wiki pages from the controller to a service (but seemed necessary to test it better), and if I needed to add a column to the web hooks table or if the services table would have been enough. Please let me know if I should change anything and I will improve the MR, thanks for checking :)
## Why was this MR needed?
Related to #563 and fixes #4233.
See merge request !2998
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/services_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/wikis_controller.rb | 17 |
2 files changed, 4 insertions, 15 deletions
diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 8b2577aebe1..739681f4085 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -6,7 +6,7 @@ class Projects::ServicesController < Projects::ApplicationController :description, :issues_url, :new_issue_url, :restrict_to_branch, :channel, :colorize_messages, :channels, :push_events, :issues_events, :merge_requests_events, :tag_push_events, - :note_events, :build_events, + :note_events, :build_events, :wiki_page_events, :notify_only_broken_builds, :add_pusher, :send_from_committer_email, :disable_diffs, :external_wiki_url, :notify, :color, diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 9f3a4a69721..c02bc28acef 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -44,7 +44,7 @@ class Projects::WikisController < Projects::ApplicationController return render('empty') unless can?(current_user, :create_wiki, @project) - if @page.update(content, format, message) + if @page = WikiPages::UpdateService.new(@project, current_user, wiki_params).execute(@page) redirect_to( namespace_project_wiki_path(@project.namespace, @project, @page), notice: 'Wiki was successfully updated.' @@ -55,9 +55,9 @@ class Projects::WikisController < Projects::ApplicationController end def create - @page = WikiPage.new(@project_wiki) + @page = WikiPages::CreateService.new(@project, current_user, wiki_params).execute - if @page.create(wiki_params) + if @page.persisted? redirect_to( namespace_project_wiki_path(@project.namespace, @project, @page), notice: 'Wiki was successfully updated.' @@ -122,15 +122,4 @@ class Projects::WikisController < Projects::ApplicationController params[:wiki].slice(:title, :content, :format, :message) end - def content - params[:wiki][:content] - end - - def format - params[:wiki][:format] - end - - def message - params[:wiki][:message] - end end |