1
0

fix(BRIDGE-387): use gluon ID for getting the message count instead of the address ID

This commit is contained in:
Atanas Janeshliev
2025-06-12 11:47:33 +02:00
parent 7b533d5951
commit 4ee149ecd7
4 changed files with 25 additions and 6 deletions

View File

@ -73,6 +73,7 @@ type Connector struct {
syncState *SyncState
mailboxCountProvider mailboxCountProvider
gluonIDProvider gluonIDProvider
}
var errNoSenderAddressMatch = errors.New("no matching sender found in address list")
@ -89,6 +90,7 @@ func NewConnector(
showAllMail bool,
syncState *SyncState,
mailboxCountProvider mailboxCountProvider,
gluonIDProvider gluonIDProvider,
) *Connector {
userID := identityState.UserID()
@ -124,6 +126,7 @@ func NewConnector(
syncState: syncState,
mailboxCountProvider: mailboxCountProvider,
gluonIDProvider: gluonIDProvider,
}
}
@ -920,7 +923,16 @@ func (s *Connector) SetAddrIDTest(addrID string) {
}
func (s *Connector) GetMailboxMessageCount(ctx context.Context, mailboxInternalID imap.InternalMailboxID) (int, error) {
return s.mailboxCountProvider.GetUserMailboxCountByInternalID(ctx, s.addrID, mailboxInternalID)
gluonID, ok := s.gluonIDProvider.GetGluonID(s.addrID)
if !ok {
return 0, errors.New("could not retrieve Gluon ID for connector address ID")
}
return s.mailboxCountProvider.GetUserMailboxCountByInternalID(ctx, gluonID, mailboxInternalID)
}
// SetGluonIDProviderTest - sets the relevant gluon ID provider. Should only be used for testing.
func (s *Connector) SetGluonIDProviderTest(provider gluonIDProvider) {
s.gluonIDProvider = provider
}
// SetMailboxCountProviderTest - sets the relevant provider. Should only be used for testing.