Other: Update Gluon to v0.13.0

This commit is contained in:
Leander Beernaert
2022-10-20 11:25:42 +02:00
committed by James Houlahan
parent d47b5b99c5
commit ca132881f9
6 changed files with 37 additions and 31 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.18
require ( require (
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557 github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557
github.com/Masterminds/semver/v3 v3.1.1 github.com/Masterminds/semver/v3 v3.1.1
github.com/ProtonMail/gluon v0.12.0 github.com/ProtonMail/gluon v0.13.0
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a
github.com/ProtonMail/go-rfc5322 v0.11.0 github.com/ProtonMail/go-rfc5322 v0.11.0
github.com/ProtonMail/gopenpgp/v2 v2.4.10 github.com/ProtonMail/gopenpgp/v2 v2.4.10

2
go.sum
View File

@ -30,6 +30,8 @@ github.com/ProtonMail/docker-credential-helpers v1.1.0 h1:+kvUIpwWcbtP3WFv5sSvkF
github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g= github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g=
github.com/ProtonMail/gluon v0.12.0 h1:90kirLwZNh91B+Mhc8fLGt/HMnhSJD2XUedwKVCs5bQ= github.com/ProtonMail/gluon v0.12.0 h1:90kirLwZNh91B+Mhc8fLGt/HMnhSJD2XUedwKVCs5bQ=
github.com/ProtonMail/gluon v0.12.0/go.mod h1:XW/gcr4jErc5bX5yMqkUq3U+AucC2QZHJ5L231k3Nw4= github.com/ProtonMail/gluon v0.12.0/go.mod h1:XW/gcr4jErc5bX5yMqkUq3U+AucC2QZHJ5L231k3Nw4=
github.com/ProtonMail/gluon v0.13.0 h1:WgL32KvMcanomDP3Z0mSs61QYmNHAtSEbVlimD5seiU=
github.com/ProtonMail/gluon v0.13.0/go.mod h1:XW/gcr4jErc5bX5yMqkUq3U+AucC2QZHJ5L231k3Nw4=
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a h1:D+aZah+k14Gn6kmL7eKxoo/4Dr/lK3ChBcwce2+SQP4= github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a h1:D+aZah+k14Gn6kmL7eKxoo/4Dr/lK3ChBcwce2+SQP4=
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4= github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=

View File

@ -195,7 +195,7 @@ func (user *User) handleLabelEvents(ctx context.Context, labelEvents []liteapi.L
func (user *User) handleCreateLabelEvent(_ context.Context, event liteapi.LabelEvent) error { //nolint:unparam func (user *User) handleCreateLabelEvent(_ context.Context, event liteapi.LabelEvent) error { //nolint:unparam
user.updateCh.IterValues(func(updateCh *queue.QueuedChannel[imap.Update]) { user.updateCh.IterValues(func(updateCh *queue.QueuedChannel[imap.Update]) {
updateCh.Enqueue(newMailboxCreatedUpdate(imap.LabelID(event.ID), getMailboxName(event.Label))) updateCh.Enqueue(newMailboxCreatedUpdate(imap.MailboxID(event.ID), getMailboxName(event.Label)))
}) })
return nil return nil
@ -203,7 +203,7 @@ func (user *User) handleCreateLabelEvent(_ context.Context, event liteapi.LabelE
func (user *User) handleUpdateLabelEvent(_ context.Context, event liteapi.LabelEvent) error { //nolint:unparam func (user *User) handleUpdateLabelEvent(_ context.Context, event liteapi.LabelEvent) error { //nolint:unparam
user.updateCh.IterValues(func(updateCh *queue.QueuedChannel[imap.Update]) { user.updateCh.IterValues(func(updateCh *queue.QueuedChannel[imap.Update]) {
updateCh.Enqueue(imap.NewMailboxUpdated(imap.LabelID(event.ID), getMailboxName(event.Label))) updateCh.Enqueue(imap.NewMailboxUpdated(imap.MailboxID(event.ID), getMailboxName(event.Label)))
}) })
return nil return nil
@ -211,7 +211,7 @@ func (user *User) handleUpdateLabelEvent(_ context.Context, event liteapi.LabelE
func (user *User) handleDeleteLabelEvent(_ context.Context, event liteapi.LabelEvent) error { //nolint:unparam func (user *User) handleDeleteLabelEvent(_ context.Context, event liteapi.LabelEvent) error { //nolint:unparam
user.updateCh.IterValues(func(updateCh *queue.QueuedChannel[imap.Update]) { user.updateCh.IterValues(func(updateCh *queue.QueuedChannel[imap.Update]) {
updateCh.Enqueue(imap.NewMailboxDeleted(imap.LabelID(event.ID))) updateCh.Enqueue(imap.NewMailboxDeleted(imap.MailboxID(event.ID)))
}) })
return nil return nil
@ -263,9 +263,9 @@ func (user *User) handleCreateMessageEvent(ctx context.Context, event liteapi.Me
} }
func (user *User) handleUpdateMessageEvent(_ context.Context, event liteapi.MessageEvent) error { //nolint:unparam func (user *User) handleUpdateMessageEvent(_ context.Context, event liteapi.MessageEvent) error { //nolint:unparam
update := imap.NewMessageLabelsUpdated( update := imap.NewMessageMailboxesUpdated(
imap.MessageID(event.ID), imap.MessageID(event.ID),
mapTo[string, imap.LabelID](xslices.Filter(event.Message.LabelIDs, wantLabelID)), mapTo[string, imap.MailboxID](xslices.Filter(event.Message.LabelIDs, wantLabelID)),
event.Message.Seen(), event.Message.Seen(),
event.Message.Starred(), event.Message.Starred(),
) )

View File

@ -78,8 +78,8 @@ func (conn *imapConnector) Authorize(username string, password []byte) bool {
return true return true
} }
// GetLabel returns information about the label with the given ID. // GetMailbox returns information about the label with the given ID.
func (conn *imapConnector) GetLabel(ctx context.Context, labelID imap.LabelID) (imap.Mailbox, error) { func (conn *imapConnector) GetMailbox(ctx context.Context, labelID imap.MailboxID) (imap.Mailbox, error) {
label, err := conn.client.GetLabel(ctx, string(labelID), liteapi.LabelTypeLabel, liteapi.LabelTypeFolder) label, err := conn.client.GetLabel(ctx, string(labelID), liteapi.LabelTypeLabel, liteapi.LabelTypeFolder)
if err != nil { if err != nil {
return imap.Mailbox{}, err return imap.Mailbox{}, err
@ -103,7 +103,7 @@ func (conn *imapConnector) GetLabel(ctx context.Context, labelID imap.LabelID) (
} }
return imap.Mailbox{ return imap.Mailbox{
ID: imap.LabelID(label.ID), ID: imap.MailboxID(label.ID),
Name: name, Name: name,
Flags: conn.flags, Flags: conn.flags,
PermanentFlags: conn.permFlags, PermanentFlags: conn.permFlags,
@ -111,8 +111,8 @@ func (conn *imapConnector) GetLabel(ctx context.Context, labelID imap.LabelID) (
}, nil }, nil
} }
// CreateLabel creates a label with the given name. // CreateMailbox creates a label with the given name.
func (conn *imapConnector) CreateLabel(ctx context.Context, name []string) (imap.Mailbox, error) { func (conn *imapConnector) CreateMailbox(ctx context.Context, name []string) (imap.Mailbox, error) {
if len(name) != 2 { if len(name) != 2 {
panic("subfolders are unsupported") panic("subfolders are unsupported")
} }
@ -135,7 +135,7 @@ func (conn *imapConnector) CreateLabel(ctx context.Context, name []string) (imap
} }
return imap.Mailbox{ return imap.Mailbox{
ID: imap.LabelID(label.ID), ID: imap.MailboxID(label.ID),
Name: name, Name: name,
Flags: conn.flags, Flags: conn.flags,
PermanentFlags: conn.permFlags, PermanentFlags: conn.permFlags,
@ -143,8 +143,8 @@ func (conn *imapConnector) CreateLabel(ctx context.Context, name []string) (imap
}, nil }, nil
} }
// UpdateLabel sets the name of the label with the given ID. // UpdateMailboxName sets the name of the label with the given ID.
func (conn *imapConnector) UpdateLabel(ctx context.Context, labelID imap.LabelID, newName []string) error { func (conn *imapConnector) UpdateMailboxName(ctx context.Context, labelID imap.MailboxID, newName []string) error {
if len(newName) != 2 { if len(newName) != 2 {
panic("subfolders are unsupported") panic("subfolders are unsupported")
} }
@ -182,13 +182,13 @@ func (conn *imapConnector) UpdateLabel(ctx context.Context, labelID imap.LabelID
return nil return nil
} }
// DeleteLabel deletes the label with the given ID. // DeleteMailbox deletes the label with the given ID.
func (conn *imapConnector) DeleteLabel(ctx context.Context, labelID imap.LabelID) error { func (conn *imapConnector) DeleteMailbox(ctx context.Context, labelID imap.MailboxID) error {
return conn.client.DeleteLabel(ctx, string(labelID)) return conn.client.DeleteLabel(ctx, string(labelID))
} }
// GetMessage returns the message with the given ID. // GetMessage returns the message with the given ID.
func (conn *imapConnector) GetMessage(ctx context.Context, messageID imap.MessageID) (imap.Message, []imap.LabelID, error) { func (conn *imapConnector) GetMessage(ctx context.Context, messageID imap.MessageID) (imap.Message, []imap.MailboxID, error) {
message, err := conn.client.GetMessage(ctx, string(messageID)) message, err := conn.client.GetMessage(ctx, string(messageID))
if err != nil { if err != nil {
return imap.Message{}, nil, err return imap.Message{}, nil, err
@ -208,13 +208,13 @@ func (conn *imapConnector) GetMessage(ctx context.Context, messageID imap.Messag
ID: imap.MessageID(message.ID), ID: imap.MessageID(message.ID),
Flags: flags, Flags: flags,
Date: time.Unix(message.Time, 0), Date: time.Unix(message.Time, 0),
}, mapTo[string, imap.LabelID](message.LabelIDs), nil }, mapTo[string, imap.MailboxID](message.LabelIDs), nil
} }
// CreateMessage creates a new message on the remote. // CreateMessage creates a new message on the remote.
func (conn *imapConnector) CreateMessage( func (conn *imapConnector) CreateMessage(
ctx context.Context, ctx context.Context,
labelID imap.LabelID, labelID imap.MailboxID,
literal []byte, literal []byte,
flags imap.FlagSet, flags imap.FlagSet,
date time.Time, date time.Time,
@ -267,18 +267,18 @@ func (conn *imapConnector) CreateMessage(
}, literal, nil }, literal, nil
} }
// LabelMessages labels the given messages with the given label ID. // AddMessagesToMailbox labels the given messages with the given label ID.
func (conn *imapConnector) LabelMessages(ctx context.Context, messageIDs []imap.MessageID, labelID imap.LabelID) error { func (conn *imapConnector) AddMessagesToMailbox(ctx context.Context, messageIDs []imap.MessageID, labelID imap.MailboxID) error {
return conn.client.LabelMessages(ctx, mapTo[imap.MessageID, string](messageIDs), string(labelID)) return conn.client.LabelMessages(ctx, mapTo[imap.MessageID, string](messageIDs), string(labelID))
} }
// UnlabelMessages unlabels the given messages with the given label ID. // RemoveMessagesFromMailbox unlabels the given messages with the given label ID.
func (conn *imapConnector) UnlabelMessages(ctx context.Context, messageIDs []imap.MessageID, labelID imap.LabelID) error { func (conn *imapConnector) RemoveMessagesFromMailbox(ctx context.Context, messageIDs []imap.MessageID, labelID imap.MailboxID) error {
return conn.client.UnlabelMessages(ctx, mapTo[imap.MessageID, string](messageIDs), string(labelID)) return conn.client.UnlabelMessages(ctx, mapTo[imap.MessageID, string](messageIDs), string(labelID))
} }
// MoveMessages removes the given messages from one label and adds them to the other label. // MoveMessages removes the given messages from one label and adds them to the other label.
func (conn *imapConnector) MoveMessages(ctx context.Context, messageIDs []imap.MessageID, labelFromID imap.LabelID, labelToID imap.LabelID) error { func (conn *imapConnector) MoveMessages(ctx context.Context, messageIDs []imap.MessageID, labelFromID imap.MailboxID, labelToID imap.MailboxID) error {
if err := conn.client.LabelMessages(ctx, mapTo[imap.MessageID, string](messageIDs), string(labelToID)); err != nil { if err := conn.client.LabelMessages(ctx, mapTo[imap.MessageID, string](messageIDs), string(labelToID)); err != nil {
return fmt.Errorf("labeling messages: %w", err) return fmt.Errorf("labeling messages: %w", err)
} }
@ -335,3 +335,7 @@ func (conn *imapConnector) SetUIDValidity(uidValidity imap.UID) error {
func (conn *imapConnector) Close(ctx context.Context) error { func (conn *imapConnector) Close(ctx context.Context) error {
return nil return nil
} }
func (conn *imapConnector) IsMailboxVisible(_ context.Context, _ imap.MailboxID) bool {
return true
}

View File

@ -91,7 +91,7 @@ func syncLabels(ctx context.Context, client *liteapi.Client, updateCh ...*queue.
for _, label := range xslices.Filter(system, func(label liteapi.Label) bool { return wantLabelID(label.ID) }) { for _, label := range xslices.Filter(system, func(label liteapi.Label) bool { return wantLabelID(label.ID) }) {
for _, updateCh := range updateCh { for _, updateCh := range updateCh {
updateCh.Enqueue(newSystemMailboxCreatedUpdate(imap.LabelID(label.ID), label.Name)) updateCh.Enqueue(newSystemMailboxCreatedUpdate(imap.MailboxID(label.ID), label.Name))
} }
} }
@ -110,7 +110,7 @@ func syncLabels(ctx context.Context, client *liteapi.Client, updateCh ...*queue.
for _, folder := range folders { for _, folder := range folders {
for _, updateCh := range updateCh { for _, updateCh := range updateCh {
updateCh.Enqueue(newMailboxCreatedUpdate(imap.LabelID(folder.ID), getMailboxName(folder))) updateCh.Enqueue(newMailboxCreatedUpdate(imap.MailboxID(folder.ID), getMailboxName(folder)))
} }
} }
@ -122,7 +122,7 @@ func syncLabels(ctx context.Context, client *liteapi.Client, updateCh ...*queue.
for _, label := range labels { for _, label := range labels {
for _, updateCh := range updateCh { for _, updateCh := range updateCh {
updateCh.Enqueue(newMailboxCreatedUpdate(imap.LabelID(label.ID), getMailboxName(label))) updateCh.Enqueue(newMailboxCreatedUpdate(imap.MailboxID(label.ID), getMailboxName(label)))
} }
} }
@ -205,7 +205,7 @@ func syncMessages( //nolint:funlen
}) })
} }
func newSystemMailboxCreatedUpdate(labelID imap.LabelID, labelName string) *imap.MailboxCreated { func newSystemMailboxCreatedUpdate(labelID imap.MailboxID, labelName string) *imap.MailboxCreated {
if strings.EqualFold(labelName, imap.Inbox) { if strings.EqualFold(labelName, imap.Inbox) {
labelName = imap.Inbox labelName = imap.Inbox
} }
@ -221,7 +221,7 @@ func newSystemMailboxCreatedUpdate(labelID imap.LabelID, labelName string) *imap
func newPlaceHolderMailboxCreatedUpdate(labelName string) *imap.MailboxCreated { func newPlaceHolderMailboxCreatedUpdate(labelName string) *imap.MailboxCreated {
return imap.NewMailboxCreated(imap.Mailbox{ return imap.NewMailboxCreated(imap.Mailbox{
ID: imap.LabelID(uuid.NewString()), ID: imap.MailboxID(uuid.NewString()),
Name: []string{labelName}, Name: []string{labelName},
Flags: defaultFlags, Flags: defaultFlags,
PermanentFlags: defaultPermanentFlags, PermanentFlags: defaultPermanentFlags,
@ -229,7 +229,7 @@ func newPlaceHolderMailboxCreatedUpdate(labelName string) *imap.MailboxCreated {
}) })
} }
func newMailboxCreatedUpdate(labelID imap.LabelID, labelName []string) *imap.MailboxCreated { func newMailboxCreatedUpdate(labelID imap.MailboxID, labelName []string) *imap.MailboxCreated {
return imap.NewMailboxCreated(imap.Mailbox{ return imap.NewMailboxCreated(imap.Mailbox{
ID: labelID, ID: labelID,
Name: labelName, Name: labelName,

View File

@ -90,7 +90,7 @@ func newMessageCreatedUpdate(message liteapi.MessageMetadata, literal []byte) (*
return &imap.MessageCreated{ return &imap.MessageCreated{
Message: imapMessage, Message: imapMessage,
Literal: literal, Literal: literal,
LabelIDs: mapTo[string, imap.LabelID](xslices.Filter(message.LabelIDs, wantLabelID)), MailboxIDs: mapTo[string, imap.MailboxID](xslices.Filter(message.LabelIDs, wantLabelID)),
ParsedMessage: parsedMessage, ParsedMessage: parsedMessage,
}, nil }, nil
} }