mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 12:46:46 +00:00
Other: Update Gluon to v0.13.0
This commit is contained in:
committed by
James Houlahan
parent
d47b5b99c5
commit
ca132881f9
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.18
|
||||
require (
|
||||
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557
|
||||
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-rfc5322 v0.11.0
|
||||
github.com/ProtonMail/gopenpgp/v2 v2.4.10
|
||||
|
||||
2
go.sum
2
go.sum
@ -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/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.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/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
|
||||
|
||||
@ -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
|
||||
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
|
||||
@ -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
|
||||
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
|
||||
@ -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
|
||||
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
|
||||
@ -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
|
||||
update := imap.NewMessageLabelsUpdated(
|
||||
update := imap.NewMessageMailboxesUpdated(
|
||||
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.Starred(),
|
||||
)
|
||||
|
||||
@ -78,8 +78,8 @@ func (conn *imapConnector) Authorize(username string, password []byte) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// GetLabel returns information about the label with the given ID.
|
||||
func (conn *imapConnector) GetLabel(ctx context.Context, labelID imap.LabelID) (imap.Mailbox, error) {
|
||||
// GetMailbox returns information about the label with the given ID.
|
||||
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)
|
||||
if err != nil {
|
||||
return imap.Mailbox{}, err
|
||||
@ -103,7 +103,7 @@ func (conn *imapConnector) GetLabel(ctx context.Context, labelID imap.LabelID) (
|
||||
}
|
||||
|
||||
return imap.Mailbox{
|
||||
ID: imap.LabelID(label.ID),
|
||||
ID: imap.MailboxID(label.ID),
|
||||
Name: name,
|
||||
Flags: conn.flags,
|
||||
PermanentFlags: conn.permFlags,
|
||||
@ -111,8 +111,8 @@ func (conn *imapConnector) GetLabel(ctx context.Context, labelID imap.LabelID) (
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateLabel creates a label with the given name.
|
||||
func (conn *imapConnector) CreateLabel(ctx context.Context, name []string) (imap.Mailbox, error) {
|
||||
// CreateMailbox creates a label with the given name.
|
||||
func (conn *imapConnector) CreateMailbox(ctx context.Context, name []string) (imap.Mailbox, error) {
|
||||
if len(name) != 2 {
|
||||
panic("subfolders are unsupported")
|
||||
}
|
||||
@ -135,7 +135,7 @@ func (conn *imapConnector) CreateLabel(ctx context.Context, name []string) (imap
|
||||
}
|
||||
|
||||
return imap.Mailbox{
|
||||
ID: imap.LabelID(label.ID),
|
||||
ID: imap.MailboxID(label.ID),
|
||||
Name: name,
|
||||
Flags: conn.flags,
|
||||
PermanentFlags: conn.permFlags,
|
||||
@ -143,8 +143,8 @@ func (conn *imapConnector) CreateLabel(ctx context.Context, name []string) (imap
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateLabel sets the name of the label with the given ID.
|
||||
func (conn *imapConnector) UpdateLabel(ctx context.Context, labelID imap.LabelID, newName []string) error {
|
||||
// UpdateMailboxName sets the name of the label with the given ID.
|
||||
func (conn *imapConnector) UpdateMailboxName(ctx context.Context, labelID imap.MailboxID, newName []string) error {
|
||||
if len(newName) != 2 {
|
||||
panic("subfolders are unsupported")
|
||||
}
|
||||
@ -182,13 +182,13 @@ func (conn *imapConnector) UpdateLabel(ctx context.Context, labelID imap.LabelID
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteLabel deletes the label with the given ID.
|
||||
func (conn *imapConnector) DeleteLabel(ctx context.Context, labelID imap.LabelID) error {
|
||||
// DeleteMailbox deletes the label with the given ID.
|
||||
func (conn *imapConnector) DeleteMailbox(ctx context.Context, labelID imap.MailboxID) error {
|
||||
return conn.client.DeleteLabel(ctx, string(labelID))
|
||||
}
|
||||
|
||||
// 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))
|
||||
if err != nil {
|
||||
return imap.Message{}, nil, err
|
||||
@ -208,13 +208,13 @@ func (conn *imapConnector) GetMessage(ctx context.Context, messageID imap.Messag
|
||||
ID: imap.MessageID(message.ID),
|
||||
Flags: flags,
|
||||
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.
|
||||
func (conn *imapConnector) CreateMessage(
|
||||
ctx context.Context,
|
||||
labelID imap.LabelID,
|
||||
labelID imap.MailboxID,
|
||||
literal []byte,
|
||||
flags imap.FlagSet,
|
||||
date time.Time,
|
||||
@ -267,18 +267,18 @@ func (conn *imapConnector) CreateMessage(
|
||||
}, literal, nil
|
||||
}
|
||||
|
||||
// LabelMessages labels the given messages with the given label ID.
|
||||
func (conn *imapConnector) LabelMessages(ctx context.Context, messageIDs []imap.MessageID, labelID imap.LabelID) error {
|
||||
// AddMessagesToMailbox labels the given messages with the given label ID.
|
||||
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))
|
||||
}
|
||||
|
||||
// UnlabelMessages unlabels the given messages with the given label ID.
|
||||
func (conn *imapConnector) UnlabelMessages(ctx context.Context, messageIDs []imap.MessageID, labelID imap.LabelID) error {
|
||||
// RemoveMessagesFromMailbox unlabels the given messages with the given label ID.
|
||||
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))
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (conn *imapConnector) IsMailboxVisible(_ context.Context, _ imap.MailboxID) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -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 _, 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 _, 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 _, 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) {
|
||||
labelName = imap.Inbox
|
||||
}
|
||||
@ -221,7 +221,7 @@ func newSystemMailboxCreatedUpdate(labelID imap.LabelID, labelName string) *imap
|
||||
|
||||
func newPlaceHolderMailboxCreatedUpdate(labelName string) *imap.MailboxCreated {
|
||||
return imap.NewMailboxCreated(imap.Mailbox{
|
||||
ID: imap.LabelID(uuid.NewString()),
|
||||
ID: imap.MailboxID(uuid.NewString()),
|
||||
Name: []string{labelName},
|
||||
Flags: defaultFlags,
|
||||
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{
|
||||
ID: labelID,
|
||||
Name: labelName,
|
||||
|
||||
@ -90,7 +90,7 @@ func newMessageCreatedUpdate(message liteapi.MessageMetadata, literal []byte) (*
|
||||
return &imap.MessageCreated{
|
||||
Message: imapMessage,
|
||||
Literal: literal,
|
||||
LabelIDs: mapTo[string, imap.LabelID](xslices.Filter(message.LabelIDs, wantLabelID)),
|
||||
MailboxIDs: mapTo[string, imap.MailboxID](xslices.Filter(message.LabelIDs, wantLabelID)),
|
||||
ParsedMessage: parsedMessage,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user