forked from Silverfish/proton-bridge
fix: better error handling when message is still in send queue
This commit is contained in:
@ -216,14 +216,16 @@ func (su *smtpUser) Send(from string, to []string, messageReader io.Reader) (err
|
|||||||
// nil to indicate it's OK.
|
// nil to indicate it's OK.
|
||||||
sendRecorderMessageHash := su.backend.sendRecorder.getMessageHash(message)
|
sendRecorderMessageHash := su.backend.sendRecorder.getMessageHash(message)
|
||||||
isSending, wasSent := su.backend.sendRecorder.isSendingOrSent(su.client(), sendRecorderMessageHash)
|
isSending, wasSent := su.backend.sendRecorder.isSendingOrSent(su.client(), sendRecorderMessageHash)
|
||||||
if isSending {
|
|
||||||
log.Debug("Message is in send queue, waiting")
|
startTime := time.Now()
|
||||||
time.Sleep(60 * time.Second)
|
for isSending && time.Since(startTime) < 90*time.Second {
|
||||||
|
log.Debug("Message is still in send queue, waiting for a bit")
|
||||||
|
time.Sleep(15 * time.Second)
|
||||||
isSending, wasSent = su.backend.sendRecorder.isSendingOrSent(su.client(), sendRecorderMessageHash)
|
isSending, wasSent = su.backend.sendRecorder.isSendingOrSent(su.client(), sendRecorderMessageHash)
|
||||||
}
|
}
|
||||||
if isSending {
|
if isSending {
|
||||||
log.Debug("Message is still in send queue, returning error")
|
log.Debug("Message is still in send queue, returning error to prevent client from adding it to the sent folder prematurely")
|
||||||
return errors.New("message is sending")
|
return errors.New("original message is still being sent")
|
||||||
}
|
}
|
||||||
if wasSent {
|
if wasSent {
|
||||||
log.Debug("Message was already sent")
|
log.Debug("Message was already sent")
|
||||||
|
|||||||
Reference in New Issue
Block a user