Detect Gmail labels from All Mail mbox export

This commit is contained in:
Michal Horejsek
2020-10-08 15:03:03 +02:00
parent 719d369c2a
commit ef85c8df24
16 changed files with 461 additions and 73 deletions

View File

@ -49,11 +49,24 @@ func (p *MBOXProvider) Mailboxes(includeEmpty, includeAllMail bool) ([]Mailbox,
return nil, err
}
mailboxes := []Mailbox{}
mailboxNames := []string{}
for _, filePath := range filePaths {
fileName := filepath.Base(filePath)
mailboxName := strings.TrimSuffix(fileName, ".mbox")
mailboxNames = appendIfNew(mailboxNames, mailboxName)
labels, err := getGmailLabelsFromMboxFile(filepath.Join(p.root, filePath))
if err != nil {
log.WithError(err).Error("Failed to get gmail labels from mbox file")
continue
}
for _, label := range labels {
mailboxNames = appendIfNew(mailboxNames, label)
}
}
mailboxes := []Mailbox{}
for _, mailboxName := range mailboxNames {
mailboxes = append(mailboxes, Mailbox{
ID: "",
Name: mailboxName,
@ -61,6 +74,5 @@ func (p *MBOXProvider) Mailboxes(includeEmpty, includeAllMail bool) ([]Mailbox,
IsExclusive: false,
})
}
return mailboxes, nil
}