aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/open.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-08-14 16:59:11 +0200
committerRobin Jarry <robin@jarry.cc>2024-08-28 12:06:01 +0200
commit73dc39c6ee0827fc68b93af8dc438b0e1c14e929 (patch)
treeaff067600ea6326ff179447ed968b6712013b889 /worker/imap/open.go
parent2950d919a5c5a55bd0eb53d6c41f989d8b70bd55 (diff)
downloadaerc-73dc39c6ee0827fc68b93af8dc438b0e1c14e929.tar.gz
treewide: replace uint32 uids with opaque strings
Add a new models.UID type (an alias to string). Replace all occurrences of uint32 being used as message UID or thread UID with models.UID. Update all workers to only expose models.UID values and deal with the conversion internally. Only IMAP needs to convert these to uint32. All other backends already use plain strings as message identifiers, in which case no conversion is even needed. The directory tree implementation needed to be heavily refactored in order to accommodate thread UID not being usable as a list index. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker/imap/open.go')
-rw-r--r--worker/imap/open.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/worker/imap/open.go b/worker/imap/open.go
index 355709a7..b1314a4b 100644
--- a/worker/imap/open.go
+++ b/worker/imap/open.go
@@ -5,6 +5,7 @@ import (
sortthread "github.com/emersion/go-imap-sortthread"
+ "git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
)
@@ -85,9 +86,10 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
// Only initialize if we are not filtering
imapw.seqMap.Initialize(uids)
}
+
imapw.worker.PostMessage(&types.DirectoryContents{
Message: types.RespondTo(msg),
- Uids: uids,
+ Uids: models.Uint32ToUidList(uids),
}, nil)
imapw.worker.PostMessage(&types.Done{Message: types.RespondTo(msg)}, nil)
}
@@ -146,7 +148,7 @@ func (imapw *IMAPWorker) handleDirectoryThreaded(
var uids []uint32
for i := len(aercThreads) - 1; i >= 0; i-- {
aercThreads[i].Walk(func(t *types.Thread, level int, currentErr error) error { //nolint:errcheck // error indicates skipped threads
- uids = append(uids, t.Uid)
+ uids = append(uids, models.UidToUint32(t.Uid))
return nil
})
}
@@ -175,7 +177,7 @@ func convertThreads(threads []*sortthread.Thread, parent *types.Thread) ([]*type
for i := 0; i < len(threads); i++ {
t := threads[i]
conv[i] = &types.Thread{
- Uid: t.Id,
+ Uid: models.Uint32ToUid(t.Id),
}
// Set the first child node