diff --git a/benchmarks/gluon_bench/gluon_benchmarks/sync.go b/benchmarks/gluon_bench/gluon_benchmarks/sync.go index 701ee4ce..16f23035 100644 --- a/benchmarks/gluon_bench/gluon_benchmarks/sync.go +++ b/benchmarks/gluon_bench/gluon_benchmarks/sync.go @@ -27,7 +27,7 @@ var ( type Sync struct { connector utils.ConnectorImpl server *gluon.Server - mailboxes []imap.LabelID + mailboxes []imap.MailboxID } func NewSync() benchmark.Benchmark { @@ -70,10 +70,10 @@ func (s *Sync) setupConnector(ctx context.Context) (utils.ConnectorImpl, error) return nil, err } - mboxIDs := make([]imap.LabelID, 0, *syncMBoxCountFlag) + mboxIDs := make([]imap.MailboxID, 0, *syncMBoxCountFlag) for i := uint(0); i < *syncMBoxCountFlag; i++ { - mbox, err := c.Connector().CreateLabel(ctx, []string{uuid.NewString()}) + mbox, err := c.Connector().CreateMailbox(ctx, []string{uuid.NewString()}) if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (s *Sync) setupConnector(ctx context.Context) (utils.ConnectorImpl, error) flagSet := imap.NewFlagSet("\\Recent", "\\Draft", "\\Foo") - s.mailboxes = make([]imap.LabelID, 0, len(mboxIDs)) + s.mailboxes = make([]imap.MailboxID, 0, len(mboxIDs)) for _, mboxID := range mboxIDs { for i := uint(0); i < *syncMessageCountFlag; i++ { @@ -132,7 +132,7 @@ func (s *Sync) Run(ctx context.Context) (*reporter.BenchmarkRun, error) { func (s *Sync) TearDown(ctx context.Context) error { for _, id := range s.mailboxes { - if err := s.connector.Connector().DeleteLabel(ctx, id); err != nil { + if err := s.connector.Connector().DeleteMailbox(ctx, id); err != nil { return err } } diff --git a/connector/connector.go b/connector/connector.go index d44711c9..ef9aa095 100644 --- a/connector/connector.go +++ b/connector/connector.go @@ -12,35 +12,35 @@ type Connector interface { // Authorize returns whether the given username/password combination are valid for this connector. Authorize(username string, password []byte) bool - // GetLabel returns information about the label with the given ID. - GetLabel(ctx context.Context, labelID imap.LabelID) (imap.Mailbox, error) + // GetMailbox returns information about the mailbox with the given ID. + GetMailbox(ctx context.Context, mboxID imap.MailboxID) (imap.Mailbox, error) - // CreateLabel creates a label with the given name. - CreateLabel(ctx context.Context, name []string) (imap.Mailbox, error) + // CreateMailbox creates a mailbox with the given name. + CreateMailbox(ctx context.Context, name []string) (imap.Mailbox, error) - // IsLabelVisible can be used to hide mailboxes from connected clients. - IsLabelVisible(ctx context.Context, labelID imap.LabelID) bool + // IsMailboxVisible can be used to hide mailboxes from connected clients. + IsMailboxVisible(ctx context.Context, mboxID imap.MailboxID) bool - // UpdateLabel sets the name of the label with the given ID. - UpdateLabel(ctx context.Context, labelID imap.LabelID, newName []string) error + // UpdateMailboxName sets the name of the mailbox with the given ID. + UpdateMailboxName(ctx context.Context, mboxID imap.MailboxID, newName []string) error - // DeleteLabel deletes the label with the given ID. - DeleteLabel(ctx context.Context, labelID imap.LabelID) error + // DeleteMailbox deletes the mailbox with the given ID. + DeleteMailbox(ctx context.Context, mboxID imap.MailboxID) error // GetMessage returns the message with the given ID. - GetMessage(ctx context.Context, messageID imap.MessageID) (imap.Message, []imap.LabelID, error) + GetMessage(ctx context.Context, messageID imap.MessageID) (imap.Message, []imap.MailboxID, error) // CreateMessage creates a new message on the remote. - CreateMessage(ctx context.Context, labelID imap.LabelID, literal []byte, flags imap.FlagSet, date time.Time) (imap.Message, []byte, error) + CreateMessage(ctx context.Context, mboxID imap.MailboxID, literal []byte, flags imap.FlagSet, date time.Time) (imap.Message, []byte, error) - // LabelMessages labels the given messages with the given label ID. - LabelMessages(ctx context.Context, messageIDs []imap.MessageID, labelID imap.LabelID) error + // AddMessagesToMailbox adds the given messages to the given mailbox. + AddMessagesToMailbox(ctx context.Context, messageIDs []imap.MessageID, mboxID imap.MailboxID) error - // UnlabelMessages unlabels the given messages with the given label ID. - UnlabelMessages(ctx context.Context, messageIDs []imap.MessageID, labelID imap.LabelID) error + // RemoveMessagesFromMailbox removes the given messages from the given mailbox. + RemoveMessagesFromMailbox(ctx context.Context, messageIDs []imap.MessageID, mboxID imap.MailboxID) error - // MoveMessages removes the given messages from one label and adds them to the other label. - MoveMessages(ctx context.Context, messageIDs []imap.MessageID, labelFromID, labelToID imap.LabelID) error + // MoveMessages removes the given messages from one mailbox and adds them to the another mailbox. + MoveMessages(ctx context.Context, messageIDs []imap.MessageID, mboxFromID, mboxToID imap.MailboxID) error // MarkMessagesSeen sets the seen value of the given messages. MarkMessagesSeen(ctx context.Context, messageIDs []imap.MessageID, seen bool) error diff --git a/connector/dummy.go b/connector/dummy.go index a03f5e30..7297da35 100644 --- a/connector/dummy.go +++ b/connector/dummy.go @@ -15,7 +15,7 @@ import ( ) var ( - ErrNoSuchLabel = errors.New("no such label") + ErrNoSuchMailbox = errors.New("no such mailbox") ErrNoSuchMessage = errors.New("no such message") ErrInvalidPrefix = errors.New("invalid prefix") @@ -50,21 +50,21 @@ type Dummy struct { queue []imap.Update queueLock sync.Mutex - hiddenLabels map[imap.LabelID]struct{} + hiddenMailboxes map[imap.MailboxID]struct{} } func NewDummy(usernames []string, password []byte, period time.Duration, flags, permFlags, attrs imap.FlagSet) *Dummy { conn := &Dummy{ - state: newDummyState(flags, permFlags, attrs), - usernames: usernames, - password: password, - flags: flags, - permFlags: permFlags, - attrs: attrs, - updateCh: make(chan imap.Update, constants.ChannelBufferCount), - updateQuitCh: make(chan struct{}), - ticker: ticker.New(period), - hiddenLabels: make(map[imap.LabelID]struct{}), + state: newDummyState(flags, permFlags, attrs), + usernames: usernames, + password: password, + flags: flags, + permFlags: permFlags, + attrs: attrs, + updateCh: make(chan imap.Update, constants.ChannelBufferCount), + updateQuitCh: make(chan struct{}), + ticker: ticker.New(period), + hiddenMailboxes: make(map[imap.MailboxID]struct{}), } go func() { @@ -82,7 +82,7 @@ func NewDummy(usernames []string, password []byte, period time.Duration, flags, }) }() - conn.state.createLabelWithID([]string{imap.Inbox}, "0", false) + conn.state.createMailboxWithID([]string{imap.Inbox}, "0", false) return conn } @@ -99,58 +99,58 @@ func (conn *Dummy) GetUpdates() <-chan imap.Update { return conn.updateCh } -func (conn *Dummy) GetLabel(ctx context.Context, labelID imap.LabelID) (imap.Mailbox, error) { - return conn.state.getLabel(labelID) +func (conn *Dummy) GetMailbox(ctx context.Context, mboxID imap.MailboxID) (imap.Mailbox, error) { + return conn.state.getMailbox(mboxID) } -func (conn *Dummy) CreateLabel(ctx context.Context, name []string) (imap.Mailbox, error) { +func (conn *Dummy) CreateMailbox(ctx context.Context, name []string) (imap.Mailbox, error) { exclusive, err := conn.validateName(name) if err != nil { return imap.Mailbox{}, err } - mbox := conn.state.createLabel(name, exclusive) + mbox := conn.state.createMailbox(name, exclusive) conn.pushUpdate(imap.NewMailboxCreated(mbox)) return mbox, nil } -func (conn *Dummy) UpdateLabel(ctx context.Context, labelID imap.LabelID, newName []string) error { - label, err := conn.state.getLabel(labelID) +func (conn *Dummy) UpdateMailboxName(ctx context.Context, mboxID imap.MailboxID, newName []string) error { + mbox, err := conn.state.getMailbox(mboxID) if err != nil { return err } - if err := conn.validateUpdate(label.Name, newName); err != nil { + if err := conn.validateUpdate(mbox.Name, newName); err != nil { return err } - conn.state.updateLabel(labelID, newName) + conn.state.updateMailboxName(mboxID, newName) - conn.pushUpdate(imap.NewMailboxUpdated(labelID, newName)) + conn.pushUpdate(imap.NewMailboxUpdated(mboxID, newName)) return nil } -func (conn *Dummy) DeleteLabel(ctx context.Context, labelID imap.LabelID) error { - conn.state.deleteLabel(labelID) +func (conn *Dummy) DeleteMailbox(ctx context.Context, mboxID imap.MailboxID) error { + conn.state.deleteMailbox(mboxID) - conn.pushUpdate(imap.NewMailboxDeleted(labelID)) + conn.pushUpdate(imap.NewMailboxDeleted(mboxID)) return nil } -func (conn *Dummy) GetMessage(ctx context.Context, messageID imap.MessageID) (imap.Message, []imap.LabelID, error) { +func (conn *Dummy) GetMessage(ctx context.Context, messageID imap.MessageID) (imap.Message, []imap.MailboxID, error) { message, err := conn.state.getMessage(messageID) if err != nil { return imap.Message{}, nil, err } - return message, conn.state.getLabelIDs(messageID), nil + return message, conn.state.getMailboxIDs(messageID), nil } -func (conn *Dummy) CreateMessage(ctx context.Context, mboxID imap.LabelID, literal []byte, flags imap.FlagSet, date time.Time) (imap.Message, []byte, error) { +func (conn *Dummy) CreateMessage(ctx context.Context, mboxID imap.MailboxID, literal []byte, flags imap.FlagSet, date time.Time) (imap.Message, []byte, error) { // NOTE: We are only recording this here since it was the easiest command to verify the data has been record properly // in the context, as APPEND will always require a communication with the remote connector. conn.state.recordIMAPID(ctx) @@ -173,7 +173,7 @@ func (conn *Dummy) CreateMessage(ctx context.Context, mboxID imap.LabelID, liter update := imap.NewMessagesCreated(&imap.MessageCreated{ Message: message, Literal: literal, - LabelIDs: []imap.LabelID{mboxID}, + MailboxIDs: []imap.MailboxID{mboxID}, ParsedMessage: parsed, }) @@ -182,13 +182,13 @@ func (conn *Dummy) CreateMessage(ctx context.Context, mboxID imap.LabelID, liter return message, literal, nil } -func (conn *Dummy) LabelMessages(ctx context.Context, messageIDs []imap.MessageID, mboxID imap.LabelID) error { +func (conn *Dummy) AddMessagesToMailbox(ctx context.Context, messageIDs []imap.MessageID, mboxID imap.MailboxID) error { for _, messageID := range messageIDs { - conn.state.labelMessage(messageID, mboxID) + conn.state.addMessageToMailbox(messageID, mboxID) - conn.pushUpdate(imap.NewMessageLabelsUpdated( + conn.pushUpdate(imap.NewMessageMailboxesUpdated( messageID, - conn.state.getLabelIDs(messageID), + conn.state.getMailboxIDs(messageID), conn.state.isSeen(messageID), conn.state.isFlagged(messageID), )) @@ -197,13 +197,13 @@ func (conn *Dummy) LabelMessages(ctx context.Context, messageIDs []imap.MessageI return nil } -func (conn *Dummy) UnlabelMessages(ctx context.Context, messageIDs []imap.MessageID, mboxID imap.LabelID) error { +func (conn *Dummy) RemoveMessagesFromMailbox(ctx context.Context, messageIDs []imap.MessageID, mboxID imap.MailboxID) error { for _, messageID := range messageIDs { - conn.state.unlabelMessage(messageID, mboxID) + conn.state.removeMessageFromMailbox(messageID, mboxID) - conn.pushUpdate(imap.NewMessageLabelsUpdated( + conn.pushUpdate(imap.NewMessageMailboxesUpdated( messageID, - conn.state.getLabelIDs(messageID), + conn.state.getMailboxIDs(messageID), conn.state.isSeen(messageID), conn.state.isFlagged(messageID), )) @@ -212,14 +212,14 @@ func (conn *Dummy) UnlabelMessages(ctx context.Context, messageIDs []imap.Messag return nil } -func (conn *Dummy) MoveMessages(ctx context.Context, messageIDs []imap.MessageID, labelFromID, labelToID imap.LabelID) error { +func (conn *Dummy) MoveMessages(ctx context.Context, messageIDs []imap.MessageID, mboxFromID, mboxToID imap.MailboxID) error { for _, messageID := range messageIDs { - conn.state.unlabelMessage(messageID, labelFromID) - conn.state.labelMessage(messageID, labelToID) + conn.state.removeMessageFromMailbox(messageID, mboxFromID) + conn.state.addMessageToMailbox(messageID, mboxToID) - conn.pushUpdate(imap.NewMessageLabelsUpdated( + conn.pushUpdate(imap.NewMessageMailboxesUpdated( messageID, - conn.state.getLabelIDs(messageID), + conn.state.getMailboxIDs(messageID), conn.state.isSeen(messageID), conn.state.isFlagged(messageID), )) @@ -265,7 +265,7 @@ func (conn *Dummy) SetUIDValidity(imap.UID) error { } func (conn *Dummy) Sync(ctx context.Context) error { - for _, mailbox := range conn.state.getLabels() { + for _, mailbox := range conn.state.getMailboxes() { update := imap.NewMailboxCreated(mailbox) defer update.WaitContext(ctx) @@ -308,17 +308,17 @@ func (conn *Dummy) ClearUpdates() { conn.popUpdates() } -func (conn *Dummy) IsLabelVisible(_ context.Context, id imap.LabelID) bool { - _, ok := conn.hiddenLabels[id] +func (conn *Dummy) IsMailboxVisible(_ context.Context, id imap.MailboxID) bool { + _, ok := conn.hiddenMailboxes[id] return !ok } -func (conn *Dummy) SetMailboxVisible(id imap.LabelID, visible bool) { +func (conn *Dummy) SetMailboxVisible(id imap.MailboxID, visible bool) { if !visible { - conn.hiddenLabels[id] = struct{}{} + conn.hiddenMailboxes[id] = struct{}{} } else { - delete(conn.hiddenLabels, id) + delete(conn.hiddenMailboxes, id) } } @@ -329,8 +329,8 @@ func (conn *Dummy) pushUpdate(update imap.Update) { // We mimic the behaviour of the Proton sever. if several update to a message or mailbox happen in between // two event polls, we only get one refresh update with the latest state. switch update := update.(type) { - case *imap.MessageLabelsUpdated: - conn.queue = removeMessageLabelsUpdatedFromSlice(conn.queue, update.MessageID) + case *imap.MessageMailboxesUpdated: + conn.queue = removeMessageMailboxesUpdatedFromSlice(conn.queue, update.MessageID) case *imap.MessageFlagsUpdated: conn.queue = removeMessageFlagsUpdatedFromSlice(conn.queue, update.MessageID) @@ -370,9 +370,9 @@ func (conn *Dummy) validateUpdate(oldName, newName []string) error { return nil } -func removeMessageLabelsUpdatedFromSlice(updates []imap.Update, messageID imap.MessageID) []imap.Update { +func removeMessageMailboxesUpdatedFromSlice(updates []imap.Update, messageID imap.MessageID) []imap.Update { return xslices.Filter(updates, func(update imap.Update) bool { - u, ok := update.(*imap.MessageLabelsUpdated) + u, ok := update.(*imap.MessageMailboxesUpdated) return (!ok) || (u.MessageID != messageID) }) @@ -386,7 +386,7 @@ func removeMessageFlagsUpdatedFromSlice(updates []imap.Update, messageID imap.Me }) } -func removeMailboxUpdatedFromSlice(updates []imap.Update, mailboxID imap.LabelID) []imap.Update { +func removeMailboxUpdatedFromSlice(updates []imap.Update, mailboxID imap.MailboxID) []imap.Update { return xslices.Filter(updates, func(update imap.Update) bool { u, ok := update.(*imap.MailboxUpdated) diff --git a/connector/dummy_simulate.go b/connector/dummy_simulate.go index 989b5f7f..06fa1c97 100644 --- a/connector/dummy_simulate.go +++ b/connector/dummy_simulate.go @@ -9,19 +9,19 @@ func (conn *Dummy) SetFolderPrefix(pfx string) { conn.pfxFolder = pfx - mbox := conn.state.createLabel([]string{pfx}, true) + mbox := conn.state.createMailbox([]string{pfx}, true) mbox.Attributes = mbox.Attributes.Add(imap.AttrNoSelect) conn.pushUpdate(imap.NewMailboxCreated(mbox)) } -func (conn *Dummy) SetLabelPrefix(pfx string) { +func (conn *Dummy) SetMailboxPrefix(pfx string) { defer conn.Flush() conn.pfxLabel = pfx - mbox := conn.state.createLabel([]string{pfx}, false) + mbox := conn.state.createMailbox([]string{pfx}, false) mbox.Attributes = mbox.Attributes.Add(imap.AttrNoSelect) @@ -37,8 +37,8 @@ func (conn *Dummy) MailboxCreated(mbox imap.Mailbox) error { return err } - conn.state.labels[mbox.ID] = &dummyLabel{ - labelName: mbox.Name, + conn.state.mailboxes[mbox.ID] = &dummyMailbox{ + mboxName: mbox.Name, exclusive: exclusive, } @@ -47,15 +47,15 @@ func (conn *Dummy) MailboxCreated(mbox imap.Mailbox) error { return nil } -func (conn *Dummy) MailboxDeleted(labelID imap.LabelID) error { - conn.state.deleteLabel(labelID) +func (conn *Dummy) MailboxDeleted(mboxID imap.MailboxID) error { + conn.state.deleteMailbox(mboxID) - conn.pushUpdate(imap.NewMailboxDeleted(labelID)) + conn.pushUpdate(imap.NewMailboxDeleted(mboxID)) return nil } -func (conn *Dummy) MessageCreated(message imap.Message, literal []byte, mboxIDs []imap.LabelID) error { +func (conn *Dummy) MessageCreated(message imap.Message, literal []byte, mboxIDs []imap.MailboxID) error { parsedMessage, err := imap.NewParsedMessage(literal) if err != nil { return err @@ -64,25 +64,25 @@ func (conn *Dummy) MessageCreated(message imap.Message, literal []byte, mboxIDs conn.state.lock.Lock() defer conn.state.lock.Unlock() - labelIDs := make(map[imap.LabelID]struct{}) + mboxIDMap := make(map[imap.MailboxID]struct{}) for _, mboxID := range mboxIDs { - labelIDs[mboxID] = struct{}{} + mboxIDMap[mboxID] = struct{}{} } conn.state.messages[message.ID] = &dummyMessage{ - literal: literal, - seen: message.Flags.Contains(imap.FlagSeen), - flagged: message.Flags.Contains(imap.FlagFlagged), - parsed: parsedMessage, - date: message.Date, - labelIDs: labelIDs, + literal: literal, + seen: message.Flags.Contains(imap.FlagSeen), + flagged: message.Flags.Contains(imap.FlagFlagged), + parsed: parsedMessage, + date: message.Date, + mboxIDs: mboxIDMap, } update := imap.NewMessagesCreated(&imap.MessageCreated{ Message: message, Literal: literal, - LabelIDs: mboxIDs, + MailboxIDs: mboxIDs, ParsedMessage: parsedMessage, }) @@ -91,7 +91,7 @@ func (conn *Dummy) MessageCreated(message imap.Message, literal []byte, mboxIDs return nil } -func (conn *Dummy) MessagesCreated(messages []imap.Message, literals [][]byte, mboxIDs [][]imap.LabelID) error { +func (conn *Dummy) MessagesCreated(messages []imap.Message, literals [][]byte, mboxIDs [][]imap.MailboxID) error { conn.state.lock.Lock() defer conn.state.lock.Unlock() @@ -103,25 +103,25 @@ func (conn *Dummy) MessagesCreated(messages []imap.Message, literals [][]byte, m return err } - labelIDs := make(map[imap.LabelID]struct{}) + mboxIDMap := make(map[imap.MailboxID]struct{}) for _, mboxID := range mboxIDs[i] { - labelIDs[mboxID] = struct{}{} + mboxIDMap[mboxID] = struct{}{} } conn.state.messages[messages[i].ID] = &dummyMessage{ - literal: literals[i], - seen: messages[i].Flags.Contains(imap.FlagSeen), - flagged: messages[i].Flags.Contains(imap.FlagFlagged), - parsed: parsedMessage, - date: messages[i].Date, - labelIDs: labelIDs, + literal: literals[i], + seen: messages[i].Flags.Contains(imap.FlagSeen), + flagged: messages[i].Flags.Contains(imap.FlagFlagged), + parsed: parsedMessage, + date: messages[i].Date, + mboxIDs: mboxIDMap, } updates = append(updates, &imap.MessageCreated{ Message: messages[i], Literal: literals[i], - LabelIDs: mboxIDs[i], + MailboxIDs: mboxIDs[i], ParsedMessage: parsedMessage, }) } @@ -131,12 +131,12 @@ func (conn *Dummy) MessagesCreated(messages []imap.Message, literals [][]byte, m return nil } -func (conn *Dummy) MessageAdded(messageID imap.MessageID, labelID imap.LabelID) error { - conn.state.labelMessage(messageID, labelID) +func (conn *Dummy) MessageAdded(messageID imap.MessageID, mboxID imap.MailboxID) error { + conn.state.addMessageToMailbox(messageID, mboxID) - conn.pushUpdate(imap.NewMessageLabelsUpdated( + conn.pushUpdate(imap.NewMessageMailboxesUpdated( messageID, - conn.state.getLabelIDs(messageID), + conn.state.getMailboxIDs(messageID), conn.state.isSeen(messageID), conn.state.isFlagged(messageID), )) @@ -144,12 +144,12 @@ func (conn *Dummy) MessageAdded(messageID imap.MessageID, labelID imap.LabelID) return nil } -func (conn *Dummy) MessageRemoved(messageID imap.MessageID, labelID imap.LabelID) error { - conn.state.unlabelMessage(messageID, labelID) +func (conn *Dummy) MessageRemoved(messageID imap.MessageID, mboxID imap.MailboxID) error { + conn.state.removeMessageFromMailbox(messageID, mboxID) - conn.pushUpdate(imap.NewMessageLabelsUpdated( + conn.pushUpdate(imap.NewMessageMailboxesUpdated( messageID, - conn.state.getLabelIDs(messageID), + conn.state.getMailboxIDs(messageID), conn.state.isSeen(messageID), conn.state.isFlagged(messageID), )) diff --git a/connector/dummy_state.go b/connector/dummy_state.go index a2fa77c4..b5dea8a4 100644 --- a/connector/dummy_state.go +++ b/connector/dummy_state.go @@ -15,14 +15,14 @@ type dummyState struct { flags, permFlags, attrs imap.FlagSet messages map[imap.MessageID]*dummyMessage - labels map[imap.LabelID]*dummyLabel + mailboxes map[imap.MailboxID]*dummyMailbox lastIMAPID imap.IMAPID lock sync.RWMutex } -type dummyLabel struct { - labelName []string +type dummyMailbox struct { + mboxName []string exclusive bool } @@ -34,7 +34,7 @@ type dummyMessage struct { date time.Time flags imap.FlagSet - labelIDs map[imap.LabelID]struct{} + mboxIDs map[imap.MailboxID]struct{} } func newDummyState(flags, permFlags, attrs imap.FlagSet) *dummyState { @@ -43,7 +43,7 @@ func newDummyState(flags, permFlags, attrs imap.FlagSet) *dummyState { permFlags: permFlags, attrs: attrs, messages: make(map[imap.MessageID]*dummyMessage), - labels: make(map[imap.LabelID]*dummyLabel), + mailboxes: make(map[imap.MailboxID]*dummyMailbox), lastIMAPID: imap.NewIMAPID(), } } @@ -56,67 +56,67 @@ func (state *dummyState) recordIMAPID(ctx context.Context) { } } -func (state *dummyState) getLabels() []imap.Mailbox { +func (state *dummyState) getMailboxes() []imap.Mailbox { state.lock.Lock() defer state.lock.Unlock() - return xslices.Map(maps.Keys(state.labels), func(labelID imap.LabelID) imap.Mailbox { - return state.toMailbox(labelID) + return xslices.Map(maps.Keys(state.mailboxes), func(mboxID imap.MailboxID) imap.Mailbox { + return state.toMailbox(mboxID) }) } -func (state *dummyState) getLabel(labelID imap.LabelID) (imap.Mailbox, error) { +func (state *dummyState) getMailbox(mboxID imap.MailboxID) (imap.Mailbox, error) { state.lock.Lock() defer state.lock.Unlock() - if _, ok := state.labels[labelID]; !ok { - return imap.Mailbox{}, ErrNoSuchLabel + if _, ok := state.mailboxes[mboxID]; !ok { + return imap.Mailbox{}, ErrNoSuchMailbox } - return state.toMailbox(labelID), nil + return state.toMailbox(mboxID), nil } -func (state *dummyState) createLabel(name []string, exclusive bool) imap.Mailbox { +func (state *dummyState) createMailbox(name []string, exclusive bool) imap.Mailbox { state.lock.Lock() defer state.lock.Unlock() - labelID := imap.LabelID(uuid.NewString()) + mboxID := imap.MailboxID(uuid.NewString()) - state.labels[labelID] = &dummyLabel{ - labelName: name, + state.mailboxes[mboxID] = &dummyMailbox{ + mboxName: name, exclusive: exclusive, } - return state.toMailbox(labelID) + return state.toMailbox(mboxID) } -func (state *dummyState) createLabelWithID(name []string, id imap.LabelID, exclusive bool) imap.Mailbox { +func (state *dummyState) createMailboxWithID(name []string, id imap.MailboxID, exclusive bool) imap.Mailbox { state.lock.Lock() defer state.lock.Unlock() - state.labels[id] = &dummyLabel{ - labelName: name, + state.mailboxes[id] = &dummyMailbox{ + mboxName: name, exclusive: exclusive, } return state.toMailbox(id) } -func (state *dummyState) updateLabel(labelID imap.LabelID, name []string) { +func (state *dummyState) updateMailboxName(mboxID imap.MailboxID, name []string) { state.lock.Lock() defer state.lock.Unlock() - state.labels[labelID].labelName = name + state.mailboxes[mboxID].mboxName = name } -func (state *dummyState) deleteLabel(labelID imap.LabelID) { +func (state *dummyState) deleteMailbox(mboxID imap.MailboxID) { state.lock.Lock() defer state.lock.Unlock() - delete(state.labels, labelID) + delete(state.mailboxes, mboxID) for _, message := range state.messages { - delete(message.labelIDs, labelID) + delete(message.mboxIDs, mboxID) } } @@ -141,7 +141,7 @@ func (state *dummyState) getMessageCreatedUpdate(id imap.MessageID) (*imap.Messa return &imap.MessageCreated{ Message: state.toMessage(id), Literal: msg.literal, - LabelIDs: maps.Keys(msg.labelIDs), + MailboxIDs: maps.Keys(msg.mboxIDs), ParsedMessage: msg.parsed, }, nil } @@ -157,11 +157,11 @@ func (state *dummyState) getMessage(messageID imap.MessageID) (imap.Message, err return state.toMessage(messageID), nil } -func (state *dummyState) getLabelIDs(messageID imap.MessageID) []imap.LabelID { +func (state *dummyState) getMailboxIDs(messageID imap.MessageID) []imap.MailboxID { state.lock.Lock() defer state.lock.Unlock() - return maps.Keys(state.messages[messageID].labelIDs) + return maps.Keys(state.messages[messageID].mboxIDs) } func (state *dummyState) getLiteral(messageID imap.MessageID) []byte { @@ -172,7 +172,7 @@ func (state *dummyState) getLiteral(messageID imap.MessageID) []byte { } func (state *dummyState) createMessage( - mboxID imap.LabelID, + mboxID imap.MailboxID, literal []byte, parsed *imap.ParsedMessage, seen, flagged bool, @@ -193,34 +193,34 @@ func (state *dummyState) createMessage( } state.messages[messageID] = &dummyMessage{ - literal: literal, - seen: seen, - parsed: parsed, - flagged: flagged, - flags: otherFlags, - date: date, - labelIDs: map[imap.LabelID]struct{}{mboxID: {}}, + literal: literal, + seen: seen, + parsed: parsed, + flagged: flagged, + flags: otherFlags, + date: date, + mboxIDs: map[imap.MailboxID]struct{}{mboxID: {}}, } return state.toMessage(messageID) } -func (state *dummyState) labelMessage(messageID imap.MessageID, labelID imap.LabelID) { +func (state *dummyState) addMessageToMailbox(messageID imap.MessageID, mboxID imap.MailboxID) { state.lock.Lock() defer state.lock.Unlock() - if state.labels[labelID].exclusive { - state.messages[messageID].labelIDs = make(map[imap.LabelID]struct{}) + if state.mailboxes[mboxID].exclusive { + state.messages[messageID].mboxIDs = make(map[imap.MailboxID]struct{}) } - state.messages[messageID].labelIDs[labelID] = struct{}{} + state.messages[messageID].mboxIDs[mboxID] = struct{}{} } -func (state *dummyState) unlabelMessage(messageID imap.MessageID, labelID imap.LabelID) { +func (state *dummyState) removeMessageFromMailbox(messageID imap.MessageID, mboxID imap.MailboxID) { state.lock.Lock() defer state.lock.Unlock() - delete(state.messages[messageID].labelIDs, labelID) + delete(state.messages[messageID].mboxIDs, mboxID) } func (state *dummyState) setSeen(messageID imap.MessageID, seen bool) { @@ -251,10 +251,10 @@ func (state *dummyState) isFlagged(messageID imap.MessageID) bool { return state.messages[messageID].flagged } -func (state *dummyState) toMailbox(labelID imap.LabelID) imap.Mailbox { +func (state *dummyState) toMailbox(mboxID imap.MailboxID) imap.Mailbox { return imap.Mailbox{ - ID: labelID, - Name: state.labels[labelID].labelName, + ID: mboxID, + Name: state.mailboxes[mboxID].mboxName, Flags: state.flags, PermanentFlags: state.permFlags, Attributes: state.attrs, diff --git a/connector/dummy_test.go b/connector/dummy_test.go index a955b46f..3c91b046 100644 --- a/connector/dummy_test.go +++ b/connector/dummy_test.go @@ -40,7 +40,7 @@ func TestDummyConnector_validateUpdate(t *testing.T) { require.Error(t, conn.validateUpdate([]string{"Folders", "something"}, []string{"other"})) require.Error(t, conn.validateUpdate([]string{"something"}, []string{"Folders", "other"})) - conn.SetLabelPrefix("Labels") + conn.SetMailboxPrefix("Labels") require.NoError(t, conn.validateUpdate([]string{"Labels", "something"}, []string{"Labels", "other"})) require.NoError(t, conn.validateUpdate([]string{"Labels", "something"}, []string{"Labels", "other", "long"})) require.Error(t, conn.validateUpdate([]string{"Labels", "something"}, []string{"other"})) diff --git a/connector/mock_connector/connector.go b/connector/mock_connector/connector.go index 29c6e004..1502ffa9 100644 --- a/connector/mock_connector/connector.go +++ b/connector/mock_connector/connector.go @@ -36,6 +36,20 @@ func (m *MockConnector) EXPECT() *MockConnectorMockRecorder { return m.recorder } +// AddMessagesToMailbox mocks base method. +func (m *MockConnector) AddMessagesToMailbox(arg0 context.Context, arg1 []imap.MessageID, arg2 imap.MailboxID) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddMessagesToMailbox", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddMessagesToMailbox indicates an expected call of AddMessagesToMailbox. +func (mr *MockConnectorMockRecorder) AddMessagesToMailbox(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMessagesToMailbox", reflect.TypeOf((*MockConnector)(nil).AddMessagesToMailbox), arg0, arg1, arg2) +} + // Authorize mocks base method. func (m *MockConnector) Authorize(arg0 string, arg1 []byte) bool { m.ctrl.T.Helper() @@ -64,71 +78,72 @@ func (mr *MockConnectorMockRecorder) Close(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockConnector)(nil).Close), arg0) } -// CreateLabel mocks base method. -func (m *MockConnector) CreateLabel(arg0 context.Context, arg1 []string) (imap.Mailbox, error) { +// CreateMailbox mocks base method. +func (m *MockConnector) CreateMailbox(arg0 context.Context, arg1 []string) (imap.Mailbox, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateLabel", arg0, arg1) + ret := m.ctrl.Call(m, "CreateMailbox", arg0, arg1) ret0, _ := ret[0].(imap.Mailbox) ret1, _ := ret[1].(error) return ret0, ret1 } -// CreateLabel indicates an expected call of CreateLabel. -func (mr *MockConnectorMockRecorder) CreateLabel(arg0, arg1 interface{}) *gomock.Call { +// CreateMailbox indicates an expected call of CreateMailbox. +func (mr *MockConnectorMockRecorder) CreateMailbox(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLabel", reflect.TypeOf((*MockConnector)(nil).CreateLabel), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateMailbox", reflect.TypeOf((*MockConnector)(nil).CreateMailbox), arg0, arg1) } // CreateMessage mocks base method. -func (m *MockConnector) CreateMessage(arg0 context.Context, arg1 imap.LabelID, arg2 []byte, arg3 *imap.ParsedMessage, arg4 imap.FlagSet, arg5 time.Time) (imap.Message, error) { +func (m *MockConnector) CreateMessage(arg0 context.Context, arg1 imap.MailboxID, arg2 []byte, arg3 imap.FlagSet, arg4 time.Time) (imap.Message, []byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateMessage", arg0, arg1, arg2, arg3, arg4, arg5) + ret := m.ctrl.Call(m, "CreateMessage", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(imap.Message) - ret1, _ := ret[1].(error) - return ret0, ret1 + ret1, _ := ret[1].([]byte) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 } // CreateMessage indicates an expected call of CreateMessage. -func (mr *MockConnectorMockRecorder) CreateMessage(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +func (mr *MockConnectorMockRecorder) CreateMessage(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateMessage", reflect.TypeOf((*MockConnector)(nil).CreateMessage), arg0, arg1, arg2, arg3, arg4, arg5) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateMessage", reflect.TypeOf((*MockConnector)(nil).CreateMessage), arg0, arg1, arg2, arg3, arg4) } -// DeleteLabel mocks base method. -func (m *MockConnector) DeleteLabel(arg0 context.Context, arg1 imap.LabelID) error { +// DeleteMailbox mocks base method. +func (m *MockConnector) DeleteMailbox(arg0 context.Context, arg1 imap.MailboxID) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteLabel", arg0, arg1) + ret := m.ctrl.Call(m, "DeleteMailbox", arg0, arg1) ret0, _ := ret[0].(error) return ret0 } -// DeleteLabel indicates an expected call of DeleteLabel. -func (mr *MockConnectorMockRecorder) DeleteLabel(arg0, arg1 interface{}) *gomock.Call { +// DeleteMailbox indicates an expected call of DeleteMailbox. +func (mr *MockConnectorMockRecorder) DeleteMailbox(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLabel", reflect.TypeOf((*MockConnector)(nil).DeleteLabel), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMailbox", reflect.TypeOf((*MockConnector)(nil).DeleteMailbox), arg0, arg1) } -// GetLabel mocks base method. -func (m *MockConnector) GetLabel(arg0 context.Context, arg1 imap.LabelID) (imap.Mailbox, error) { +// GetMailbox mocks base method. +func (m *MockConnector) GetMailbox(arg0 context.Context, arg1 imap.MailboxID) (imap.Mailbox, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLabel", arg0, arg1) + ret := m.ctrl.Call(m, "GetMailbox", arg0, arg1) ret0, _ := ret[0].(imap.Mailbox) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetLabel indicates an expected call of GetLabel. -func (mr *MockConnectorMockRecorder) GetLabel(arg0, arg1 interface{}) *gomock.Call { +// GetMailbox indicates an expected call of GetMailbox. +func (mr *MockConnectorMockRecorder) GetMailbox(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLabel", reflect.TypeOf((*MockConnector)(nil).GetLabel), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMailbox", reflect.TypeOf((*MockConnector)(nil).GetMailbox), arg0, arg1) } // GetMessage mocks base method. -func (m *MockConnector) GetMessage(arg0 context.Context, arg1 imap.MessageID) (imap.Message, []imap.LabelID, error) { +func (m *MockConnector) GetMessage(arg0 context.Context, arg1 imap.MessageID) (imap.Message, []imap.MailboxID, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetMessage", arg0, arg1) ret0, _ := ret[0].(imap.Message) - ret1, _ := ret[1].([]imap.LabelID) + ret1, _ := ret[1].([]imap.MailboxID) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } @@ -139,6 +154,20 @@ func (mr *MockConnectorMockRecorder) GetMessage(arg0, arg1 interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMessage", reflect.TypeOf((*MockConnector)(nil).GetMessage), arg0, arg1) } +// GetUIDValidity mocks base method. +func (m *MockConnector) GetUIDValidity() imap.UID { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUIDValidity") + ret0, _ := ret[0].(imap.UID) + return ret0 +} + +// GetUIDValidity indicates an expected call of GetUIDValidity. +func (mr *MockConnectorMockRecorder) GetUIDValidity() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUIDValidity", reflect.TypeOf((*MockConnector)(nil).GetUIDValidity)) +} + // GetUpdates mocks base method. func (m *MockConnector) GetUpdates() <-chan imap.Update { m.ctrl.T.Helper() @@ -153,18 +182,18 @@ func (mr *MockConnectorMockRecorder) GetUpdates() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUpdates", reflect.TypeOf((*MockConnector)(nil).GetUpdates)) } -// LabelMessages mocks base method. -func (m *MockConnector) LabelMessages(arg0 context.Context, arg1 []imap.MessageID, arg2 imap.LabelID) error { +// IsMailboxVisible mocks base method. +func (m *MockConnector) IsMailboxVisible(arg0 context.Context, arg1 imap.MailboxID) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LabelMessages", arg0, arg1, arg2) - ret0, _ := ret[0].(error) + ret := m.ctrl.Call(m, "IsMailboxVisible", arg0, arg1) + ret0, _ := ret[0].(bool) return ret0 } -// LabelMessages indicates an expected call of LabelMessages. -func (mr *MockConnectorMockRecorder) LabelMessages(arg0, arg1, arg2 interface{}) *gomock.Call { +// IsMailboxVisible indicates an expected call of IsMailboxVisible. +func (mr *MockConnectorMockRecorder) IsMailboxVisible(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LabelMessages", reflect.TypeOf((*MockConnector)(nil).LabelMessages), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsMailboxVisible", reflect.TypeOf((*MockConnector)(nil).IsMailboxVisible), arg0, arg1) } // MarkMessagesFlagged mocks base method. @@ -196,7 +225,7 @@ func (mr *MockConnectorMockRecorder) MarkMessagesSeen(arg0, arg1, arg2 interface } // MoveMessages mocks base method. -func (m *MockConnector) MoveMessages(arg0 context.Context, arg1 []imap.MessageID, arg2, arg3 imap.LabelID) error { +func (m *MockConnector) MoveMessages(arg0 context.Context, arg1 []imap.MessageID, arg2, arg3 imap.MailboxID) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MoveMessages", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(error) @@ -209,30 +238,44 @@ func (mr *MockConnectorMockRecorder) MoveMessages(arg0, arg1, arg2, arg3 interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MoveMessages", reflect.TypeOf((*MockConnector)(nil).MoveMessages), arg0, arg1, arg2, arg3) } -// UnlabelMessages mocks base method. -func (m *MockConnector) UnlabelMessages(arg0 context.Context, arg1 []imap.MessageID, arg2 imap.LabelID) error { +// RemoveMessagesFromMailbox mocks base method. +func (m *MockConnector) RemoveMessagesFromMailbox(arg0 context.Context, arg1 []imap.MessageID, arg2 imap.MailboxID) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveMessagesFromMailbox", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveMessagesFromMailbox indicates an expected call of RemoveMessagesFromMailbox. +func (mr *MockConnectorMockRecorder) RemoveMessagesFromMailbox(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveMessagesFromMailbox", reflect.TypeOf((*MockConnector)(nil).RemoveMessagesFromMailbox), arg0, arg1, arg2) +} + +// SetUIDValidity mocks base method. +func (m *MockConnector) SetUIDValidity(arg0 imap.UID) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UnlabelMessages", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "SetUIDValidity", arg0) ret0, _ := ret[0].(error) return ret0 } -// UnlabelMessages indicates an expected call of UnlabelMessages. -func (mr *MockConnectorMockRecorder) UnlabelMessages(arg0, arg1, arg2 interface{}) *gomock.Call { +// SetUIDValidity indicates an expected call of SetUIDValidity. +func (mr *MockConnectorMockRecorder) SetUIDValidity(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlabelMessages", reflect.TypeOf((*MockConnector)(nil).UnlabelMessages), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetUIDValidity", reflect.TypeOf((*MockConnector)(nil).SetUIDValidity), arg0) } -// UpdateLabel mocks base method. -func (m *MockConnector) UpdateLabel(arg0 context.Context, arg1 imap.LabelID, arg2 []string) error { +// UpdateMailboxName mocks base method. +func (m *MockConnector) UpdateMailboxName(arg0 context.Context, arg1 imap.MailboxID, arg2 []string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateLabel", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "UpdateMailboxName", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } -// UpdateLabel indicates an expected call of UpdateLabel. -func (mr *MockConnectorMockRecorder) UpdateLabel(arg0, arg1, arg2 interface{}) *gomock.Call { +// UpdateMailboxName indicates an expected call of UpdateMailboxName. +func (mr *MockConnectorMockRecorder) UpdateMailboxName(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLabel", reflect.TypeOf((*MockConnector)(nil).UpdateLabel), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateMailboxName", reflect.TypeOf((*MockConnector)(nil).UpdateMailboxName), arg0, arg1, arg2) } diff --git a/imap/mailbox.go b/imap/mailbox.go index 3105bf4d..620b4a66 100644 --- a/imap/mailbox.go +++ b/imap/mailbox.go @@ -1,7 +1,7 @@ package imap type Mailbox struct { - ID LabelID + ID MailboxID Name []string diff --git a/imap/strong_types.go b/imap/strong_types.go index 5d0e1fc3..c05362fb 100644 --- a/imap/strong_types.go +++ b/imap/strong_types.go @@ -8,11 +8,11 @@ import ( "github.com/ProtonMail/gluon/internal/utils" ) -type LabelID string +type MailboxID string type MessageID string -func (l LabelID) ShortID() string { +func (l MailboxID) ShortID() string { return utils.ShortID(string(l)) } diff --git a/imap/update_mailbox_deleted.go b/imap/update_mailbox_deleted.go index f90e62bc..b2ffc21f 100644 --- a/imap/update_mailbox_deleted.go +++ b/imap/update_mailbox_deleted.go @@ -9,10 +9,10 @@ type MailboxDeleted struct { *updateWaiter - MailboxID LabelID + MailboxID MailboxID } -func NewMailboxDeleted(mailboxID LabelID) *MailboxDeleted { +func NewMailboxDeleted(mailboxID MailboxID) *MailboxDeleted { return &MailboxDeleted{ updateWaiter: newUpdateWaiter(), MailboxID: mailboxID, diff --git a/imap/update_mailbox_id_changed.go b/imap/update_mailbox_id_changed.go index 641d38d8..c97df948 100644 --- a/imap/update_mailbox_id_changed.go +++ b/imap/update_mailbox_id_changed.go @@ -10,10 +10,10 @@ type MailboxIDChanged struct { *updateWaiter InternalID InternalMailboxID - RemoteID LabelID + RemoteID MailboxID } -func NewMailboxIDChanged(internalID InternalMailboxID, remoteID LabelID) *MailboxIDChanged { +func NewMailboxIDChanged(internalID InternalMailboxID, remoteID MailboxID) *MailboxIDChanged { return &MailboxIDChanged{ updateWaiter: newUpdateWaiter(), InternalID: internalID, diff --git a/imap/update_mailbox_updated.go b/imap/update_mailbox_updated.go index 1ae86daa..fdea14cf 100644 --- a/imap/update_mailbox_updated.go +++ b/imap/update_mailbox_updated.go @@ -12,11 +12,11 @@ type MailboxUpdated struct { *updateWaiter - MailboxID LabelID + MailboxID MailboxID MailboxName []string } -func NewMailboxUpdated(mailboxID LabelID, mailboxName []string) *MailboxUpdated { +func NewMailboxUpdated(mailboxID MailboxID, mailboxName []string) *MailboxUpdated { return &MailboxUpdated{ updateWaiter: newUpdateWaiter(), MailboxID: mailboxID, diff --git a/imap/update_message_created.go b/imap/update_message_created.go index cd0f8554..e8ba2ec1 100644 --- a/imap/update_message_created.go +++ b/imap/update_message_created.go @@ -48,7 +48,7 @@ type MessagesCreated struct { type MessageCreated struct { Message Message Literal []byte - LabelIDs []LabelID + MailboxIDs []MailboxID ParsedMessage *ParsedMessage } diff --git a/imap/update_message_labels_updated.go b/imap/update_message_labels_updated.go index ef6f0102..f5226e09 100644 --- a/imap/update_message_labels_updated.go +++ b/imap/update_message_labels_updated.go @@ -6,18 +6,18 @@ import ( "github.com/bradenaw/juniper/xslices" ) -type MessageLabelsUpdated struct { +type MessageMailboxesUpdated struct { updateBase *updateWaiter MessageID MessageID - MailboxIDs []LabelID + MailboxIDs []MailboxID Seen, Flagged bool } -func NewMessageLabelsUpdated(messageID MessageID, mailboxIDs []LabelID, seen, flagged bool) *MessageLabelsUpdated { - return &MessageLabelsUpdated{ +func NewMessageMailboxesUpdated(messageID MessageID, mailboxIDs []MailboxID, seen, flagged bool) *MessageMailboxesUpdated { + return &MessageMailboxesUpdated{ updateWaiter: newUpdateWaiter(), MessageID: messageID, MailboxIDs: mailboxIDs, @@ -26,11 +26,11 @@ func NewMessageLabelsUpdated(messageID MessageID, mailboxIDs []LabelID, seen, fl } } -func (u *MessageLabelsUpdated) String() string { +func (u *MessageMailboxesUpdated) String() string { return fmt.Sprintf( - "MessageLabelsUpdated: MessageID = %v, MailboxIDs = %v, seen = %v, flagged = %v", + "MessageMailboxesUpdated: MessageID = %v, MailboxIDs = %v, seen = %v, flagged = %v", u.MessageID.ShortID(), - xslices.Map(u.MailboxIDs, func(id LabelID) string { return id.ShortID() }), + xslices.Map(u.MailboxIDs, func(id MailboxID) string { return id.ShortID() }), u.Seen, u.Flagged, ) diff --git a/internal/backend/connector_updates.go b/internal/backend/connector_updates.go index 9d000ece..308a18be 100644 --- a/internal/backend/connector_updates.go +++ b/internal/backend/connector_updates.go @@ -38,8 +38,8 @@ func (user *user) apply(ctx context.Context, update imap.Update) error { case *imap.MessagesCreated: return user.applyMessagesCreated(ctx, update) - case *imap.MessageLabelsUpdated: - return user.applyMessageLabelsUpdated(ctx, update) + case *imap.MessageMailboxesUpdated: + return user.applyMessageMailboxesUpdated(ctx, update) case *imap.MessageFlagsUpdated: return user.applyMessageFlagsUpdated(ctx, update) @@ -156,7 +156,7 @@ func (user *user) applyMessagesCreated(ctx context.Context, update *imap.Message messagesToCreate := make([]*db.CreateMessageReq, 0, len(update.Messages)) messagesToCreateFilter := make(map[imap.MessageID]imap.InternalMessageID, len(update.Messages)/2) messageForMBox := make(map[imap.InternalMailboxID][]imap.InternalMessageID) - mboxInternalIDMap := make(map[imap.LabelID]imap.InternalMailboxID) + mboxInternalIDMap := make(map[imap.MailboxID]imap.InternalMailboxID) if err := user.db.Read(ctx, func(ctx context.Context, client *ent.Client) error { for _, message := range update.Messages { @@ -187,7 +187,7 @@ func (user *user) applyMessagesCreated(ctx context.Context, update *imap.Message messagesToCreateFilter[message.Message.ID] = internalID } - for _, mboxID := range message.LabelIDs { + for _, mboxID := range message.MailboxIDs { v, ok := mboxInternalIDMap[mboxID] if !ok { internalMBoxID, err := db.GetMailboxIDWithRemoteID(ctx, client, mboxID) @@ -260,8 +260,8 @@ func (user *user) applyMessagesCreated(ctx context.Context, update *imap.Message }) } -// applyMessageLabelsUpdated applies a MessageLabelsUpdated update. -func (user *user) applyMessageLabelsUpdated(ctx context.Context, update *imap.MessageLabelsUpdated) error { +// applyMessageMailboxesUpdated applies a MessageMailboxesUpdated update. +func (user *user) applyMessageMailboxesUpdated(ctx context.Context, update *imap.MessageMailboxesUpdated) error { if exists, err := db.ReadResult(ctx, user.db, func(ctx context.Context, client *ent.Client) (bool, error) { return db.MessageExistsWithRemoteID(ctx, client, update.MessageID) }); err != nil { diff --git a/internal/backend/state_connector_impl.go b/internal/backend/state_connector_impl.go index f06bed78..1702f4c2 100644 --- a/internal/backend/state_connector_impl.go +++ b/internal/backend/state_connector_impl.go @@ -38,7 +38,7 @@ func (sc *stateConnectorImpl) ClearAllConnMetadata() { func (sc *stateConnectorImpl) CreateMailbox(ctx context.Context, name []string) (imap.Mailbox, error) { ctx = sc.newContextWithMetadata(ctx) - mbox, err := sc.connector.CreateLabel(ctx, name) + mbox, err := sc.connector.CreateMailbox(ctx, name) if err != nil { return imap.Mailbox{}, err } @@ -46,21 +46,21 @@ func (sc *stateConnectorImpl) CreateMailbox(ctx context.Context, name []string) return mbox, nil } -func (sc *stateConnectorImpl) UpdateMailbox(ctx context.Context, mboxID imap.LabelID, oldName, newName []string) error { +func (sc *stateConnectorImpl) UpdateMailbox(ctx context.Context, mboxID imap.MailboxID, oldName, newName []string) error { ctx = sc.newContextWithMetadata(ctx) - return sc.connector.UpdateLabel(ctx, mboxID, newName) + return sc.connector.UpdateMailboxName(ctx, mboxID, newName) } -func (sc *stateConnectorImpl) DeleteMailbox(ctx context.Context, mboxID imap.LabelID) error { +func (sc *stateConnectorImpl) DeleteMailbox(ctx context.Context, mboxID imap.MailboxID) error { ctx = sc.newContextWithMetadata(ctx) - return sc.connector.DeleteLabel(ctx, mboxID) + return sc.connector.DeleteMailbox(ctx, mboxID) } func (sc *stateConnectorImpl) CreateMessage( ctx context.Context, - mboxID imap.LabelID, + mboxID imap.MailboxID, literal []byte, flags imap.FlagSet, date time.Time, @@ -78,11 +78,11 @@ func (sc *stateConnectorImpl) CreateMessage( func (sc *stateConnectorImpl) AddMessagesToMailbox( ctx context.Context, messageIDs []imap.MessageID, - mboxID imap.LabelID, + mboxID imap.MailboxID, ) error { ctx = sc.newContextWithMetadata(ctx) - if err := sc.connector.LabelMessages(ctx, messageIDs, mboxID); err != nil { + if err := sc.connector.AddMessagesToMailbox(ctx, messageIDs, mboxID); err != nil { return sc.refresh(ctx, messageIDs, mboxID) } @@ -92,11 +92,11 @@ func (sc *stateConnectorImpl) AddMessagesToMailbox( func (sc *stateConnectorImpl) RemoveMessagesFromMailbox( ctx context.Context, messageIDs []imap.MessageID, - mboxID imap.LabelID, + mboxID imap.MailboxID, ) error { ctx = sc.newContextWithMetadata(ctx) - if err := sc.connector.UnlabelMessages(ctx, messageIDs, mboxID); err != nil { + if err := sc.connector.RemoveMessagesFromMailbox(ctx, messageIDs, mboxID); err != nil { return sc.refresh(ctx, messageIDs, mboxID) } @@ -106,8 +106,8 @@ func (sc *stateConnectorImpl) RemoveMessagesFromMailbox( func (sc *stateConnectorImpl) MoveMessagesFromMailbox( ctx context.Context, messageIDs []imap.MessageID, - mboxFromID imap.LabelID, - mboxToID imap.LabelID, + mboxFromID imap.MailboxID, + mboxToID imap.MailboxID, ) error { ctx = sc.newContextWithMetadata(ctx) @@ -142,8 +142,8 @@ func (sc *stateConnectorImpl) SetUIDValidity(uidValidity imap.UID) error { return sc.connector.SetUIDValidity(uidValidity) } -func (sc *stateConnectorImpl) IsMailboxVisible(ctx context.Context, id imap.LabelID) bool { - return sc.connector.IsLabelVisible(ctx, id) +func (sc *stateConnectorImpl) IsMailboxVisible(ctx context.Context, id imap.MailboxID) bool { + return sc.connector.IsMailboxVisible(ctx, id) } func (sc *stateConnectorImpl) getMetadataValue(key string) any { @@ -166,14 +166,14 @@ func (sc *stateConnectorImpl) newContextWithMetadata(ctx context.Context) contex return ctx } -func (sc *stateConnectorImpl) refresh(ctx context.Context, messageIDs []imap.MessageID, mboxIDs ...imap.LabelID) error { +func (sc *stateConnectorImpl) refresh(ctx context.Context, messageIDs []imap.MessageID, mboxIDs ...imap.MailboxID) error { for _, messageID := range messageIDs { message, mboxIDs, err := sc.connector.GetMessage(ctx, messageID) if err != nil { return err } - sc.user.updateInjector.send(ctx, imap.NewMessageLabelsUpdated( + sc.user.updateInjector.send(ctx, imap.NewMessageMailboxesUpdated( message.ID, mboxIDs, message.Flags.ContainsUnchecked(imap.FlagSeenLowerCase), @@ -182,7 +182,7 @@ func (sc *stateConnectorImpl) refresh(ctx context.Context, messageIDs []imap.Mes } for _, mboxID := range mboxIDs { - mailbox, err := sc.connector.GetLabel(ctx, mboxID) + mailbox, err := sc.connector.GetMailbox(ctx, mboxID) if err != nil { return err } diff --git a/internal/db/ent/client.go b/internal/db/ent/client.go index aad46b52..abb336b3 100644 --- a/internal/db/ent/client.go +++ b/internal/db/ent/client.go @@ -144,7 +144,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) // Mailbox. // Query(). // Count(ctx) -// func (c *Client) Debug() *Client { if c.debug { return c diff --git a/internal/db/ent/ent.go b/internal/db/ent/ent.go index 3ec4e004..f61cc4b9 100644 --- a/internal/db/ent/ent.go +++ b/internal/db/ent/ent.go @@ -95,7 +95,6 @@ type AggregateFunc func(*sql.Selector) string // GroupBy(field1, field2). // Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). // Scan(ctx, &v) -// func As(fn AggregateFunc, end string) AggregateFunc { return func(s *sql.Selector) string { return sql.As(fn(s), end) diff --git a/internal/db/ent/hook/hook.go b/internal/db/ent/hook/hook.go index 0788845b..52c615f3 100644 --- a/internal/db/ent/hook/hook.go +++ b/internal/db/ent/hook/hook.go @@ -208,7 +208,6 @@ func HasFields(field string, fields ...string) Condition { // If executes the given hook under condition. // // hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) -// func If(hk ent.Hook, cond Condition) ent.Hook { return func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { @@ -223,7 +222,6 @@ func If(hk ent.Hook, cond Condition) ent.Hook { // On executes the given hook only for the given operation. // // hook.On(Log, ent.Delete|ent.Create) -// func On(hk ent.Hook, op ent.Op) ent.Hook { return If(hk, HasOp(op)) } @@ -231,7 +229,6 @@ func On(hk ent.Hook, op ent.Op) ent.Hook { // Unless skips the given hook only for the given operation. // // hook.Unless(Log, ent.Update|ent.UpdateOne) -// func Unless(hk ent.Hook, op ent.Op) ent.Hook { return If(hk, Not(HasOp(op))) } @@ -252,7 +249,6 @@ func FixedError(err error) ent.Hook { // Reject(ent.Delete|ent.Update), // } // } -// func Reject(op ent.Op) ent.Hook { hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) return On(hk, op) diff --git a/internal/db/ent/mailbox.go b/internal/db/ent/mailbox.go index f4ebf508..b863a41b 100644 --- a/internal/db/ent/mailbox.go +++ b/internal/db/ent/mailbox.go @@ -17,7 +17,7 @@ type Mailbox struct { // ID of the ent. ID imap.InternalMailboxID `json:"id,omitempty"` // RemoteID holds the value of the "RemoteID" field. - RemoteID imap.LabelID `json:"RemoteID,omitempty"` + RemoteID imap.MailboxID `json:"RemoteID,omitempty"` // Name holds the value of the "Name" field. Name string `json:"Name,omitempty"` // UIDNext holds the value of the "UIDNext" field. @@ -118,7 +118,7 @@ func (m *Mailbox) assignValues(columns []string, values []interface{}) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field RemoteID", values[i]) } else if value.Valid { - m.RemoteID = imap.LabelID(value.String) + m.RemoteID = imap.MailboxID(value.String) } case mailbox.FieldName: if value, ok := values[i].(*sql.NullString); !ok { diff --git a/internal/db/ent/mailbox/where.go b/internal/db/ent/mailbox/where.go index 74ee1897..64940642 100644 --- a/internal/db/ent/mailbox/where.go +++ b/internal/db/ent/mailbox/where.go @@ -81,7 +81,7 @@ func IDLTE(id imap.InternalMailboxID) predicate.Mailbox { } // RemoteID applies equality check predicate on the "RemoteID" field. It's identical to RemoteIDEQ. -func RemoteID(v imap.LabelID) predicate.Mailbox { +func RemoteID(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldRemoteID), vc)) @@ -119,7 +119,7 @@ func Subscribed(v bool) predicate.Mailbox { } // RemoteIDEQ applies the EQ predicate on the "RemoteID" field. -func RemoteIDEQ(v imap.LabelID) predicate.Mailbox { +func RemoteIDEQ(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldRemoteID), vc)) @@ -127,7 +127,7 @@ func RemoteIDEQ(v imap.LabelID) predicate.Mailbox { } // RemoteIDNEQ applies the NEQ predicate on the "RemoteID" field. -func RemoteIDNEQ(v imap.LabelID) predicate.Mailbox { +func RemoteIDNEQ(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldRemoteID), vc)) @@ -135,7 +135,7 @@ func RemoteIDNEQ(v imap.LabelID) predicate.Mailbox { } // RemoteIDIn applies the In predicate on the "RemoteID" field. -func RemoteIDIn(vs ...imap.LabelID) predicate.Mailbox { +func RemoteIDIn(vs ...imap.MailboxID) predicate.Mailbox { v := make([]interface{}, len(vs)) for i := range v { v[i] = string(vs[i]) @@ -146,7 +146,7 @@ func RemoteIDIn(vs ...imap.LabelID) predicate.Mailbox { } // RemoteIDNotIn applies the NotIn predicate on the "RemoteID" field. -func RemoteIDNotIn(vs ...imap.LabelID) predicate.Mailbox { +func RemoteIDNotIn(vs ...imap.MailboxID) predicate.Mailbox { v := make([]interface{}, len(vs)) for i := range v { v[i] = string(vs[i]) @@ -157,7 +157,7 @@ func RemoteIDNotIn(vs ...imap.LabelID) predicate.Mailbox { } // RemoteIDGT applies the GT predicate on the "RemoteID" field. -func RemoteIDGT(v imap.LabelID) predicate.Mailbox { +func RemoteIDGT(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldRemoteID), vc)) @@ -165,7 +165,7 @@ func RemoteIDGT(v imap.LabelID) predicate.Mailbox { } // RemoteIDGTE applies the GTE predicate on the "RemoteID" field. -func RemoteIDGTE(v imap.LabelID) predicate.Mailbox { +func RemoteIDGTE(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldRemoteID), vc)) @@ -173,7 +173,7 @@ func RemoteIDGTE(v imap.LabelID) predicate.Mailbox { } // RemoteIDLT applies the LT predicate on the "RemoteID" field. -func RemoteIDLT(v imap.LabelID) predicate.Mailbox { +func RemoteIDLT(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldRemoteID), vc)) @@ -181,7 +181,7 @@ func RemoteIDLT(v imap.LabelID) predicate.Mailbox { } // RemoteIDLTE applies the LTE predicate on the "RemoteID" field. -func RemoteIDLTE(v imap.LabelID) predicate.Mailbox { +func RemoteIDLTE(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldRemoteID), vc)) @@ -189,7 +189,7 @@ func RemoteIDLTE(v imap.LabelID) predicate.Mailbox { } // RemoteIDContains applies the Contains predicate on the "RemoteID" field. -func RemoteIDContains(v imap.LabelID) predicate.Mailbox { +func RemoteIDContains(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.Contains(s.C(FieldRemoteID), vc)) @@ -197,7 +197,7 @@ func RemoteIDContains(v imap.LabelID) predicate.Mailbox { } // RemoteIDHasPrefix applies the HasPrefix predicate on the "RemoteID" field. -func RemoteIDHasPrefix(v imap.LabelID) predicate.Mailbox { +func RemoteIDHasPrefix(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.HasPrefix(s.C(FieldRemoteID), vc)) @@ -205,7 +205,7 @@ func RemoteIDHasPrefix(v imap.LabelID) predicate.Mailbox { } // RemoteIDHasSuffix applies the HasSuffix predicate on the "RemoteID" field. -func RemoteIDHasSuffix(v imap.LabelID) predicate.Mailbox { +func RemoteIDHasSuffix(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.HasSuffix(s.C(FieldRemoteID), vc)) @@ -227,7 +227,7 @@ func RemoteIDNotNil() predicate.Mailbox { } // RemoteIDEqualFold applies the EqualFold predicate on the "RemoteID" field. -func RemoteIDEqualFold(v imap.LabelID) predicate.Mailbox { +func RemoteIDEqualFold(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.EqualFold(s.C(FieldRemoteID), vc)) @@ -235,7 +235,7 @@ func RemoteIDEqualFold(v imap.LabelID) predicate.Mailbox { } // RemoteIDContainsFold applies the ContainsFold predicate on the "RemoteID" field. -func RemoteIDContainsFold(v imap.LabelID) predicate.Mailbox { +func RemoteIDContainsFold(v imap.MailboxID) predicate.Mailbox { vc := string(v) return predicate.Mailbox(func(s *sql.Selector) { s.Where(sql.ContainsFold(s.C(FieldRemoteID), vc)) diff --git a/internal/db/ent/mailbox_create.go b/internal/db/ent/mailbox_create.go index 9fa4d46e..b1fa61a3 100644 --- a/internal/db/ent/mailbox_create.go +++ b/internal/db/ent/mailbox_create.go @@ -25,13 +25,13 @@ type MailboxCreate struct { } // SetRemoteID sets the "RemoteID" field. -func (mc *MailboxCreate) SetRemoteID(ii imap.LabelID) *MailboxCreate { +func (mc *MailboxCreate) SetRemoteID(ii imap.MailboxID) *MailboxCreate { mc.mutation.SetRemoteID(ii) return mc } // SetNillableRemoteID sets the "RemoteID" field if the given value is not nil. -func (mc *MailboxCreate) SetNillableRemoteID(ii *imap.LabelID) *MailboxCreate { +func (mc *MailboxCreate) SetNillableRemoteID(ii *imap.MailboxID) *MailboxCreate { if ii != nil { mc.SetRemoteID(*ii) } diff --git a/internal/db/ent/mailbox_query.go b/internal/db/ent/mailbox_query.go index 4ff5f823..0afa7e5e 100644 --- a/internal/db/ent/mailbox_query.go +++ b/internal/db/ent/mailbox_query.go @@ -399,7 +399,7 @@ func (mq *MailboxQuery) WithAttributes(opts ...func(*MailboxAttrQuery)) *Mailbox // Example: // // var v []struct { -// RemoteID imap.LabelID `json:"RemoteID,omitempty"` +// RemoteID imap.MailboxID `json:"RemoteID,omitempty"` // Count int `json:"count,omitempty"` // } // @@ -407,7 +407,6 @@ func (mq *MailboxQuery) WithAttributes(opts ...func(*MailboxAttrQuery)) *Mailbox // GroupBy(mailbox.FieldRemoteID). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (mq *MailboxQuery) GroupBy(field string, fields ...string) *MailboxGroupBy { grbuild := &MailboxGroupBy{config: mq.config} grbuild.fields = append([]string{field}, fields...) @@ -428,13 +427,12 @@ func (mq *MailboxQuery) GroupBy(field string, fields ...string) *MailboxGroupBy // Example: // // var v []struct { -// RemoteID imap.LabelID `json:"RemoteID,omitempty"` +// RemoteID imap.MailboxID `json:"RemoteID,omitempty"` // } // // client.Mailbox.Query(). // Select(mailbox.FieldRemoteID). // Scan(ctx, &v) -// func (mq *MailboxQuery) Select(fields ...string) *MailboxSelect { mq.fields = append(mq.fields, fields...) selbuild := &MailboxSelect{MailboxQuery: mq} diff --git a/internal/db/ent/mailbox_update.go b/internal/db/ent/mailbox_update.go index 06a9bff3..46ceca2a 100644 --- a/internal/db/ent/mailbox_update.go +++ b/internal/db/ent/mailbox_update.go @@ -33,13 +33,13 @@ func (mu *MailboxUpdate) Where(ps ...predicate.Mailbox) *MailboxUpdate { } // SetRemoteID sets the "RemoteID" field. -func (mu *MailboxUpdate) SetRemoteID(ii imap.LabelID) *MailboxUpdate { +func (mu *MailboxUpdate) SetRemoteID(ii imap.MailboxID) *MailboxUpdate { mu.mutation.SetRemoteID(ii) return mu } // SetNillableRemoteID sets the "RemoteID" field if the given value is not nil. -func (mu *MailboxUpdate) SetNillableRemoteID(ii *imap.LabelID) *MailboxUpdate { +func (mu *MailboxUpdate) SetNillableRemoteID(ii *imap.MailboxID) *MailboxUpdate { if ii != nil { mu.SetRemoteID(*ii) } @@ -626,13 +626,13 @@ type MailboxUpdateOne struct { } // SetRemoteID sets the "RemoteID" field. -func (muo *MailboxUpdateOne) SetRemoteID(ii imap.LabelID) *MailboxUpdateOne { +func (muo *MailboxUpdateOne) SetRemoteID(ii imap.MailboxID) *MailboxUpdateOne { muo.mutation.SetRemoteID(ii) return muo } // SetNillableRemoteID sets the "RemoteID" field if the given value is not nil. -func (muo *MailboxUpdateOne) SetNillableRemoteID(ii *imap.LabelID) *MailboxUpdateOne { +func (muo *MailboxUpdateOne) SetNillableRemoteID(ii *imap.MailboxID) *MailboxUpdateOne { if ii != nil { muo.SetRemoteID(*ii) } diff --git a/internal/db/ent/mailboxattr_query.go b/internal/db/ent/mailboxattr_query.go index c4f0410e..bb5fcf54 100644 --- a/internal/db/ent/mailboxattr_query.go +++ b/internal/db/ent/mailboxattr_query.go @@ -262,7 +262,6 @@ func (maq *MailboxAttrQuery) Clone() *MailboxAttrQuery { // GroupBy(mailboxattr.FieldValue). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (maq *MailboxAttrQuery) GroupBy(field string, fields ...string) *MailboxAttrGroupBy { grbuild := &MailboxAttrGroupBy{config: maq.config} grbuild.fields = append([]string{field}, fields...) @@ -289,7 +288,6 @@ func (maq *MailboxAttrQuery) GroupBy(field string, fields ...string) *MailboxAtt // client.MailboxAttr.Query(). // Select(mailboxattr.FieldValue). // Scan(ctx, &v) -// func (maq *MailboxAttrQuery) Select(fields ...string) *MailboxAttrSelect { maq.fields = append(maq.fields, fields...) selbuild := &MailboxAttrSelect{MailboxAttrQuery: maq} diff --git a/internal/db/ent/mailboxflag_query.go b/internal/db/ent/mailboxflag_query.go index bf123930..0f04bbbe 100644 --- a/internal/db/ent/mailboxflag_query.go +++ b/internal/db/ent/mailboxflag_query.go @@ -262,7 +262,6 @@ func (mfq *MailboxFlagQuery) Clone() *MailboxFlagQuery { // GroupBy(mailboxflag.FieldValue). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (mfq *MailboxFlagQuery) GroupBy(field string, fields ...string) *MailboxFlagGroupBy { grbuild := &MailboxFlagGroupBy{config: mfq.config} grbuild.fields = append([]string{field}, fields...) @@ -289,7 +288,6 @@ func (mfq *MailboxFlagQuery) GroupBy(field string, fields ...string) *MailboxFla // client.MailboxFlag.Query(). // Select(mailboxflag.FieldValue). // Scan(ctx, &v) -// func (mfq *MailboxFlagQuery) Select(fields ...string) *MailboxFlagSelect { mfq.fields = append(mfq.fields, fields...) selbuild := &MailboxFlagSelect{MailboxFlagQuery: mfq} diff --git a/internal/db/ent/mailboxpermflag_query.go b/internal/db/ent/mailboxpermflag_query.go index 6ab9281e..a5b1f983 100644 --- a/internal/db/ent/mailboxpermflag_query.go +++ b/internal/db/ent/mailboxpermflag_query.go @@ -262,7 +262,6 @@ func (mpfq *MailboxPermFlagQuery) Clone() *MailboxPermFlagQuery { // GroupBy(mailboxpermflag.FieldValue). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (mpfq *MailboxPermFlagQuery) GroupBy(field string, fields ...string) *MailboxPermFlagGroupBy { grbuild := &MailboxPermFlagGroupBy{config: mpfq.config} grbuild.fields = append([]string{field}, fields...) @@ -289,7 +288,6 @@ func (mpfq *MailboxPermFlagQuery) GroupBy(field string, fields ...string) *Mailb // client.MailboxPermFlag.Query(). // Select(mailboxpermflag.FieldValue). // Scan(ctx, &v) -// func (mpfq *MailboxPermFlagQuery) Select(fields ...string) *MailboxPermFlagSelect { mpfq.fields = append(mpfq.fields, fields...) selbuild := &MailboxPermFlagSelect{MailboxPermFlagQuery: mpfq} diff --git a/internal/db/ent/message_query.go b/internal/db/ent/message_query.go index 9eb4e4cd..bcdd39c1 100644 --- a/internal/db/ent/message_query.go +++ b/internal/db/ent/message_query.go @@ -335,7 +335,6 @@ func (mq *MessageQuery) WithUIDs(opts ...func(*UIDQuery)) *MessageQuery { // GroupBy(message.FieldRemoteID). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (mq *MessageQuery) GroupBy(field string, fields ...string) *MessageGroupBy { grbuild := &MessageGroupBy{config: mq.config} grbuild.fields = append([]string{field}, fields...) @@ -362,7 +361,6 @@ func (mq *MessageQuery) GroupBy(field string, fields ...string) *MessageGroupBy // client.Message.Query(). // Select(message.FieldRemoteID). // Scan(ctx, &v) -// func (mq *MessageQuery) Select(fields ...string) *MessageSelect { mq.fields = append(mq.fields, fields...) selbuild := &MessageSelect{MessageQuery: mq} diff --git a/internal/db/ent/messageflag_query.go b/internal/db/ent/messageflag_query.go index 3d2bf03a..39244ca8 100644 --- a/internal/db/ent/messageflag_query.go +++ b/internal/db/ent/messageflag_query.go @@ -299,7 +299,6 @@ func (mfq *MessageFlagQuery) WithMessages(opts ...func(*MessageQuery)) *MessageF // GroupBy(messageflag.FieldValue). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (mfq *MessageFlagQuery) GroupBy(field string, fields ...string) *MessageFlagGroupBy { grbuild := &MessageFlagGroupBy{config: mfq.config} grbuild.fields = append([]string{field}, fields...) @@ -326,7 +325,6 @@ func (mfq *MessageFlagQuery) GroupBy(field string, fields ...string) *MessageFla // client.MessageFlag.Query(). // Select(messageflag.FieldValue). // Scan(ctx, &v) -// func (mfq *MessageFlagQuery) Select(fields ...string) *MessageFlagSelect { mfq.fields = append(mfq.fields, fields...) selbuild := &MessageFlagSelect{MessageFlagQuery: mfq} diff --git a/internal/db/ent/migrate/migrate.go b/internal/db/ent/migrate/migrate.go index 6bccf391..1956a6bf 100644 --- a/internal/db/ent/migrate/migrate.go +++ b/internal/db/ent/migrate/migrate.go @@ -56,10 +56,9 @@ func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...sche // WriteTo writes the schema changes to w instead of running them against the database. // -// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { // log.Fatal(err) -// } -// +// } func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) } diff --git a/internal/db/ent/mutation.go b/internal/db/ent/mutation.go index cc37fbee..b09d54bc 100644 --- a/internal/db/ent/mutation.go +++ b/internal/db/ent/mutation.go @@ -48,7 +48,7 @@ type MailboxMutation struct { op Op typ string id *imap.InternalMailboxID - _RemoteID *imap.LabelID + _RemoteID *imap.MailboxID _Name *string _UIDNext *imap.UID add_UIDNext *imap.UID @@ -178,12 +178,12 @@ func (m *MailboxMutation) IDs(ctx context.Context) ([]imap.InternalMailboxID, er } // SetRemoteID sets the "RemoteID" field. -func (m *MailboxMutation) SetRemoteID(ii imap.LabelID) { +func (m *MailboxMutation) SetRemoteID(ii imap.MailboxID) { m._RemoteID = &ii } // RemoteID returns the value of the "RemoteID" field in the mutation. -func (m *MailboxMutation) RemoteID() (r imap.LabelID, exists bool) { +func (m *MailboxMutation) RemoteID() (r imap.MailboxID, exists bool) { v := m._RemoteID if v == nil { return @@ -194,7 +194,7 @@ func (m *MailboxMutation) RemoteID() (r imap.LabelID, exists bool) { // OldRemoteID returns the old "RemoteID" field's value of the Mailbox entity. // If the Mailbox object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MailboxMutation) OldRemoteID(ctx context.Context) (v imap.LabelID, err error) { +func (m *MailboxMutation) OldRemoteID(ctx context.Context) (v imap.MailboxID, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRemoteID is only allowed on UpdateOne operations") } @@ -708,7 +708,7 @@ func (m *MailboxMutation) OldField(ctx context.Context, name string) (ent.Value, func (m *MailboxMutation) SetField(name string, value ent.Value) error { switch name { case mailbox.FieldRemoteID: - v, ok := value.(imap.LabelID) + v, ok := value.(imap.MailboxID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } diff --git a/internal/db/ent/schema/mailbox.go b/internal/db/ent/schema/mailbox.go index 98a8ba37..e8c14663 100644 --- a/internal/db/ent/schema/mailbox.go +++ b/internal/db/ent/schema/mailbox.go @@ -18,7 +18,7 @@ type Mailbox struct { func (Mailbox) Fields() []ent.Field { return []ent.Field{ field.Uint64("id").GoType(imap.InternalMailboxID(0)).Unique().Immutable(), - field.String("RemoteID").Optional().Unique().GoType(imap.LabelID("")), + field.String("RemoteID").Optional().Unique().GoType(imap.MailboxID("")), field.String("Name").Unique(), field.Uint32("UIDNext").Default(1).GoType(imap.UID(0)), field.Uint32("UIDValidity").Default(1).GoType(imap.UID(0)), diff --git a/internal/db/ent/uid_query.go b/internal/db/ent/uid_query.go index ab36988b..89e724b5 100644 --- a/internal/db/ent/uid_query.go +++ b/internal/db/ent/uid_query.go @@ -335,7 +335,6 @@ func (uq *UIDQuery) WithMailbox(opts ...func(*MailboxQuery)) *UIDQuery { // GroupBy(uid.FieldUID). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (uq *UIDQuery) GroupBy(field string, fields ...string) *UIDGroupBy { grbuild := &UIDGroupBy{config: uq.config} grbuild.fields = append([]string{field}, fields...) @@ -362,7 +361,6 @@ func (uq *UIDQuery) GroupBy(field string, fields ...string) *UIDGroupBy { // client.UID.Query(). // Select(uid.FieldUID). // Scan(ctx, &v) -// func (uq *UIDQuery) Select(fields ...string) *UIDSelect { uq.fields = append(uq.fields, fields...) selbuild := &UIDSelect{UIDQuery: uq} diff --git a/internal/db/ent/uidvalidity_query.go b/internal/db/ent/uidvalidity_query.go index 03bb8e5b..863a37d5 100644 --- a/internal/db/ent/uidvalidity_query.go +++ b/internal/db/ent/uidvalidity_query.go @@ -261,7 +261,6 @@ func (uvq *UIDValidityQuery) Clone() *UIDValidityQuery { // GroupBy(uidvalidity.FieldUIDValidity). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (uvq *UIDValidityQuery) GroupBy(field string, fields ...string) *UIDValidityGroupBy { grbuild := &UIDValidityGroupBy{config: uvq.config} grbuild.fields = append([]string{field}, fields...) @@ -288,7 +287,6 @@ func (uvq *UIDValidityQuery) GroupBy(field string, fields ...string) *UIDValidit // client.UIDValidity.Query(). // Select(uidvalidity.FieldUIDValidity). // Scan(ctx, &v) -// func (uvq *UIDValidityQuery) Select(fields ...string) *UIDValiditySelect { uvq.fields = append(uvq.fields, fields...) selbuild := &UIDValiditySelect{UIDValidityQuery: uvq} diff --git a/internal/db/mailbox.go b/internal/db/mailbox.go index ba7f743c..d36ae885 100644 --- a/internal/db/mailbox.go +++ b/internal/db/mailbox.go @@ -17,7 +17,7 @@ import ( "github.com/bradenaw/juniper/xslices" ) -func CreateMailbox(ctx context.Context, tx *ent.Tx, labelID imap.LabelID, name string, flags, permFlags, attrs imap.FlagSet) (*ent.Mailbox, error) { +func CreateMailbox(ctx context.Context, tx *ent.Tx, mboxID imap.MailboxID, name string, flags, permFlags, attrs imap.FlagSet) (*ent.Mailbox, error) { create := tx.Mailbox.Create(). SetName(name) @@ -33,8 +33,8 @@ func CreateMailbox(ctx context.Context, tx *ent.Tx, labelID imap.LabelID, name s create.AddAttributes(tx.MailboxAttr.Create().SetValue(attr).SaveX(ctx)) } - if len(labelID) != 0 { - create = create.SetRemoteID(labelID) + if len(mboxID) != 0 { + create = create.SetRemoteID(mboxID) } globalUIDValidity, err := getGlobalUIDValidity(ctx, tx) @@ -51,7 +51,7 @@ func MailboxExistsWithID(ctx context.Context, client *ent.Client, mboxID imap.In return client.Mailbox.Query().Where(mailbox.ID(mboxID)).Exist(ctx) } -func MailboxExistsWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.LabelID) (bool, error) { +func MailboxExistsWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.MailboxID) (bool, error) { return client.Mailbox.Query().Where(mailbox.RemoteID(mboxID)).Exist(ctx) } @@ -59,7 +59,7 @@ func MailboxExistsWithName(ctx context.Context, client *ent.Client, name string) return client.Mailbox.Query().Where(mailbox.Name(name)).Exist(ctx) } -func RenameMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.LabelID, name string) error { +func RenameMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.MailboxID, name string) error { if _, err := tx.Mailbox.Update(). Where(mailbox.RemoteID(mboxID)). SetName(name). @@ -72,7 +72,7 @@ func RenameMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.Labe // DeleteMailboxWithRemoteID deletes the mailbox with the given remote ID. // It returns the (potentially new) global UID validity, along with a bool indicating whether it has been increased. -func DeleteMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.LabelID) (imap.UID, bool, error) { +func DeleteMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.MailboxID) (imap.UID, bool, error) { mbox, err := tx.Mailbox.Query(). Where(mailbox.RemoteID(mboxID)). Select(mailbox.FieldUIDValidity). @@ -109,7 +109,7 @@ func DeleteMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.Labe return newUIDValidity, newUIDValidity > curUIDValidity, nil } -func UpdateRemoteMailboxID(ctx context.Context, tx *ent.Tx, internalID imap.InternalMailboxID, remoteID imap.LabelID) error { +func UpdateRemoteMailboxID(ctx context.Context, tx *ent.Tx, internalID imap.InternalMailboxID, remoteID imap.MailboxID) error { if _, err := tx.Mailbox.Update(). Where(mailbox.ID(internalID)). SetRemoteID(remoteID). @@ -147,7 +147,7 @@ func GetMailboxName(ctx context.Context, client *ent.Client, mboxID imap.Interna return mailbox.Name, nil } -func GetMailboxNameWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.LabelID) (string, error) { +func GetMailboxNameWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.MailboxID) (string, error) { mailbox, err := client.Mailbox.Query().Where(mailbox.RemoteID(mboxID)).Select(mailbox.FieldName).Only(ctx) if err != nil { return "", err @@ -204,7 +204,7 @@ func GetMailboxByID(ctx context.Context, client *ent.Client, id imap.InternalMai return client.Mailbox.Query().Where(mailbox.ID(id)).Only(ctx) } -func GetMailboxByRemoteID(ctx context.Context, client *ent.Client, id imap.LabelID) (*ent.Mailbox, error) { +func GetMailboxByRemoteID(ctx context.Context, client *ent.Client, id imap.MailboxID) (*ent.Mailbox, error) { return client.Mailbox.Query().Where(mailbox.RemoteID(id)).Only(ctx) } @@ -261,8 +261,8 @@ func GetMailboxMessagesForNewSnapshot(ctx context.Context, client *ent.Client, m return messages, nil } -func GetMailboxIDWithRemoteID(ctx context.Context, client *ent.Client, labelID imap.LabelID) (imap.InternalMailboxID, error) { - mbox, err := client.Mailbox.Query().Where(mailbox.RemoteID(labelID)).Select(mailbox.FieldID).Only(ctx) +func GetMailboxIDWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.MailboxID) (imap.InternalMailboxID, error) { + mbox, err := client.Mailbox.Query().Where(mailbox.RemoteID(mboxID)).Select(mailbox.FieldID).Only(ctx) if err != nil { return 0, err } @@ -270,7 +270,7 @@ func GetMailboxIDWithRemoteID(ctx context.Context, client *ent.Client, labelID i return mbox.ID, nil } -func TranslateRemoteMailboxIDs(ctx context.Context, client *ent.Client, mboxIDs []imap.LabelID) ([]imap.InternalMailboxID, error) { +func TranslateRemoteMailboxIDs(ctx context.Context, client *ent.Client, mboxIDs []imap.MailboxID) ([]imap.InternalMailboxID, error) { mboxes, err := client.Mailbox.Query().Where(mailbox.RemoteIDIn(mboxIDs...)).Select(mailbox.FieldID).All(ctx) if err != nil { return nil, err diff --git a/internal/ids/ids.go b/internal/ids/ids.go index 6497fc38..1dd1e889 100644 --- a/internal/ids/ids.go +++ b/internal/ids/ids.go @@ -9,7 +9,7 @@ import ( type MailboxIDPair struct { InternalID imap.InternalMailboxID - RemoteID imap.LabelID + RemoteID imap.MailboxID } func (m *MailboxIDPair) String() string { @@ -67,16 +67,16 @@ func SplitMessageIDPairSlice(s []MessageIDPair) ([]imap.InternalMessageID, []ima return internalMessageIDs, remoteMessageIDs } -func SplitMailboxIDPairSlice(s []MailboxIDPair) ([]imap.InternalMailboxID, []imap.LabelID) { +func SplitMailboxIDPairSlice(s []MailboxIDPair) ([]imap.InternalMailboxID, []imap.MailboxID) { l := len(s) internalMailboxIDs := make([]imap.InternalMailboxID, 0, l) - labelIDs := make([]imap.LabelID, 0, l) + mailboxIDs := make([]imap.MailboxID, 0, l) for _, v := range s { internalMailboxIDs = append(internalMailboxIDs, v.InternalID) - labelIDs = append(labelIDs, v.RemoteID) + mailboxIDs = append(mailboxIDs, v.RemoteID) } - return internalMailboxIDs, labelIDs + return internalMailboxIDs, mailboxIDs } diff --git a/internal/state/actions.go b/internal/state/actions.go index 717fad97..9f312d2c 100644 --- a/internal/state/actions.go +++ b/internal/state/actions.go @@ -74,7 +74,7 @@ func (state *State) actionDeleteMailbox(ctx context.Context, tx *ent.Tx, mboxID return state.user.QueueOrApplyStateUpdate(ctx, tx, NewMailboxDeletedStateUpdate(mboxID.InternalID)) } -func (state *State) actionUpdateMailbox(ctx context.Context, tx *ent.Tx, mboxID imap.LabelID, oldName, newName string) error { +func (state *State) actionUpdateMailbox(ctx context.Context, tx *ent.Tx, mboxID imap.MailboxID, oldName, newName string) error { if err := state.user.GetRemote().UpdateMailbox( ctx, mboxID, diff --git a/internal/state/connector.go b/internal/state/connector.go index f21c125f..2ff256c1 100644 --- a/internal/state/connector.go +++ b/internal/state/connector.go @@ -27,15 +27,15 @@ type Connector interface { CreateMailbox(ctx context.Context, name []string) (imap.Mailbox, error) // UpdateMailbox sets the name of the mailbox with the given ID to the given new name. - UpdateMailbox(ctx context.Context, mboxID imap.LabelID, oldName, newName []string) error + UpdateMailbox(ctx context.Context, mboxID imap.MailboxID, oldName, newName []string) error // DeleteMailbox deletes the mailbox with the given ID and name. - DeleteMailbox(ctx context.Context, mboxID imap.LabelID) error + DeleteMailbox(ctx context.Context, mboxID imap.MailboxID) error // CreateMessage appends a message literal to the mailbox with the given ID. CreateMessage( ctx context.Context, - mboxID imap.LabelID, + mboxID imap.MailboxID, literal []byte, flags imap.FlagSet, date time.Time, @@ -45,22 +45,22 @@ type Connector interface { AddMessagesToMailbox( ctx context.Context, messageIDs []imap.MessageID, - mboxID imap.LabelID, + mboxID imap.MailboxID, ) error // RemoveMessagesFromMailbox removes the message with the given ID from the mailbox with the given ID. RemoveMessagesFromMailbox( ctx context.Context, messageIDs []imap.MessageID, - mboxID imap.LabelID, + mboxID imap.MailboxID, ) error // MoveMessagesFromMailbox removes the message with the given ID from the mailbox with the given ID. MoveMessagesFromMailbox( ctx context.Context, messageIDs []imap.MessageID, - mboxFromID imap.LabelID, - mboxToID imap.LabelID, + mboxFromID imap.MailboxID, + mboxToID imap.MailboxID, ) error // SetMessagesSeen marks the message with the given ID as seen or unseen. @@ -73,5 +73,5 @@ type Connector interface { SetUIDValidity(imap.UID) error // IsMailboxVisible checks whether a mailbox is visible to a client. - IsMailboxVisible(ctx context.Context, id imap.LabelID) bool + IsMailboxVisible(ctx context.Context, id imap.MailboxID) bool } diff --git a/internal/state/snapshot.go b/internal/state/snapshot.go index a9cb1ff7..e3942285 100644 --- a/internal/state/snapshot.go +++ b/internal/state/snapshot.go @@ -404,7 +404,7 @@ func (snap *snapshot) expungeMessage(messageID imap.InternalMessageID) error { return nil } -func (snap *snapshot) updateMailboxRemoteID(internalID imap.InternalMailboxID, remoteID imap.LabelID) error { +func (snap *snapshot) updateMailboxRemoteID(internalID imap.InternalMailboxID, remoteID imap.MailboxID) error { if snap.mboxID.InternalID != internalID { return ErrNoSuchMailbox } diff --git a/internal/state/state.go b/internal/state/state.go index c916b52b..705b171a 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -644,7 +644,7 @@ func (state *State) popResponders(permitExpunge bool) []Responder { return pop } -func (state *State) UpdateMailboxRemoteID(internalID imap.InternalMailboxID, remoteID imap.LabelID) error { +func (state *State) UpdateMailboxRemoteID(internalID imap.InternalMailboxID, remoteID imap.MailboxID) error { if state.snap != nil { if err := state.snap.updateMailboxRemoteID(internalID, remoteID); err != nil { return err diff --git a/internal/state/updates.go b/internal/state/updates.go index f2da8aae..4c6e9873 100644 --- a/internal/state/updates.go +++ b/internal/state/updates.go @@ -268,10 +268,10 @@ func (state *State) applyMessageFlagsSet(ctx context.Context, tx *ent.Tx, messag type mailboxRemoteIDUpdateStateUpdate struct { SnapFilter - remoteID imap.LabelID + remoteID imap.MailboxID } -func NewMailboxRemoteIDUpdateStateUpdate(internalID imap.InternalMailboxID, remoteID imap.LabelID) Update { +func NewMailboxRemoteIDUpdateStateUpdate(internalID imap.InternalMailboxID, remoteID imap.MailboxID) Update { return &mailboxRemoteIDUpdateStateUpdate{ SnapFilter: NewMBoxIDStateFilter(internalID), remoteID: remoteID, diff --git a/internal/utils/utils.go b/internal/utils/utils.go index fccde631..685302b4 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -9,8 +9,8 @@ func NewRandomUserID() string { return "usr-" + uuid.NewString() } -// NewRandomLabelID return a new random label/mailbox ID. For debugging purposes, the ID starts with the 'label-' prefix. -func NewRandomLabelID() string { +// NewRandomMailboxID return a new random mailbox ID. For debugging purposes, the ID starts with the 'lbl-' prefix. +func NewRandomMailboxID() string { return "lbl-" + uuid.NewString() } diff --git a/store/mock_store/store.go b/store/mock_store/store.go index 8646e923..0b8f2ad8 100644 --- a/store/mock_store/store.go +++ b/store/mock_store/store.go @@ -81,6 +81,21 @@ func (mr *MockStoreMockRecorder) Get(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockStore)(nil).Get), arg0) } +// List mocks base method. +func (m *MockStore) List() ([]imap.InternalMessageID, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "List") + ret0, _ := ret[0].([]imap.InternalMessageID) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockStoreMockRecorder) List() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockStore)(nil).List)) +} + // Set mocks base method. func (m *MockStore) Set(arg0 imap.InternalMessageID, arg1 []byte) error { m.ctrl.T.Helper() diff --git a/tests/append_test.go b/tests/append_test.go index ec7902da..419f6ff6 100644 --- a/tests/append_test.go +++ b/tests/append_test.go @@ -188,7 +188,7 @@ type returnSameRemoteIDConnector struct { messageLiteral []byte } -func (r *returnSameRemoteIDConnector) CreateMessage(ctx context.Context, mboxID imap.LabelID, literal []byte, flags imap.FlagSet, date time.Time) (imap.Message, []byte, error) { +func (r *returnSameRemoteIDConnector) CreateMessage(ctx context.Context, mboxID imap.MailboxID, literal []byte, flags imap.FlagSet, date time.Time) (imap.Message, []byte, error) { r.lock.Lock() defer r.lock.Unlock() diff --git a/tests/copy_test.go b/tests/copy_test.go index c35fc88e..ba81e2d9 100644 --- a/tests/copy_test.go +++ b/tests/copy_test.go @@ -11,7 +11,7 @@ import ( ) func TestCopy(t *testing.T) { - runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.MailboxID) { { // There are 100 messages in the origin and no messages in the destination. mailboxStatus, err := client.Status(mbox, []goimap.StatusItem{goimap.StatusMessages}) @@ -62,7 +62,7 @@ func TestCopy(t *testing.T) { } func TestCopySameMBox(t *testing.T) { - runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.MailboxID) { { // There are 100 messages in the origin and no messages in the destination. mailboxStatus, err := client.Status(mbox, []goimap.StatusItem{goimap.StatusMessages}) @@ -93,7 +93,7 @@ func TestCopySameMBox(t *testing.T) { func TestCopyTryCreate(t *testing.T) { // Test can't be remove since there is no way to check the TRYCREATE response from the server - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // There are 100 messages in the origin. c.Cf(`A001 status %v (messages)`, mbox).Sxe(`MESSAGES 100`).OK(`A001`) @@ -108,7 +108,7 @@ func TestCopyTryCreate(t *testing.T) { } func TestCopyNonExistingClient(t *testing.T) { - runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.MailboxID) { { // Move message intervals to inbox sequenceSet, seqErr := goimap.ParseSeqSet("1:25,76:100") @@ -146,7 +146,7 @@ func TestCopyNonExistingClient(t *testing.T) { } func TestCopyNonExisting(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // MOVE some of the messages out of the mailbox. c.C(`A001 move 1:24,76:100 inbox`).OK(`A001`) diff --git a/tests/fetch_test.go b/tests/fetch_test.go index 8337385c..c985b9d1 100644 --- a/tests/fetch_test.go +++ b/tests/fetch_test.go @@ -317,7 +317,7 @@ func TestFetchUID(t *testing.T) { } func TestFetchFromDataSequences(t *testing.T) { - runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, _ *testSession, _ string, _ imap.LabelID) { + runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, _ *testSession, _ string, _ imap.MailboxID) { const sectionStr = "BODY[HEADER.FIELDS (To Subject)]" fetchResult := newFetchCommand(t, client).withItems(sectionStr).fetch("1:4,30:31,81") fetchResult.forSeqNum(1, func(builder *validatorBuilder) { @@ -388,7 +388,7 @@ func TestFetchFromDataSequences(t *testing.T) { } func TestFetchFromDataUids(t *testing.T) { - runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, _ *testSession, _ string, _ imap.LabelID) { + runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, _ *testSession, _ string, _ imap.MailboxID) { // Remove a couple of messages require.NoError(t, client.Store(createSeqSet("20:29,50:60,90"), goimap.AddFlags, []interface{}{goimap.DeletedFlag}, nil)) require.NoError(t, client.Expunge(nil)) diff --git a/tests/full_state_test.go b/tests/full_state_test.go index df4a7f65..af83393c 100644 --- a/tests/full_state_test.go +++ b/tests/full_state_test.go @@ -183,7 +183,7 @@ func TestReceptionOnIdle(t *testing.T) { * Either delete it, Archive it or put it as unseen. */ func TestMorningFiltering(t *testing.T) { - runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestClientWithData(t, defaultServerOptions(t), func(client *client.Client, s *testSession, mbox string, mboxID imap.MailboxID) { require.NoError(t, client.Create("ReadLater")) require.NoError(t, client.Create("Archive")) diff --git a/tests/idle_test.go b/tests/idle_test.go index 0d86d413..6d2656f6 100644 --- a/tests/idle_test.go +++ b/tests/idle_test.go @@ -35,7 +35,7 @@ func TestIDLEExistsUpdates(t *testing.T) { } func TestIDLEPendingUpdates(t *testing.T) { - runManyToOneTestWithData(t, defaultServerOptions(t), []int{1, 2}, func(c map[int]*testConnection, s *testSession, _ string, _ imap.LabelID) { + runManyToOneTestWithData(t, defaultServerOptions(t), []int{1, 2}, func(c map[int]*testConnection, s *testSession, _ string, _ imap.MailboxID) { c[1].C("A001 select INBOX").OK("A001") // Generate some pending updates. diff --git a/tests/move_test.go b/tests/move_test.go index a39aeaba..31efe1a9 100644 --- a/tests/move_test.go +++ b/tests/move_test.go @@ -8,7 +8,7 @@ import ( ) func TestMove(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // There are 100 messages in the origin and no messages in the destination. c.Cf(`A001 status %v (messages)`, mbox).Sxe(`MESSAGES 100`).OK(`A001`) c.C(`A002 status inbox (messages)`).Sxe(`MESSAGES 0`).OK(`A002`) @@ -36,7 +36,7 @@ func TestMove(t *testing.T) { } func TestMoveTryCreate(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // There are 100 messages in the origin. c.Cf(`A001 status %v (messages)`, mbox).Sxe(`MESSAGES 100`).OK(`A001`) @@ -51,7 +51,7 @@ func TestMoveTryCreate(t *testing.T) { } func TestMoveNonExistent(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // MOVE some of the messages out of the mailbox. c.C(`A001 move 1:24,76:100 inbox`).OK(`A001`) @@ -75,7 +75,7 @@ func TestMoveNonExistent(t *testing.T) { } func TestMoveBackAndForth(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // There are 100 messages in the origin and no messages in the destination. c.Cf(`A001 status %v (messages)`, mbox).Sxe(`MESSAGES 100`).OK(`A001`) c.C(`A002 status inbox (messages)`).Sxe(`MESSAGES 0`).OK(`A002`) @@ -205,7 +205,7 @@ func TestMoveDuplicate(t *testing.T) { } func TestConcurrency(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`tag create archive`).OK(`tag`) for i := 0; i < 100; i++ { diff --git a/tests/parallel_test.go b/tests/parallel_test.go index 801f2e0e..6c0e7991 100644 --- a/tests/parallel_test.go +++ b/tests/parallel_test.go @@ -16,7 +16,7 @@ func TestSelectWhileSyncing(t *testing.T) { mailboxNames := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"} // Collect the mailbox IDs as they're created. - mailboxIDs := xslices.Map(mailboxNames, func(name string) imap.LabelID { + mailboxIDs := xslices.Map(mailboxNames, func(name string) imap.MailboxID { return s.mailboxCreated("user", []string{name}) }) diff --git a/tests/path_config_test.go b/tests/path_config_test.go index bb686652..349f7af5 100644 --- a/tests/path_config_test.go +++ b/tests/path_config_test.go @@ -5,7 +5,7 @@ import "testing" func TestPathConfig_ProtonPathConfig(t *testing.T) { runOneToOneTestWithAuth(t, defaultServerOptions(t), func(c *testConnection, s *testSession) { s.setFolderPrefix("user", "Folders") - s.setLabelPrefix("user", "Labels") + s.setMailboxPrefix("user", "Labels") c.C(`A001 CREATE Folders/TestFolder`) c.Sx(`A001 OK`) @@ -64,7 +64,7 @@ func TestPathConfig_ProtonPathConfig(t *testing.T) { func TestPathConfig_DotDelimiter(t *testing.T) { runOneToOneTestWithAuth(t, defaultServerOptions(t, withDelimiter(".")), func(c *testConnection, s *testSession) { s.setFolderPrefix("user", "Folders") - s.setLabelPrefix("user", "Labels") + s.setMailboxPrefix("user", "Labels") c.C(`A001 CREATE Folders.TestFolder`) c.Sx(`A001 OK`) diff --git a/tests/remote_test.go b/tests/remote_test.go index 3ab39f01..5f90b669 100644 --- a/tests/remote_test.go +++ b/tests/remote_test.go @@ -7,7 +7,7 @@ import ( func TestRemoteCopy(t *testing.T) { runOneToOneTestWithAuth(t, defaultServerOptions(t), func(c *testConnection, s *testSession) { s.setFolderPrefix("user", "Folders") - s.setLabelPrefix("user", "Labels") + s.setMailboxPrefix("user", "Labels") // Create two exclusive mailboxes, one with 100 messages. s.mailboxCreated("user", []string{"Folders", "mbox1"}, "testdata/dovecot-crlf") diff --git a/tests/rename_test.go b/tests/rename_test.go index b9569431..0ec11d6c 100644 --- a/tests/rename_test.go +++ b/tests/rename_test.go @@ -105,7 +105,7 @@ func TestRenameBadHierarchy(t *testing.T) { } func TestRenameInbox(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap2.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap2.MailboxID) { // Put all the 100 messages into the inbox. c.C("tag move 1:* inbox").OK("tag") diff --git a/tests/run_test.go b/tests/run_test.go index e9b7bee9..4939b1c8 100644 --- a/tests/run_test.go +++ b/tests/run_test.go @@ -30,10 +30,10 @@ func runOneToOneTestWithAuth(tb testing.TB, options *serverOptions, tests func(* // runOneToOneTestWithData runs a test with one account and one connection. A mailbox is created with test data. func runOneToOneTestWithData(tb testing.TB, options *serverOptions, - tests func(*testConnection, *testSession, string, imap.LabelID), + tests func(*testConnection, *testSession, string, imap.MailboxID), ) { runOneToOneTestWithAuth(tb, options, func(c *testConnection, s *testSession) { - withData(s, options.defaultUsername(), func(mbox string, mboxID imap.LabelID) { + withData(s, options.defaultUsername(), func(mbox string, mboxID imap.MailboxID) { withTag(func(tag string) { c.Cf("%v select %v", tag, mbox).OK(tag) }) tests(c, s, mbox, mboxID) @@ -65,10 +65,10 @@ func runManyToOneTestWithAuth(tb testing.TB, options *serverOptions, // runManyToOneTestWithData runs a test with one account and multiple connections. Apply mailbox is created with test data. func runManyToOneTestWithData(tb testing.TB, options *serverOptions, - connIDs []int, tests func(map[int]*testConnection, *testSession, string, imap.LabelID), + connIDs []int, tests func(map[int]*testConnection, *testSession, string, imap.MailboxID), ) { runManyToOneTestWithAuth(tb, options, connIDs, func(c map[int]*testConnection, s *testSession) { - withData(s, options.defaultUsername(), func(mbox string, mboxID imap.LabelID) { + withData(s, options.defaultUsername(), func(mbox string, mboxID imap.MailboxID) { for _, c := range c { withTag(func(tag string) { c.Cf("%v select %v", tag, mbox).OK(tag) }) } @@ -114,9 +114,9 @@ func runOneToOneTestClientWithAuth(tb testing.TB, options *serverOptions, test f } // runOneToOneTestClientWithData runs a test with one account and one connection using an imap client. Apply mailbox is created with test data. -func runOneToOneTestClientWithData(tb testing.TB, options *serverOptions, test func(*client.Client, *testSession, string, imap.LabelID)) { +func runOneToOneTestClientWithData(tb testing.TB, options *serverOptions, test func(*client.Client, *testSession, string, imap.MailboxID)) { runOneToOneTestClientWithAuth(tb, options, func(client *client.Client, s *testSession) { - withData(s, options.defaultUsername(), func(mbox string, mboxID imap.LabelID) { + withData(s, options.defaultUsername(), func(mbox string, mboxID imap.MailboxID) { _, err := client.Select(mbox, false) require.NoError(s.tb, err) test(client, s, mbox, mboxID) diff --git a/tests/search_test.go b/tests/search_test.go index 030466b9..b1dbdaea 100644 --- a/tests/search_test.go +++ b/tests/search_test.go @@ -40,7 +40,7 @@ func TestSearchCharSetISO88591(t *testing.T) { } func TestSearchCharSetASCII(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C("A001 search CHARSET US-ASCII TEXT foo") c.S("* SEARCH 75") c.OK("A001") @@ -48,13 +48,13 @@ func TestSearchCharSetASCII(t *testing.T) { } func TestSearchCharSetInvalid(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C("A001 search CHARSET invalid-charset TEXT foo").NO("A001", "BADCHARSET") }) } func TestSearchAll(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C("A001 search all") c.S("* SEARCH " + seq(1, 100)) c.OK("A001") @@ -62,7 +62,7 @@ func TestSearchAll(t *testing.T) { } func TestSearchAnswered(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as answered. c.C(`A001 STORE 10,20,30,40,50 +FLAGS (\Answered)`).OK("A001") @@ -74,7 +74,7 @@ func TestSearchAnswered(t *testing.T) { } func TestSearchBcc(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search bcc "dovecot@procontrol.fi"`) c.S("* SEARCH 49 50") c.OK("A001") @@ -87,7 +87,7 @@ func TestSearchBcc(t *testing.T) { } func TestSearchBefore(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // None c.C(`A001 search before 13-Aug-1982`) c.S("* SEARCH") @@ -106,7 +106,7 @@ func TestSearchBefore(t *testing.T) { } func TestSearchBody(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search body "Content-Length saves just the size of mail body"`) c.S("* SEARCH 50") c.OK("A001") @@ -119,7 +119,7 @@ func TestSearchBody(t *testing.T) { } func TestSearchCc(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search cc "Dovecot Mailinglist "`) c.S("* SEARCH 53 55 60") c.OK("A001") @@ -132,7 +132,7 @@ func TestSearchCc(t *testing.T) { } func TestSearchDeleted(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as deleted. c.C(`A001 STORE 10,20,30,40,50 +FLAGS (\Deleted)`).OK("A001") @@ -144,7 +144,7 @@ func TestSearchDeleted(t *testing.T) { } func TestSearchDraft(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as draft. c.C(`A001 STORE 10,20,30,40,50 +FLAGS (\Draft)`).OK("A001") @@ -156,7 +156,7 @@ func TestSearchDraft(t *testing.T) { } func TestSearchFlagged(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as flagged. c.C(`A001 STORE 10,20,30,40,50 +FLAGS (\Flagged)`).OK("A001") @@ -168,7 +168,7 @@ func TestSearchFlagged(t *testing.T) { } func TestSearchFrom(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search from "\"Vanessa Lintner\" "`) c.S("* SEARCH 5") c.OK("A001") @@ -184,7 +184,7 @@ func TestSearchFrom(t *testing.T) { } func TestSearchHeader(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search header Message-ID "<20020723193923.J22431@irccrew.org>"`) c.S("* SEARCH 1") c.OK("A001") @@ -200,7 +200,7 @@ func TestSearchHeader(t *testing.T) { } func TestSearchKeyword(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as with a custom flag. c.C(`A001 STORE 10,20,30,40,50 +FLAGS (my-special-flag)`).OK("A001") @@ -212,7 +212,7 @@ func TestSearchKeyword(t *testing.T) { } func TestSearchLarger(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C("A001 search larger 9500") c.S("* SEARCH 47 48") c.OK("A001") @@ -220,7 +220,7 @@ func TestSearchLarger(t *testing.T) { } func TestSearchNew(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially all messages are recent and none are seen. Thus they are all new. c.C("A001 search new") c.S("* SEARCH " + seq(1, 100)) @@ -237,7 +237,7 @@ func TestSearchNew(t *testing.T) { } func TestSearchNot(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as deleted. c.C(`A001 STORE 50:* +FLAGS (\Deleted)`).OK("A001") @@ -254,7 +254,7 @@ func TestSearchNot(t *testing.T) { } func TestSearchOld(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially all messages are recent so none are old. c.C("A001 search old") c.S("* SEARCH") @@ -283,7 +283,7 @@ func TestSearchOld(t *testing.T) { } func TestSearchOn(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // None c.C(`A001 search on 13-Aug-1982`) c.S("* SEARCH") @@ -304,7 +304,7 @@ func TestSearchOn(t *testing.T) { func TestSearchSentOnAndOn(t *testing.T) { // Test search senton/on when internal date (e.g. 11-Aug-2002) and // header date (10-Aug-2002) are different. - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search on 10-Aug-2002`) c.S("* SEARCH") c.OK("A001") @@ -324,7 +324,7 @@ func TestSearchSentOnAndOn(t *testing.T) { } func TestSearchOr(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as deleted. c.C(`A001 STORE 1:30 +FLAGS (\Deleted)`).OK("A001") @@ -362,7 +362,7 @@ func TestSearchOr(t *testing.T) { } func TestSearchRecent(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially all messages are recent. c.C("A001 search recent") c.S("* SEARCH " + seq(1, 100)) @@ -387,7 +387,7 @@ func TestSearchRecent(t *testing.T) { } func TestSearchSeen(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially no messages are seen. c.C("A001 search seen") c.S("* SEARCH") @@ -404,7 +404,7 @@ func TestSearchSeen(t *testing.T) { } func TestSearchSentBefore(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search sentbefore 10-Aug-2002`) c.S("* SEARCH " + seq(1, 18)) c.OK("A001") @@ -429,7 +429,7 @@ func TestSearchSentSinceAndSentBefore(t *testing.T) { } func TestSearchSentOn(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search senton 22-Aug-2002`) c.S("* SEARCH 21") c.OK("A001") @@ -437,7 +437,7 @@ func TestSearchSentOn(t *testing.T) { } func TestSearchSentSince(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search sentsince 13-Nov-2002`) c.S("* SEARCH " + seq(93, 100)) c.OK("A001") @@ -445,7 +445,7 @@ func TestSearchSentSince(t *testing.T) { } func TestSearchSince(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // None c.C(`A001 search since 13-Aug-2200`) c.S("* SEARCH") @@ -464,7 +464,7 @@ func TestSearchSince(t *testing.T) { } func TestSearchSmaller(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C("A001 search smaller 1250") c.S("* SEARCH 1 8 83") c.OK("A001") @@ -472,7 +472,7 @@ func TestSearchSmaller(t *testing.T) { } func TestSearchSubject(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search subject "first test mail"`) c.S("* SEARCH 1") c.OK("A001") @@ -493,7 +493,7 @@ func TestSearchSubject(t *testing.T) { } func TestSearchText(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Search something from the header. c.C(`A001 search text "Message-ID: <006701c24183$c7f10d60$0200a8c0@eero>"`) c.S("* SEARCH 20") @@ -512,7 +512,7 @@ func TestSearchText(t *testing.T) { } func TestSearchTo(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search to "Timo Sirainen "`) c.S("* SEARCH 49") c.OK("A001") @@ -524,7 +524,7 @@ func TestSearchTo(t *testing.T) { } func TestUIDSearchTo(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Remove some messages to ensure sequence doesn't match uid c.C(`A002 STORE 10,20,30,40,50 +FLAGS (\DELETED)`).OK("A002") c.C(`A003 EXPUNGE`).OK("A003") @@ -536,7 +536,7 @@ func TestUIDSearchTo(t *testing.T) { } func TestSearchUID(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search uid 1`) c.S("* SEARCH 1") c.OK("A001") @@ -556,7 +556,7 @@ func TestSearchUID(t *testing.T) { } func TestSearchUIDAfterDelete(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Remove some messages to ensure sequence doesn't match uid c.C(`A002 STORE 5,6,7 +FLAGS (\DELETED)`).OK("A002") c.C(`A003 EXPUNGE`).OK("A003") @@ -568,7 +568,7 @@ func TestSearchUIDAfterDelete(t *testing.T) { } func TestSearchUnanswered(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially, nothing is answered; everything is unanswered. c.C("A001 search unanswered") c.S("* SEARCH " + seq(1, 100)) @@ -590,7 +590,7 @@ func TestSearchUnanswered(t *testing.T) { } func TestSearchUndeleted(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially, nothing is deleted; everything is undeleted. c.C("A001 search undeleted") c.S("* SEARCH " + seq(1, 100)) @@ -612,7 +612,7 @@ func TestSearchUndeleted(t *testing.T) { } func TestSearchUndraft(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially, nothing is draft; everything is undraft. c.C("A001 search undraft") c.S("* SEARCH " + seq(1, 100)) @@ -634,7 +634,7 @@ func TestSearchUndraft(t *testing.T) { } func TestSearchUnflagged(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially, nothing is flagged; everything is unflagged. c.C("A001 search unflagged") c.S("* SEARCH " + seq(1, 100)) @@ -656,7 +656,7 @@ func TestSearchUnflagged(t *testing.T) { } func TestSearchUnkeyword(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially, nothing has a custom flag; everything is "unkeyword". c.C("A001 search unkeyword my-special-flag") c.S("* SEARCH " + seq(1, 100)) @@ -678,7 +678,7 @@ func TestSearchUnkeyword(t *testing.T) { } func TestSearchUnseen(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Initially, nothing is seen; everything is unseen. c.C("A001 search unseen") c.S("* SEARCH " + seq(1, 100)) @@ -700,7 +700,7 @@ func TestSearchUnseen(t *testing.T) { } func TestSearchSeqSet(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search 1`) c.S("* SEARCH 1") c.OK("A001") @@ -720,7 +720,7 @@ func TestSearchSeqSet(t *testing.T) { } func TestSearchSeqSetFrom(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A001 search 1:2,4:6,30:31 from "\"Vanessa Lintner\" "`) c.S("* SEARCH 5") c.OK("A001") @@ -728,7 +728,7 @@ func TestSearchSeqSetFrom(t *testing.T) { } func TestUIDSearchSeqSetFrom(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { c.C(`A002 STORE 1:4,10:80 +FLAGS (\DELETED)`).OK("A002") c.C(`A003 EXPUNGE`).OK("A003") @@ -739,7 +739,7 @@ func TestUIDSearchSeqSetFrom(t *testing.T) { } func TestSearchList(t *testing.T) { - runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.LabelID) { + runOneToOneTestWithData(t, defaultServerOptions(t), func(c *testConnection, s *testSession, mbox string, mboxID imap.MailboxID) { // Set some messages as deleted. c.C(`A001 STORE 1:30 +FLAGS (\Deleted)`).OK("A001") diff --git a/tests/server_test.go b/tests/server_test.go index 2dd60dc5..7eb39418 100644 --- a/tests/server_test.go +++ b/tests/server_test.go @@ -319,7 +319,7 @@ func withClients(tb testing.TB, s *testSession, connIDs []int, tests func(map[in } } -func withData(s *testSession, username string, tests func(string, imap.LabelID)) { +func withData(s *testSession, username string, tests func(string, imap.MailboxID)) { mbox := uuid.NewString() mboxID := s.mailboxCreated(username, []string{mbox}, "testdata/dovecot-crlf") diff --git a/tests/session_test.go b/tests/session_test.go index 700572f6..f6f278a4 100644 --- a/tests/session_test.go +++ b/tests/session_test.go @@ -26,15 +26,15 @@ type Connector interface { connector.Connector SetFolderPrefix(string) - SetLabelPrefix(string) + SetMailboxPrefix(string) MailboxCreated(imap.Mailbox) error - MailboxDeleted(imap.LabelID) error + MailboxDeleted(imap.MailboxID) error - MessageCreated(imap.Message, []byte, []imap.LabelID) error - MessagesCreated([]imap.Message, [][]byte, [][]imap.LabelID) error - MessageAdded(imap.MessageID, imap.LabelID) error - MessageRemoved(imap.MessageID, imap.LabelID) error + MessageCreated(imap.Message, []byte, []imap.MailboxID) error + MessagesCreated([]imap.Message, [][]byte, [][]imap.MailboxID) error + MessageAdded(imap.MessageID, imap.MailboxID) error + MessageRemoved(imap.MessageID, imap.MailboxID) error MessageSeen(imap.MessageID, bool) error MessageFlagged(imap.MessageID, bool) error MessageDeleted(imap.MessageID) error @@ -44,7 +44,7 @@ type Connector interface { GetLastRecordedIMAPID() imap.IMAPID - SetMailboxVisible(imap.LabelID, bool) + SetMailboxVisible(imap.MailboxID, bool) } type testSession struct { @@ -112,16 +112,16 @@ func (s *testSession) setFolderPrefix(user, prefix string) { s.conns[s.userIDs[user]].SetFolderPrefix(prefix) } -func (s *testSession) setLabelPrefix(user, prefix string) { - s.conns[s.userIDs[user]].SetLabelPrefix(prefix) +func (s *testSession) setMailboxPrefix(user, prefix string) { + s.conns[s.userIDs[user]].SetMailboxPrefix(prefix) } -func (s *testSession) mailboxCreated(user string, name []string, withData ...string) imap.LabelID { +func (s *testSession) mailboxCreated(user string, name []string, withData ...string) imap.MailboxID { return s.mailboxCreatedWithAttributes(user, name, defaultAttributes, withData...) } -func (s *testSession) mailboxCreatedWithAttributes(user string, name []string, attributes imap.FlagSet, withData ...string) imap.LabelID { - mboxID := imap.LabelID(utils.NewRandomLabelID()) +func (s *testSession) mailboxCreatedWithAttributes(user string, name []string, attributes imap.FlagSet, withData ...string) imap.MailboxID { + mboxID := imap.MailboxID(utils.NewRandomMailboxID()) require.NoError(s.tb, s.conns[s.userIDs[user]].MailboxCreated(imap.Mailbox{ ID: mboxID, @@ -140,11 +140,11 @@ func (s *testSession) mailboxCreatedWithAttributes(user string, name []string, a return mboxID } -func (s *testSession) batchMailboxCreated(user string, count int, mailboxNameGen func(number int) string) []imap.LabelID { - var mboxIDs []imap.LabelID +func (s *testSession) batchMailboxCreated(user string, count int, mailboxNameGen func(number int) string) []imap.MailboxID { + var mboxIDs []imap.MailboxID for i := 0; i < count; i++ { - mboxID := imap.LabelID(utils.NewRandomLabelID()) + mboxID := imap.MailboxID(utils.NewRandomMailboxID()) require.NoError(s.tb, s.conns[s.userIDs[user]].MailboxCreated(imap.Mailbox{ ID: mboxID, @@ -162,8 +162,8 @@ func (s *testSession) batchMailboxCreated(user string, count int, mailboxNameGen return mboxIDs } -func (s *testSession) mailboxCreatedCustom(user string, name []string, flags, permFlags, attrs imap.FlagSet) imap.LabelID { - mboxID := imap.LabelID(utils.NewRandomLabelID()) +func (s *testSession) mailboxCreatedCustom(user string, name []string, flags, permFlags, attrs imap.FlagSet) imap.MailboxID { + mboxID := imap.MailboxID(utils.NewRandomMailboxID()) require.NoError(s.tb, s.conns[s.userIDs[user]].MailboxCreated(imap.Mailbox{ ID: mboxID, @@ -178,7 +178,7 @@ func (s *testSession) mailboxCreatedCustom(user string, name []string, flags, pe return mboxID } -func (s *testSession) messageCreated(user string, mailboxID imap.LabelID, literal []byte, internalDate time.Time, flags ...string) imap.MessageID { +func (s *testSession) messageCreated(user string, mailboxID imap.MailboxID, literal []byte, internalDate time.Time, flags ...string) imap.MessageID { messageID := imap.MessageID(utils.NewRandomMessageID()) s.messageCreatedWithID(user, messageID, mailboxID, literal, internalDate, flags...) @@ -186,7 +186,7 @@ func (s *testSession) messageCreated(user string, mailboxID imap.LabelID, litera return messageID } -func (s *testSession) messageCreatedWithID(user string, messageID imap.MessageID, mailboxID imap.LabelID, literal []byte, internalDate time.Time, flags ...string) { +func (s *testSession) messageCreatedWithID(user string, messageID imap.MessageID, mailboxID imap.MailboxID, literal []byte, internalDate time.Time, flags ...string) { require.NoError(s.tb, s.conns[s.userIDs[user]].MessageCreated( imap.Message{ ID: messageID, @@ -194,13 +194,13 @@ func (s *testSession) messageCreatedWithID(user string, messageID imap.MessageID Date: internalDate, }, literal, - []imap.LabelID{mailboxID}, + []imap.MailboxID{mailboxID}, )) s.conns[s.userIDs[user]].Flush() } -func (s *testSession) batchMessageCreated(user string, mailboxID imap.LabelID, count int, createMessage func(int) ([]byte, []string)) []imap.MessageID { +func (s *testSession) batchMessageCreated(user string, mailboxID imap.MailboxID, count int, createMessage func(int) ([]byte, []string)) []imap.MessageID { return s.batchMessageCreatedWithID(user, mailboxID, count, func(i int) (imap.MessageID, []byte, []string) { messageID := imap.MessageID(utils.NewRandomMessageID()) literal, flags := createMessage(i) @@ -209,12 +209,12 @@ func (s *testSession) batchMessageCreated(user string, mailboxID imap.LabelID, c }) } -func (s *testSession) batchMessageCreatedWithID(user string, mailboxID imap.LabelID, count int, createMessage func(int) (imap.MessageID, []byte, []string)) []imap.MessageID { +func (s *testSession) batchMessageCreatedWithID(user string, mailboxID imap.MailboxID, count int, createMessage func(int) (imap.MessageID, []byte, []string)) []imap.MessageID { var messageIDs []imap.MessageID messages := make([]imap.Message, 0, count) literals := make([][]byte, 0, count) - mailboxes := make([][]imap.LabelID, 0, count) + mailboxes := make([][]imap.MailboxID, 0, count) for i := 0; i < count; i++ { messageID, literal, flags := createMessage(i) @@ -227,7 +227,7 @@ func (s *testSession) batchMessageCreatedWithID(user string, mailboxID imap.Labe literals = append(literals, literal) - mailboxes = append(mailboxes, []imap.LabelID{mailboxID}) + mailboxes = append(mailboxes, []imap.MailboxID{mailboxID}) messageIDs = append(messageIDs, messageID) } @@ -239,14 +239,14 @@ func (s *testSession) batchMessageCreatedWithID(user string, mailboxID imap.Labe return messageIDs } -func (s *testSession) messageCreatedFromFile(user string, mailboxID imap.LabelID, path string, flags ...string) imap.MessageID { +func (s *testSession) messageCreatedFromFile(user string, mailboxID imap.MailboxID, path string, flags ...string) imap.MessageID { literal, err := os.ReadFile(path) require.NoError(s.tb, err) return s.messageCreated(user, mailboxID, literal, time.Now(), flags...) } -func (s *testSession) messagesCreatedFromMBox(user string, mailboxID imap.LabelID, path string, flags ...string) { +func (s *testSession) messagesCreatedFromMBox(user string, mailboxID imap.MailboxID, path string, flags ...string) { f, err := os.Open(path) require.NoError(s.tb, err) @@ -264,13 +264,13 @@ func (s *testSession) messagesCreatedFromMBox(user string, mailboxID imap.LabelI require.NoError(s.tb, f.Close()) } -func (s *testSession) messageAdded(user string, messageID imap.MessageID, mailboxID imap.LabelID) { +func (s *testSession) messageAdded(user string, messageID imap.MessageID, mailboxID imap.MailboxID) { require.NoError(s.tb, s.conns[s.userIDs[user]].MessageAdded(messageID, mailboxID)) s.conns[s.userIDs[user]].Flush() } -func (s *testSession) messageRemoved(user string, messageID imap.MessageID, mailboxID imap.LabelID) { +func (s *testSession) messageRemoved(user string, messageID imap.MessageID, mailboxID imap.MailboxID) { require.NoError(s.tb, s.conns[s.userIDs[user]].MessageRemoved(messageID, mailboxID)) s.conns[s.userIDs[user]].Flush()