aboutsummaryrefslogtreecommitdiff
path: root/worker/jmap/mboxstate.go
blob: 975d18ed51d9cd9eabe299f8801bfd4b77ca2dcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package jmap

import (
	"git.sr.ht/~rjarry/aerc/models"
	"git.sr.ht/~rockorager/go-jmap"
	"git.sr.ht/~rockorager/go-jmap/mail/email"
	"git.sr.ht/~rockorager/go-jmap/mail/mailbox"
)

type MailboxState struct {
	mbox       *mailbox.Mailbox
	dir        string
	queryState string
	filter     *email.FilterCondition
	sort       []*email.SortComparator
	uids       []uint32
}

func (s *MailboxState) FullPath(all map[jmap.ID]*MailboxState) string {
	if s.mbox == nil {
		return s.dir
	}
	if s.mbox.ParentID == "" {
		return s.mbox.Name
	}
	parent, ok := all[s.mbox.ParentID]
	if !ok {
		return s.mbox.Name
	}
	return parent.FullPath(all) + "/" + s.mbox.Name
}

var jmapRole2aerc = map[mailbox.Role]models.Role{
	mailbox.RoleAll:     models.AllRole,
	mailbox.RoleArchive: models.ArchiveRole,
	mailbox.RoleDrafts:  models.DraftsRole,
	mailbox.RoleInbox:   models.InboxRole,
	mailbox.RoleJunk:    models.JunkRole,
	mailbox.RoleSent:    models.SentRole,
	mailbox.RoleTrash:   models.TrashRole,
}