chore: Add delay for slack job when message has attachments (#7107)

This commit is contained in:
Tejaswini Chile
2023-05-22 13:51:14 +05:30
committed by GitHub
parent d6ce1ceeeb
commit 0e903d2365
4 changed files with 56 additions and 9 deletions

View File

@@ -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)

View 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