mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-22 01:56:44 +00:00
Allow to send calendar update multiple times
This commit is contained in:
@ -20,6 +20,7 @@ package smtp
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -48,6 +49,15 @@ func newSendRecorder() *sendRecorder {
|
||||
}
|
||||
|
||||
func (q *sendRecorder) getMessageHash(message *pmapi.Message) string {
|
||||
// Outlook Calendar updates has only headers (no body) and thus have always
|
||||
// the same hash. If the message is type of calendar, the "is sending"
|
||||
// check to avoid potential duplicates is skipped. Duplicates should not
|
||||
// be a problem in this case as calendar updates are small.
|
||||
contentType := message.Header.Get("Content-Type")
|
||||
if strings.HasPrefix(contentType, "text/calendar") {
|
||||
return ""
|
||||
}
|
||||
|
||||
h := sha256.New()
|
||||
_, _ = h.Write([]byte(message.AddressID + message.Subject))
|
||||
if message.Sender != nil {
|
||||
@ -101,6 +111,10 @@ func (q *sendRecorder) isSendingOrSent(client messageGetter, hash string) (isSen
|
||||
q.lock.Lock()
|
||||
defer q.lock.Unlock()
|
||||
|
||||
if hash == "" {
|
||||
return false, false
|
||||
}
|
||||
|
||||
q.deleteExpiredKeys()
|
||||
value, ok := q.hashes[hash]
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user