cultiv
(Sebastiaan Janssen)
23 Febbraio 2025, 8:48am
9
Hai mai risolto questo problema? Ho lo stesso errore, sulla stessa riga di codice:
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"
Non ho familiarità con Ruby, ma sembra che possa analizzare il JSON senza problemi fino al tentativo di analizzare il codice di errore, Email::SMTP_STATUS_TRANSIENT_FAILURE punta a:
Ho controllato su Webhook.site cosa invia effettivamente Sendgrid quando testo il webhook e per un rimbalzo sembra così:
[
{
"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"
}
]
Sembra che dovrebbe funzionare!