From 22ec1deaca43827f8e01c88321b1e0284b76f739 Mon Sep 17 00:00:00 2001 From: Devon Hudson Date: Tue, 29 Nov 2022 18:22:00 -0700 Subject: [PATCH] Handle async queue sending error to not fail if any mailserver succeeds --- federationapi/queue/destinationqueue.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/federationapi/queue/destinationqueue.go b/federationapi/queue/destinationqueue.go index c1bdb2ac8..cdb2d552a 100644 --- a/federationapi/queue/destinationqueue.go +++ b/federationapi/queue/destinationqueue.go @@ -392,8 +392,17 @@ func (oq *destinationQueue) nextTransaction( if oq.statistics.AssumedOffline() && len(mailservers) > 0 { // TODO : how to pass through actual userID here?!?!?!?! userID, _ := gomatrixserverlib.NewUserID("@:"+string(oq.origin), false) + anySuccess := false for _, mailserver := range mailservers { - _, _ = oq.client.SendAsyncTransaction(ctx, *userID, t, mailserver) + _, asyncErr := oq.client.SendAsyncTransaction(ctx, *userID, t, mailserver) + if asyncErr != nil { + err = asyncErr + } else { + anySuccess = true + } + } + if anySuccess { + err = nil } } else { _, err = oq.client.SendTransaction(ctx, t)