diff --git a/app/views/settings/_mattermost_settings.html.erb b/app/views/settings/_mattermost_settings.html.erb index 9f87b21..b2e802c 100644 --- a/app/views/settings/_mattermost_settings.html.erb +++ b/app/views/settings/_mattermost_settings.html.erb @@ -39,3 +39,8 @@ />
+ ++ + /> +
diff --git a/lib/redmine_mattermost/listener.rb b/lib/redmine_mattermost/listener.rb index a8f92ef..a3aebd6 100644 --- a/lib/redmine_mattermost/listener.rb +++ b/lib/redmine_mattermost/listener.rb @@ -103,6 +103,29 @@ class MattermostListener < Redmine::Hook::Listener speak msg, channel, attachment, url end + def controller_wiki_edit_after_save(context = { }) + return unless Setting.plugin_redmine_slack[:post_wiki_updates] == '1' + + project = context[:project] + page = context[:page] + + user = page.content.author + project_url = "<#{object_url project}|#{escape project}>" + page_url = "<#{object_url page}|#{page.title}>" + comment = "[#{project_url}] #{page_url} updated by *#{user}*" + + channel = channel_for_project project + url = url_for_project project + + attachment = nil + if not page.content.comments.empty? + attachment = {} + attachment[:text] = "#{escape page.content.comments}" + end + + speak comment, channel, attachment, url + end + def speak(msg, channel, attachment=nil, url=nil) url = Setting.plugin_redmine_mattermost[:mattermost_url] if not url username = Setting.plugin_redmine_mattermost[:username]