Skip to content

Commit

Permalink
Fixes: slack notification to multiple targets
Browse files Browse the repository at this point in the history
If you configure the slack integration to send out multiple notifications during one transaction, only the first one is sent it.

The variable result, which stores the rendered template, is overriden after sending out the first message to slack.

(Line numbers can be off as I modified the file)
```
zammad-scheduler_1      | E, [2023-03-14T07:52:51.356285 zammad#1-112060] ERROR -- : no implicit conversion of Symbol into Integer (TypeError)
zammad-scheduler_1      | app/models/transaction/slack.rb:200:in `block in perform'
zammad-scheduler_1      | app/models/transaction/slack.rb:118:in `each'
zammad-scheduler_1      | app/models/transaction/slack.rb:118:in `perform'
zammad-scheduler_1      | lib/transaction_dispatcher.rb:61:in `execute_single_backend'
zammad-scheduler_1      | app/jobs/transaction_job.rb:25:in `block in perform'
zammad-scheduler_1      | app/jobs/transaction_job.rb:21:in `perform'
zammad-scheduler_1      | lib/background_services/service/process_delayed_jobs.rb:25:in `block (2 levels) in launch'
zammad-scheduler_1      | lib/background_services/service/process_delayed_jobs.rb:23:in `block in launch'
zammad-scheduler_1      | lib/background_services/service/process_delayed_jobs.rb:20:in `loop'
zammad-scheduler_1      | lib/background_services/service/process_delayed_jobs.rb:20:in `launch'
zammad-scheduler_1      | lib/background_services/service.rb:27:in `block in run'
zammad-scheduler_1      | lib/application_handle_info.rb:19:in `use'
zammad-scheduler_1      | lib/background_services/service.rb:33:in `block in run_in_service_context'
zammad-scheduler_1      | lib/background_services/service.rb:32:in `run_in_service_context'
zammad-scheduler_1      | lib/background_services/service.rb:26:in `run'
zammad-scheduler_1      | lib/background_services.rb:67:in `block in start_as_thread'
```
  • Loading branch information
ChristianKoehler committed Mar 14, 2023
1 parent 6383bac commit 7af7e49
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/transaction/slack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,21 @@ def perform
)
if local_config['expand']
body = "#{result[:subject]}\n#{result[:body]}"
result = notifier.ping body
result_ping = notifier.ping body
else
attachment = {
text: result[:body],
mrkdwn_in: ['text'],
color: color,
}
result = notifier.ping result[:subject],
result_ping = notifier.ping result[:subject],
attachments: [attachment]
end
if !result.empty? && !result[0].success?
if !result_ping.empty? && !result_ping[0].success?
if sent_value
Rails.cache.delete(cache_key)
end
Rails.logger.error "Unable to post webhook: #{local_config['webhook']}: #{result.inspect}"
Rails.logger.error "Unable to post webhook: #{local_config['webhook']}: #{result_ping.inspect}"
next
end
Rails.logger.debug { "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})" }
Expand Down

0 comments on commit 7af7e49

Please sign in to comment.