diff options
Diffstat (limited to 'worker/jmap')
-rw-r--r-- | worker/jmap/directories.go | 8 | ||||
-rw-r--r-- | worker/jmap/fetch.go | 22 | ||||
-rw-r--r-- | worker/jmap/jmap.go | 2 | ||||
-rw-r--r-- | worker/jmap/push.go | 5 | ||||
-rw-r--r-- | worker/jmap/set.go | 26 | ||||
-rw-r--r-- | worker/jmap/worker.go | 3 |
6 files changed, 19 insertions, 47 deletions
diff --git a/worker/jmap/directories.go b/worker/jmap/directories.go index 07bb0762..7ae79ead 100644 --- a/worker/jmap/directories.go +++ b/worker/jmap/directories.go @@ -186,9 +186,9 @@ func (w *JMAPWorker) handleFetchDirectoryContents(msg *types.FetchDirectoryConte } } - uids := make([]uint32, 0, len(contents.MessageIDs)) + uids := make([]models.UID, 0, len(contents.MessageIDs)) for _, id := range contents.MessageIDs { - uids = append(uids, w.uidStore.GetOrInsert(string(id))) + uids = append(uids, models.UID(id)) } w.w.PostMessage(&types.DirectoryContents{ Message: types.RespondTo(msg), @@ -214,9 +214,9 @@ func (w *JMAPWorker) handleSearchDirectory(msg *types.SearchDirectory) error { for _, inv := range resp.Responses { switch r := inv.Args.(type) { case *email.QueryResponse: - var uids []uint32 + var uids []models.UID for _, id := range r.IDs { - uids = append(uids, w.uidStore.GetOrInsert(string(id))) + uids = append(uids, models.UID(id)) } w.w.PostMessage(&types.SearchResults{ Message: types.RespondTo(msg), diff --git a/worker/jmap/fetch.go b/worker/jmap/fetch.go index 07579b99..3b3a8460 100644 --- a/worker/jmap/fetch.go +++ b/worker/jmap/fetch.go @@ -38,11 +38,7 @@ func (w *JMAPWorker) handleFetchMessageHeaders(msg *types.FetchMessageHeaders) e emailIdsToFetch := make([]jmap.ID, 0, len(msg.Uids)) currentEmails := make([]*email.Email, 0, len(msg.Uids)) for _, uid := range msg.Uids { - id, ok := w.uidStore.GetKey(uid) - if !ok { - return fmt.Errorf("bug: no jmap id for message uid: %v", uid) - } - jid := jmap.ID(id) + jid := jmap.ID(uid) m, err := w.cache.GetEmail(jid) if err != nil { // Message wasn't in cache; fetch it @@ -103,13 +99,9 @@ func (w *JMAPWorker) handleFetchMessageHeaders(msg *types.FetchMessageHeaders) e } func (w *JMAPWorker) handleFetchMessageBodyPart(msg *types.FetchMessageBodyPart) error { - id, ok := w.uidStore.GetKey(msg.Uid) - if !ok { - return fmt.Errorf("bug: unknown message uid %d", msg.Uid) - } - mail, err := w.cache.GetEmail(jmap.ID(id)) + mail, err := w.cache.GetEmail(jmap.ID(msg.Uid)) if err != nil { - return fmt.Errorf("bug: unknown message id %s: %w", id, err) + return fmt.Errorf("bug: unknown message id %s: %w", msg.Uid, err) } part := mail.BodyStructure @@ -159,13 +151,9 @@ func (w *JMAPWorker) handleFetchMessageBodyPart(msg *types.FetchMessageBodyPart) func (w *JMAPWorker) handleFetchFullMessages(msg *types.FetchFullMessages) error { for _, uid := range msg.Uids { - id, ok := w.uidStore.GetKey(uid) - if !ok { - return fmt.Errorf("bug: unknown message uid %d", uid) - } - mail, err := w.cache.GetEmail(jmap.ID(id)) + mail, err := w.cache.GetEmail(jmap.ID(uid)) if err != nil { - return fmt.Errorf("bug: unknown message id %s: %w", id, err) + return fmt.Errorf("bug: unknown message id %s: %w", uid, err) } buf, err := w.cache.GetBlob(mail.BlobID) if err != nil { diff --git a/worker/jmap/jmap.go b/worker/jmap/jmap.go index bb0f75f9..7320ec04 100644 --- a/worker/jmap/jmap.go +++ b/worker/jmap/jmap.go @@ -37,7 +37,7 @@ func (w *JMAPWorker) translateMsgInfo(m *email.Email) *models.MessageInfo { return &models.MessageInfo{ Envelope: env, Flags: keywordsToFlags(m.Keywords), - Uid: w.uidStore.GetOrInsert(string(m.ID)), + Uid: models.UID(m.ID), BodyStructure: translateBodyStructure(m.BodyStructure), RFC822Headers: translateJMAPHeader(m.Headers), Refs: m.References, diff --git a/worker/jmap/push.go b/worker/jmap/push.go index bc90dd77..f2a8ad45 100644 --- a/worker/jmap/push.go +++ b/worker/jmap/push.go @@ -247,10 +247,9 @@ func (w *JMAPWorker) refresh(newState jmap.TypeState) error { } if w.selectedMbox == mboxId { - uids := make([]uint32, 0, len(ids)) + uids := make([]models.UID, 0, len(ids)) for _, id := range ids { - uid := w.uidStore.GetOrInsert(string(id)) - uids = append(uids, uid) + uids = append(uids, models.UID(id)) } w.w.PostMessage(&types.DirectoryContents{ Uids: uids, diff --git a/worker/jmap/set.go b/worker/jmap/set.go index 36b23688..302314c1 100644 --- a/worker/jmap/set.go +++ b/worker/jmap/set.go @@ -10,15 +10,11 @@ import ( "git.sr.ht/~rockorager/go-jmap/mail/mailbox" ) -func (w *JMAPWorker) updateFlags(uids []uint32, flags models.Flags, enable bool) error { +func (w *JMAPWorker) updateFlags(uids []models.UID, flags models.Flags, enable bool) error { var req jmap.Request patches := make(map[jmap.ID]jmap.Patch) for _, uid := range uids { - id, ok := w.uidStore.GetKey(uid) - if !ok { - return fmt.Errorf("bug: unknown uid %d", uid) - } patch := jmap.Patch{} for kw := range flagsToKeywords(flags) { path := fmt.Sprintf("keywords/%s", kw) @@ -28,7 +24,7 @@ func (w *JMAPWorker) updateFlags(uids []uint32, flags models.Flags, enable bool) patch[path] = nil } } - patches[jmap.ID(id)] = patch + patches[jmap.ID(uid)] = patch } req.Invoke(&email.Set{ @@ -44,7 +40,7 @@ func (w *JMAPWorker) updateFlags(uids []uint32, flags models.Flags, enable bool) return checkNotUpdated(resp) } -func (w *JMAPWorker) moveCopy(uids []uint32, destDir string, deleteSrc bool) error { +func (w *JMAPWorker) moveCopy(uids []models.UID, destDir string, deleteSrc bool) error { var req jmap.Request var destMbox jmap.ID var destroy []jmap.ID @@ -62,13 +58,9 @@ func (w *JMAPWorker) moveCopy(uids []uint32, destDir string, deleteSrc bool) err for _, uid := range uids { dest := destMbox - id, ok := w.uidStore.GetKey(uid) - if !ok { - return fmt.Errorf("bug: unknown uid %d", uid) - } - mail, err := w.cache.GetEmail(jmap.ID(id)) + mail, err := w.cache.GetEmail(jmap.ID(uid)) if err != nil { - return fmt.Errorf("bug: unknown message id %s: %w", id, err) + return fmt.Errorf("bug: unknown message id %s: %w", uid, err) } patch := w.moveCopyPatch(mail, dest, deleteSrc) @@ -76,7 +68,7 @@ func (w *JMAPWorker) moveCopy(uids []uint32, destDir string, deleteSrc bool) err destroy = append(destroy, mail.ID) w.w.Debugf("destroying <%s>", mail.MessageID[0]) } else { - patches[jmap.ID(id)] = patch + patches[jmap.ID(uid)] = patch } } @@ -161,11 +153,7 @@ func (w *JMAPWorker) handleModifyLabels(msg *types.ModifyLabels) error { patches := make(map[jmap.ID]jmap.Patch) for _, uid := range msg.Uids { - id, ok := w.uidStore.GetKey(uid) - if !ok { - return fmt.Errorf("bug: unknown uid %d", uid) - } - patches[jmap.ID(id)] = patch + patches[jmap.ID(uid)] = patch } req.Invoke(&email.Set{ diff --git a/worker/jmap/worker.go b/worker/jmap/worker.go index 67553272..58883e1e 100644 --- a/worker/jmap/worker.go +++ b/worker/jmap/worker.go @@ -6,7 +6,6 @@ import ( "time" "git.sr.ht/~rjarry/aerc/config" - "git.sr.ht/~rjarry/aerc/lib/uidstore" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/handlers" "git.sr.ht/~rjarry/aerc/worker/jmap/cache" @@ -47,7 +46,6 @@ type JMAPWorker struct { mbox2dir map[jmap.ID]string roles map[mailbox.Role]jmap.ID identities map[string]*identity.Identity - uidStore *uidstore.Store changes chan jmap.TypeState stop chan struct{} @@ -56,7 +54,6 @@ type JMAPWorker struct { func NewJMAPWorker(worker *types.Worker) (types.Backend, error) { return &JMAPWorker{ w: worker, - uidStore: uidstore.NewStore(), roles: make(map[mailbox.Role]jmap.ID), dir2mbox: make(map[string]jmap.ID), mbox2dir: make(map[jmap.ID]string), |