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 (moved) and fixes #4233 (closed).
Merge request reports
Activity
@sekl The feature looks cool! I'll take a look at the implementation in the coming days (I'm not familiar myself with the hooks/services code so I will learn a lot myself in the process!).
Reassigned to @rymai
Added services label
Added webhooks label
@rymai Let me know if you want me to fix anything or resolve any merge conflicts. I also did this mainly for learning purposes so there might be a bunch of things to improve ;)
44 44 45 45 return render('empty') unless can?(current_user, :create_wiki, @project) 46 46 47 if @page.update(content, format, message) 47 if @page = WikiPages::UpdateService.new(@project, current_user, wiki_params).execute(@page) @sekl Thanks this MR and sorry for the time before I could review it! Please ignore many of my comments about using symbols for
action
and renamingexecute_hooks
, let's prefer consistency with other services.Milestone changed to 8.7
5 5 - Fix avatar stretching by providing a cropping feature (Johann Pardanaud) 6 6 - Strip leading and trailing spaces in URL validator (evuez) 7 7 - Update documentation to reflect Guest role not being enforced on internal projects 8 - Add Slack notifications when Wiki is edited (Sebastian Klier) @sekl And please rebase the MR as well! ;)
@sekl One more thing: please update the web hooks doc as well in
doc/web_hooks/web_hooks.md
.@sekl As noted by @brodock in https://gitlab.com/gitlab-org/gitlab-ce/issues/563#note_4260208, notifications won't be sent when the wiki is updated through Git.
Fortunately, @brodock refactored
PostReceive
so it should be a simple matter of hooking some code at https://gitlab.com/gitlab-org/gitlab-ce/blob/3dd91f55a048c13e6dc81ec685e521d2fc5a78f5/app/workers/post_receive.rb#L21!@rymai Thanks for all the feedback! I'll probably get around to it in the next few days.
@sekl That's fine, thank you!