Try sending to async mailservers if the conditions are right

This commit is contained in:
Devon Hudson 2022-11-29 18:12:18 -07:00
parent 116bdfc511
commit 266bf20a85
No known key found for this signature in database
GPG key ID: CD06B18E77F6A628

View file

@ -387,7 +387,17 @@ func (oq *destinationQueue) nextTransaction(
ctx, cancel := context.WithTimeout(oq.process.Context(), time.Minute*5) ctx, cancel := context.WithTimeout(oq.process.Context(), time.Minute*5)
defer cancel() defer cancel()
_, err := oq.client.SendTransaction(ctx, t) var err error
mailservers := oq.statistics.KnownMailservers()
if oq.statistics.AssumedOffline() && len(mailservers) > 0 {
// TODO : how to pass through actual userID here?!?!?!?!
userID, _ := gomatrixserverlib.NewUserID("@:"+string(oq.origin), false)
for _, mailserver := range mailservers {
_, _ = oq.client.SendAsyncTransaction(ctx, *userID, t, mailserver)
}
} else {
_, err = oq.client.SendTransaction(ctx, t)
}
switch errResponse := err.(type) { switch errResponse := err.(type) {
case nil: case nil:
// Clean up the transaction in the database. // Clean up the transaction in the database.