feat(GODT-2283): Limit max import size to 30MB (bump GPA to v0.4.0)

This commit is contained in:
James Houlahan
2023-02-09 16:24:40 +01:00
parent 5f930c262c
commit 8b9265ad96
5 changed files with 23 additions and 10 deletions

View File

@ -431,7 +431,7 @@ func createMessages(ctx context.Context, t *testing.T, c *proton.Client, addrID,
_, ok := addrKRs[addrID]
require.True(t, ok)
res, err := stream.Collect(ctx, c.ImportMessages(
str, err := c.ImportMessages(
ctx,
addrKRs[addrID],
runtime.NumCPU(),
@ -446,7 +446,10 @@ func createMessages(ctx context.Context, t *testing.T, c *proton.Client, addrID,
Message: message,
}
})...,
))
)
require.NoError(t, err)
res, err := stream.Collect(ctx, str)
require.NoError(t, err)
return xslices.Map(res, func(res proton.ImportRes) string {

View File

@ -538,7 +538,7 @@ func (conn *imapConnector) importMessage(
messageID = msg.ID
} else {
res, err := stream.Collect(ctx, conn.client.ImportMessages(ctx, addrKR, 1, 1, []proton.ImportReq{{
str, err := conn.client.ImportMessages(ctx, addrKR, 1, 1, []proton.ImportReq{{
Metadata: proton.ImportMetadata{
AddressID: conn.addrID,
LabelIDs: labelIDs,
@ -546,7 +546,12 @@ func (conn *imapConnector) importMessage(
Flags: flags,
},
Message: literal,
}}...))
}}...)
if err != nil {
return fmt.Errorf("failed to prepare message for import: %w", err)
}
res, err := stream.Collect(ctx, str)
if err != nil {
return fmt.Errorf("failed to import message: %w", err)
}