1/*2Maddy Mail Server - Composable all-in-one email server.3Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors45This program is free software: you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation, either version 3 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program. If not, see <https://www.gnu.org/licenses/>.17*/1819package module2021import (22 "context"2324 "github.com/emersion/go-message/textproto"25 "github.com/foxcpp/maddy/framework/buffer"26)2728// StatusCollector is an object that is passed by message source29// that is interested in intermediate status reports about partial30// delivery failures.31type StatusCollector interface {32 // SetStatus sets the error associated with the recipient.33 //34 // rcptTo should match exactly the value that was passed to the35 // AddRcpt, i.e. if any translations was made by the target,36 // they should not affect the rcptTo argument here.37 //38 // It should not be called multiple times for the same39 // value of rcptTo. It also should not be called40 // after BodyNonAtomic returns.41 //42 // SetStatus is goroutine-safe. Implementations43 // provide necessary serialization.44 SetStatus(rcptTo string, err error)45}4647// PartialDelivery is an optional interface that may be implemented48// by the object returned by DeliveryTarget.Start. See PartialDelivery.BodyNonAtomic49// documentation for details.50type PartialDelivery interface {51 // BodyNonAtomic is similar to Body method of the regular Delivery interface52 // with the except that it allows target to reject the body only for some53 // recipients by setting statuses using passed collector object.54 //55 // This interface is preferred by the LMTP endpoint and queue implementation56 // to ensure correct handling of partial failures.57 BodyNonAtomic(ctx context.Context, c StatusCollector, header textproto.Header, body buffer.Buffer)58}