for messages retired from the delivery queue, set "success" field properly, and include the smtp code/enhanced code on success too (not only on failure)

noticed some time ago when looking at my retired messages queue.
This commit is contained in:
Mechiel Lukkien
2024-10-05 11:06:42 +02:00
parent fb65ec0676
commit fdc0560ac4
4 changed files with 11 additions and 5 deletions

View File

@ -1027,6 +1027,10 @@ func TestRetiredHooks(t *testing.T) {
if expResult.Secode != "" {
ecode = fmt.Sprintf("%d.%s", expResult.Code/100, expResult.Secode)
}
var code int // Only set for errors.
if expResult.Code != 250 {
code = expResult.Code
}
expOut := webhook.Outgoing{
Event: webhook.OutgoingEvent(expEvent),
Suppressing: expSuppressing,
@ -1034,7 +1038,7 @@ func TestRetiredHooks(t *testing.T) {
FromID: mr.FromID,
MessageID: mr.MessageID,
Subject: mr.Subject,
SMTPCode: expResult.Code,
SMTPCode: code,
SMTPEnhancedCode: ecode,
Extra: mr.Extra,
}
@ -1130,7 +1134,7 @@ func TestRetiredHooks(t *testing.T) {
}
testAction("mjl", makeLaunchAction(smtpAccept), nil, "", false)
testAction("retired", makeLaunchAction(smtpAccept), &MsgResult{}, string(webhook.EventDelivered), false)
testAction("retired", makeLaunchAction(smtpAccept), &MsgResult{Code: 250, Success: true}, string(webhook.EventDelivered), false)
// 554 is generic, doesn't immediately cause suppression.
testAction("mjl", makeLaunchAction(smtpReject(554)), nil, "", false)
testAction("retired", makeLaunchAction(smtpReject(554)), &MsgResult{Code: 554, Secode: "1.0", Error: "nonempty"}, string(webhook.EventFailed), false)