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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
package db
import (
"fmt"
"time"
"github.com/ProtonMail/gluon/imap"
)
type MailboxIDPair struct {
InternalID imap.InternalMailboxID
RemoteID imap.MailboxID
}
func (m *MailboxIDPair) String() string {
return fmt.Sprintf("%v::%v", m.InternalID, m.RemoteID)
}
type MessageIDPair struct {
InternalID imap.InternalMessageID
RemoteID imap.MessageID
}
func (m *MessageIDPair) String() string {
return fmt.Sprintf("%v::%v", m.InternalID, m.RemoteID)
}
func NewMailboxIDPair(mbox *Mailbox) MailboxIDPair {
return MailboxIDPair{
InternalID: mbox.ID,
RemoteID: mbox.RemoteID,
}
}
func NewMailboxIDPairWithoutRemote(internalID imap.InternalMailboxID) MailboxIDPair {
return MailboxIDPair{
InternalID: internalID,
RemoteID: "",
}
}
func NewMessageIDPair(msg *Message) MessageIDPair {
return MessageIDPair{
InternalID: msg.ID,
RemoteID: msg.RemoteID,
}
}
func SplitMessageIDPairSlice(s []MessageIDPair) ([]imap.InternalMessageID, []imap.MessageID) {
l := len(s)
internalMessageIDs := make([]imap.InternalMessageID, 0, l)
remoteMessageIDs := make([]imap.MessageID, 0, l)
for _, v := range s {
internalMessageIDs = append(internalMessageIDs, v.InternalID)
remoteMessageIDs = append(remoteMessageIDs, v.RemoteID)
}
return internalMessageIDs, remoteMessageIDs
}
func SplitMailboxIDPairSlice(s []MailboxIDPair) ([]imap.InternalMailboxID, []imap.MailboxID) {
l := len(s)
internalMailboxIDs := make([]imap.InternalMailboxID, 0, l)
mailboxIDs := make([]imap.MailboxID, 0, l)
for _, v := range s {
internalMailboxIDs = append(internalMailboxIDs, v.InternalID)
mailboxIDs = append(mailboxIDs, v.RemoteID)
}
return internalMailboxIDs, mailboxIDs
}
type MailboxFlag struct {
ID int
Value string
}
type MailboxAttr struct {
ID int
Value string
}
type Mailbox struct {
ID imap.InternalMailboxID
RemoteID imap.MailboxID
Name string
UIDValidity imap.UID
Subscribed bool
}
type MailboxWithAttr struct {
Mailbox
Attributes imap.FlagSet
}
type Message struct {
ID imap.InternalMessageID
RemoteID imap.MessageID
Date time.Time
Size int
Body string
BodyStructure string
Envelope string
Deleted bool
}
type MessageWithFlags struct {
Message
Flags imap.FlagSet
}
type UID struct {
UID imap.UID
Deleted bool
Recent bool
}
type DeletedSubscription struct {
Name string
RemoteID imap.MailboxID
}
|