cultiv
(Sebastiaan Janssen)
23 Febrero, 2025 08:48
9
¿Alguna vez resolviste este problema? Tengo el mismo error, en la misma línea de código:
end
def sendgrid
if SiteSetting.sendgrid_verification_key.present?
return signature_failure if !valid_sendgrid_signature?
else
Rails.logger.warn(
"Received a Sendgrid webhook, but no verification key has been configured. This is unsafe behaviour and will be disallowed in the future.",
)
end
events = params["_json"] || [params]
events.each do |event|
message_id = Email::MessageIdService.message_id_clean((event["smtp-id"] || ""))
to_address = event["email"]
error_code = event["status"]
if event["event"] == "bounce"
# Sendgrid does not provide status field for emails that can't be delivered due to the recipient's server not existing
# so we set the error code to 5.1.2 which translates to permanent failure bad destination system address.
error_code = "5.1.2" if !error_code && event["type"] == "blocked"
No estoy familiarizado con Ruby, pero parece que puede analizar el JSON sin problemas hasta que intenta analizar el código de error, Email::SMTP_STATUS_TRANSIENT_FAILURE apunta a:
Comprobé en Webhook.site lo que Sendgrid realmente envía cuando pruebo el webhook y se ve así para un rebote:
[
{
"email": "example@test.com",
"timestamp": 1740136261,
"smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>",
"event": "bounce",
"category": [
"cat facts"
],
"sg_event_id": "ovGQ2rRo8ytNezHPDq-7Ig==",
"sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
"reason": "500 unknown recipient",
"status": "5.0.0"
}
]
¡Parece que debería funcionar!