mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
GODT-2187: Skip messages during sync that fail to build/parse
This commit is contained in:
@ -60,9 +60,10 @@ func (mode AddressMode) String() string {
|
||||
}
|
||||
|
||||
type SyncStatus struct {
|
||||
HasLabels bool
|
||||
HasMessages bool
|
||||
LastMessageID string
|
||||
HasLabels bool
|
||||
HasMessages bool
|
||||
LastMessageID string
|
||||
FailedMessageIDs []string
|
||||
}
|
||||
|
||||
func (status SyncStatus) IsComplete() bool {
|
||||
|
||||
@ -21,6 +21,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ProtonMail/gluon/imap"
|
||||
"github.com/bradenaw/juniper/xslices"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
@ -158,6 +160,24 @@ func (user *User) SetLastMessageID(messageID string) error {
|
||||
})
|
||||
}
|
||||
|
||||
// AddFailedMessageID adds a message ID to the list of failed message IDs.
|
||||
func (user *User) AddFailedMessageID(messageID string) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
if !slices.Contains(data.SyncStatus.FailedMessageIDs, messageID) {
|
||||
data.SyncStatus.FailedMessageIDs = append(data.SyncStatus.FailedMessageIDs, messageID)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// RemFailedMessageID removes a message ID from the list of failed message IDs.
|
||||
func (user *User) RemFailedMessageID(messageID string) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.SyncStatus.FailedMessageIDs = xslices.Filter(data.SyncStatus.FailedMessageIDs, func(otherID string) bool {
|
||||
return otherID != messageID
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ClearSyncStatus clears the user's sync status.
|
||||
func (user *User) ClearSyncStatus() error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
|
||||
Reference in New Issue
Block a user