chore: Add delay for slack job when message has attachments (#7107)
This commit is contained in:
@@ -20,8 +20,14 @@ class HookJob < ApplicationJob
|
||||
return unless ['message.created'].include?(event_name)
|
||||
|
||||
message = event_data[:message]
|
||||
|
||||
Integrations::Slack::SendOnSlackService.new(message: message, hook: hook).perform
|
||||
if message.attachments.blank?
|
||||
::SendOnSlackJob.perform_later(message: message,
|
||||
hook: hook)
|
||||
else
|
||||
::SendOnSlackJob.set(wait: 2.seconds).perform_later(
|
||||
message: message, hook: hook
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def process_dialogflow_integration(hook, event_name, event_data)
|
||||
|
||||
8
app/jobs/send_on_slack_job.rb
Normal file
8
app/jobs/send_on_slack_job.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class SendOnSlackJob < ApplicationJob
|
||||
queue_as :medium
|
||||
pattr_initialize [:message!, :hook!]
|
||||
|
||||
def perform
|
||||
Integrations::Slack::SendOnSlackService.new(message: message, hook: hook).perform
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user