fix(ingest): acknowledge a duplicate post with 250
- map router.ErrDuplicate to 250, like a discarded post: the post was already queued, so the MTA must stop retrying - test that a post delivered twice over LMTP is queued once
This commit is contained in:
parent
bd4258ebac
commit
6a68f316ba
2 changed files with 13 additions and 1 deletions
|
|
@ -86,7 +86,7 @@ func (s *session) deliver(rcpt string, data []byte) error {
|
|||
// status turns a router result into an LMTP reply.
|
||||
func (s *session) status(rcpt string, err error) error {
|
||||
switch {
|
||||
case err == nil, errors.Is(err, router.ErrHeld), errors.Is(err, router.ErrDiscarded):
|
||||
case err == nil, errors.Is(err, router.ErrHeld), errors.Is(err, router.ErrDiscarded), errors.Is(err, router.ErrDuplicate):
|
||||
return nil
|
||||
case errors.Is(err, router.ErrUnknownList):
|
||||
return &smtp.SMTPError{Code: 550, EnhancedCode: smtp.EnhancedCode{5, 1, 1}, Message: "no such list"}
|
||||
|
|
|
|||
|
|
@ -316,3 +316,15 @@ func TestAMessageTooBigToHoldAnswers552(t *testing.T) {
|
|||
t.Fatalf("a permanent refusal: the sender is told to send it elsewhere: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheSamePostDeliveredAgainIsAcceptedButNotQueuedTwice(t *testing.T) {
|
||||
st := newStack(t, down{}) // the deliveries stay in the queue, where they can be counted
|
||||
for i := 0; i < 2; i++ {
|
||||
if res := deliver(t, st.addr, "alice@example.com", []string{"dev@example.org"}); res["dev@example.org"] != nil {
|
||||
t.Fatalf("delivery %d: a duplicate is acknowledged with 250, got %v", i+1, res)
|
||||
}
|
||||
}
|
||||
if n := st.queued(t); n != 2 {
|
||||
t.Fatalf("queued = %d, want one delivery per member", n)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue