Skip to content

Commit 1d73ed7

Browse files
committed
Update SlackNotifier payload formatting
1 parent 6478080 commit 1d73ed7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

config/notification_types.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
:description: 'Send a notification to an email address, or a comma-separated list of email addresses.'
44
1:
55
:name: 'slack'
6-
:description: '*NOT IMPLEMENTED* Send a notification to a Slack channel or name.'
6+
:description: 'Send a notification to a Slack webhook endpoint.'

lib/slack_notifier.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
require 'json'
2+
13
class SlackNotifier
24
def initialize(webhook, project_id, commit_hash, audit_result)
35
project = Projects[id: project_id]
46
@project_name = project.name
57
@commit_hash = commit_hash
6-
@audit_result = audit_result
8+
@audit_result = JSON.pretty_generate(audit_result) || {}
79
@webhook = webhook
810
end
911

1012
def notify
1113
notifier = Slack::Notifier.new @webhook
12-
notifier.ping "Commit hash #{@commit_hash} of the project #{@project_name} has been detected to violate #{@audit_result}."
14+
notifier.ping "Commit hash [#{@commit_hash}](https://#{@project_name}/commit/#{commit_hash}) of the project #{@project_name} has been detected to violate the following:\n#{@audit_result}\n"
1315
end
1416
end

0 commit comments

Comments
 (0)