aboutsummaryrefslogtreecommitdiff
path: root/worker/imap
diff options
context:
space:
mode:
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/open.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/worker/imap/open.go b/worker/imap/open.go
index bdb794b..1152887 100644
--- a/worker/imap/open.go
+++ b/worker/imap/open.go
@@ -64,18 +64,23 @@ func (imapw *IMAPWorker) handleDirectoryThreaded(
Error: err,
}, nil)
} else {
- aercThreads, count := convertThreads(threads)
+ root := &types.Thread{
+ Uid: 0,
+ Dummy: true,
+ }
+ aercThreads, count := convertThreads(threads, root)
+ root.Children = aercThreads
imapw.seqMap = make([]uint32, count)
imapw.worker.PostMessage(&types.DirectoryThreaded{
- Message: types.RespondTo(msg),
- Threads: aercThreads,
+ Message: types.RespondTo(msg),
+ ThreadRoot: root,
}, nil)
imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
}
}
// This sucks... TODO: find a better way to do this.
-func convertThreads(threads []*sortthread.Thread) ([]*types.Thread, int) {
+func convertThreads(threads []*sortthread.Thread, parent *types.Thread) ([]*types.Thread, int) {
if threads == nil {
return nil, 0
}
@@ -84,11 +89,13 @@ func convertThreads(threads []*sortthread.Thread) ([]*types.Thread, int) {
for i := 0; i < len(threads); i++ {
t := threads[i]
- children, childCount := convertThreads(t.Children)
conv[i] = &types.Thread{
- Uid: t.Id,
- Children: children,
+ Uid: t.Id,
+ Dummy: false,
}
+ conv[i].Parent = parent
+ children, childCount := convertThreads(t.Children, conv[i])
+ conv[i].Children = children
count += childCount + 1
}
return conv, count