0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/app/services/problem_check/email_sending_failures.rb
Roman Rizzi 751a1ce43c
FEATURE: Add PM whisper feedback for email sending failures (#40250)
Follow-up to bc4d4ec027.

Add immediate staff-facing PM whisper feedback when outbound SMTP
sending fails with client errors, reusing the captured SMTP response
details. This aligns send failure diagnostics with existing bounce
visibility in message threads.

Rename the problem check from `EmailDeliveryFailures` to
`EmailSendingFailures` and update related locale keys/messages to use
"sending failure" terminology for consistency.
2026-05-22 17:17:15 -03:00

35 lines
857 B
Ruby
Vendored

# frozen_string_literal: true
class ProblemCheck::EmailSendingFailures < ProblemCheck
self.priority = "low"
self.perform_every = 1.hour
LOOKBACK_WINDOW = 24.hours
def call
# De-duplicate with ProblemCheck::FailingEmails so we only show one
# admin alert for the same SMTP incident when retry jobs are already failing.
return no_problem if failing_email_job_count > 0
return no_problem if failed_send_count == 0
problem
end
private
def failed_send_count
@failed_delivery_count ||=
SkippedEmailLog
.where(reason_type: SkippedEmailLog.reason_types[:custom])
.where("created_at >= ?", LOOKBACK_WINDOW.ago)
.count
end
def failing_email_job_count
@failing_email_job_count ||= Jobs.num_email_retry_jobs.to_i
end
def translation_data
{ count: failed_send_count }
end
end