* feat(webhook): retry job on 404 * feat(webhook): enhance retry logic for 404 errors and update message status * feat(webhook): update supported message events to use dynamic error handling * chore: refactor logic * feat(webhook): simplify RetriableError initialization and improve error handling for 404 responses
18 lines
664 B
Ruby
18 lines
664 B
Ruby
class WebhookJob < ApplicationJob
|
|
queue_as :medium
|
|
|
|
retry_on CustomExceptions::Webhook::RetriableError, wait: :polynomially_longer, attempts: 5
|
|
discard_on CustomExceptions::Webhook::RetriableError do |job, error|
|
|
payload = job.arguments[1]
|
|
webhook_type = job.arguments[2] || :account_webhook
|
|
|
|
Rails.logger.warn "Webhook retries exhausted for #{payload[:event]}: #{error.message}"
|
|
Webhooks::ErrorHandler.perform(payload, webhook_type, error)
|
|
end
|
|
|
|
# There are 3 types of webhooks, account, inbox and agent_bot
|
|
def perform(url, payload, webhook_type = :account_webhook)
|
|
Webhooks::Trigger.execute(url, payload, webhook_type)
|
|
end
|
|
end
|