Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications work when forum updates #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/views/settings/_slack_settings.html.erb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<input type="checkbox" id="settings_post_updates" value="1" name="settings[post_updates]" <%= settings['post_updates'] == '1' ? 'checked="checked"' : '' %> />
</p>

<p>
<label for="settings_post_message_updates">Post Forum's Message Updates?</label>
<input type="checkbox" id="settings_post_message_updates" value="1" name="settings[post_message_updates]" <%= settings['post_message_updates'] == '1' ? 'checked="checked"' : '' %> />
</p>

<p>
<label for="settings_post_wiki_updates">Post Wiki Updates?</label>
<input type="checkbox" id="settings_post_wiki_updates" value="1" name="settings[post_wiki_updates]" <%= settings['post_wiki_updates'] == '1' ? 'checked="checked"' : '' %> />
Expand Down
40 changes: 40 additions & 0 deletions lib/redmine_slack/listener.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,46 @@ def model_changeset_scan_commit_for_issue_ids_pre_issue_update(context={})
speak msg, channel, attachment, url
end

def controller_messages_new_after_save(context = { })
return unless Setting.plugin_redmine_slack['post_message_updates'] == '1'

project = context[:project]
message = context[:message]

user = message.author
project_url = "<#{object_url project}|#{escape project}>"
message_url = "<#{object_url message}|#{escape message.subject}>"
comment = "[#{project_url}] #{message_url} updated by *#{user}*"

channel = channel_for_project project
url = url_for_project project

attachment = {}
attachment[:text] = "#{escape message.content}"

speak comment, channel, attachment, url
end

def controller_messages_reply_after_save(context = { })
return unless Setting.plugin_redmine_slack['post_message_updates'] == '1'

project = context[:project]
message = context[:message]

user = message.author
project_url = "<#{object_url project}|#{escape project}>"
message_url = "<#{object_url message}|#{escape message.subject}>"
comment = "[#{project_url}] #{message_url} updated by *#{user}*"

channel = channel_for_project project
url = url_for_project project

attachment = {}
attachment[:text] = "#{escape message.content}"

speak comment, channel, attachment, url
end

def controller_wiki_edit_after_save(context = { })
return unless Setting.plugin_redmine_slack['post_wiki_updates'] == '1'

Expand Down