mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 14:26:21 +00:00
Merge branch 'issue-10031' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
commit
6b2e22e0f2
2 changed files with 20 additions and 13 deletions
|
@ -37,7 +37,7 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
unless @issue['iid']
|
if @issue['iid'].blank? && issue_data[:issue].blank?
|
||||||
Rails.cache.delete(cache_key)
|
Rails.cache.delete(cache_key)
|
||||||
raise GitlabNotifierError, @issue.dig('message', 'title')&.join(', ')
|
raise GitlabNotifierError, @issue.dig('message', 'title')&.join(', ')
|
||||||
end
|
end
|
||||||
|
@ -62,8 +62,8 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
# Si este trabajo genera una excepción va a entrar en un loop, así que
|
# Si este trabajo genera una excepción va a entrar en un loop, así que
|
||||||
# la notificamos por correo
|
# la notificamos por correo
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
email_notification.call(e)
|
email_notification.call(e, data: @issue)
|
||||||
email_notification.call(exception, options)
|
email_notification.call(exception, data: options)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -84,10 +84,14 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
exception.class.name,
|
exception.class.name,
|
||||||
Digest::SHA1.hexdigest(exception.message),
|
Digest::SHA1.hexdigest(exception.message),
|
||||||
Digest::SHA1.hexdigest(backtrace&.first.to_s),
|
Digest::SHA1.hexdigest(backtrace&.first.to_s),
|
||||||
Digest::SHA1.hexdigest(options.dig(:data, :params, 'errors').to_s)
|
Digest::SHA1.hexdigest(errors.to_s)
|
||||||
].join('/')
|
].join('/')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def errors
|
||||||
|
options.dig(:data, :params, 'errors') if options.dig(:data, :params).is_a? Hash
|
||||||
|
end
|
||||||
|
|
||||||
# Define si es una excepción de javascript o local
|
# Define si es una excepción de javascript o local
|
||||||
#
|
#
|
||||||
# @see BacktraceJob
|
# @see BacktraceJob
|
||||||
|
@ -126,6 +130,7 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def body
|
def body
|
||||||
@body ||= ''.dup.tap do |b|
|
@body ||= ''.dup.tap do |b|
|
||||||
|
b << log_section
|
||||||
b << request_section
|
b << request_section
|
||||||
b << javascript_footer
|
b << javascript_footer
|
||||||
b << data_section
|
b << data_section
|
||||||
|
@ -162,14 +167,16 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
|
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def log_section
|
def log_section
|
||||||
return '' unless options[:log]
|
return '' unless options.dig(:data, :log)
|
||||||
|
|
||||||
<<~LOG
|
<<~LOG
|
||||||
# Log
|
|
||||||
|
|
||||||
```
|
# Build log
|
||||||
#{options[:log]}
|
|
||||||
```
|
```
|
||||||
|
#{options[:data].delete(:log)}
|
||||||
|
```
|
||||||
|
|
||||||
LOG
|
LOG
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -257,8 +264,8 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
|
|
||||||
## Data
|
## Data
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
#{pp options[:data]}
|
#{options[:data].to_yaml}
|
||||||
```
|
```
|
||||||
|
|
||||||
DATA
|
DATA
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Enviar una notificación cuando falla una tarea
|
# Enviar una notificación cuando falla una tarea
|
||||||
SuckerPunch.exception_handler = lambda { |ex, _klass, _args|
|
SuckerPunch.exception_handler = lambda { |ex, _, args|
|
||||||
ExceptionNotifier.notify_exception(ex)
|
ExceptionNotifier.notify_exception(ex, data: args)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue