feat(GODT-2891): Allow message create & delete during sync

Incoming messages which arrive into labels we know during sync are now
presented to the IMAP clients.

We also allow messages to be deleted while syncing if deleted on other
clients.

Other operations such as moving, marking messages as read and label
operations need to be considered in a follow up patch as they are far
more complex.
This commit is contained in:
Leander Beernaert
2023-08-31 10:47:47 +02:00
parent a5a9bd762d
commit 7a192d50db
4 changed files with 172 additions and 7 deletions

View File

@ -324,6 +324,8 @@ func (s *Service) run(ctx context.Context) { //nolint gocyclo
MessageHandler: s,
}
syncEventHandler := s.newSyncEventHandler()
s.eventProvider.Subscribe(s.subscription)
defer s.eventProvider.Unsubscribe(s.subscription)
@ -441,12 +443,13 @@ func (s *Service) run(ctx context.Context) { //nolint gocyclo
}
e.Consume(func(event proton.Event) error {
if s.isSyncing {
if err := syncEventHandler.OnEvent(ctx, event); err != nil {
return err
}
// We need to reset the sync if we receive a refresh event during a sync and update
// the last event id to avoid problems.
if event.Refresh&proton.RefreshMail != 0 {
if err := s.HandleRefreshEvent(ctx, 0); err != nil {
return err
}
s.lastHandledEventID = event.EventID
}