diff options
author | Kevin Kuehler <keur@xcf.berkeley.edu> | 2019-10-28 12:07:06 -0700 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2019-10-29 11:07:51 -0400 |
commit | 37f33ad65bfbfa69e620fcb0fdcff6393a251ac7 (patch) | |
tree | d80059da33a741e0581eb6a4faffdfadbab7797b /worker/imap/open.go | |
parent | 75cbf8dc0376429d6cdb6a6716b6a9b41fb681f1 (diff) |
Rework threading and add REFERENCES
* Implement a simplified version of the REFERENCES algorithm
* Remove FormatThreads function
* Instead of acting on all threads, handle each thread independently
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Diffstat (limited to 'worker/imap/open.go')
-rw-r--r-- | worker/imap/open.go | 21 |
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 |