fix(GODT-2598): Map Message Size Error to Gluon Error

Prevents messages with invalid size from ending up in the recovery
mailbox.
This commit is contained in:
Leander Beernaert
2023-04-28 11:26:53 +02:00
parent 38b13d710c
commit 910060a14c
3 changed files with 11 additions and 6 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.18
require (
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557
github.com/Masterminds/semver/v3 v3.2.0
github.com/ProtonMail/gluon v0.16.1-0.20230427090931-8b3ec72985ec
github.com/ProtonMail/gluon v0.16.1-0.20230428090920-2797a1764f16
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a
github.com/ProtonMail/go-proton-api v0.4.1-0.20230426081144-f77778bae1be
github.com/ProtonMail/gopenpgp/v2 v2.7.1-proton

6
go.sum
View File

@ -28,10 +28,8 @@ github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf h1:yc9daCCYUefEs
github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf/go.mod h1:o0ESU9p83twszAU8LBeJKFAAMX14tISa0yk4Oo5TOqo=
github.com/ProtonMail/docker-credential-helpers v1.1.0 h1:+kvUIpwWcbtP3WFv5sSvkFn/XLzSqPOB5AAthuk9xPk=
github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g=
github.com/ProtonMail/gluon v0.16.1-0.20230426114906-aed4b8adf482 h1:GvaYoE4Nj/l9L7hQnhGlu9s+IP6oqb4YPKR37GAjE+Y=
github.com/ProtonMail/gluon v0.16.1-0.20230426114906-aed4b8adf482/go.mod h1:yA4hk6CJw0BMo+YL8Y3ckCYs5L20sysu9xseshwY3QI=
github.com/ProtonMail/gluon v0.16.1-0.20230427090931-8b3ec72985ec h1:RRkoDUkPBjNBBkoDV02IAimxwWONmxP1bQ64jEDsAA0=
github.com/ProtonMail/gluon v0.16.1-0.20230427090931-8b3ec72985ec/go.mod h1:yA4hk6CJw0BMo+YL8Y3ckCYs5L20sysu9xseshwY3QI=
github.com/ProtonMail/gluon v0.16.1-0.20230428090920-2797a1764f16 h1:X5kb4PwVrgVDQjBkpiobYrDlqKDMuS1o92Ty+rZ1ptE=
github.com/ProtonMail/gluon v0.16.1-0.20230428090920-2797a1764f16/go.mod h1:yA4hk6CJw0BMo+YL8Y3ckCYs5L20sysu9xseshwY3QI=
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=

View File

@ -20,6 +20,7 @@ package user
import (
"bytes"
"context"
"errors"
"fmt"
"net/mail"
"sync/atomic"
@ -350,7 +351,13 @@ func (conn *imapConnector) CreateMessage(
wantFlags = wantFlags.Add(proton.MessageFlagReplied)
}
return conn.importMessage(ctx, literal, wantLabelIDs, wantFlags, unread)
msg, literal, err := conn.importMessage(ctx, literal, wantLabelIDs, wantFlags, unread)
if err != nil && errors.Is(err, proton.ErrImportSizeExceeded) {
// Remap error so that Gluon does not put this message in the recovery mailbox.
err = fmt.Errorf("%v: %w", err, connector.ErrMessageSizeExceedsLimits)
}
return msg, literal, err
}
func (conn *imapConnector) GetMessageLiteral(ctx context.Context, id imap.MessageID) ([]byte, error) {