Class: ExceptionNotifier::MattermostNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ExceptionNotifier::MattermostNotifier
- Defined in:
- lib/exception_notifier/mattermost_notifier.rb
Instance Attribute Summary
Attributes inherited from BaseNotifier
Instance Method Summary collapse
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #initialize, #send_notice
Constructor Details
This class inherits a constructor from ExceptionNotifier::BaseNotifier
Instance Method Details
#call(exception, opts = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/exception_notifier/mattermost_notifier.rb', line 7 def call(exception, opts = {}) = opts.merge() @exception = exception @formatter = Formatter.new(exception, ) @gitlab_url = [:git_url] @env = [:env] || {} payload = { text: .compact.join("\n"), username: [:username] || "Exception Notifier" } payload[:icon_url] = [:avatar] if [:avatar] payload[:channel] = [:channel] if [:channel] = .except( :avatar, :channel, :username, :git_url, :webhook_url, :env, :accumulated_errors_count, :app_name ) [:body] = payload.to_json [:headers] ||= {} [:headers]["Content-Type"] = "application/json" HTTParty.post([:webhook_url], ) end |