From 65cc1d5ccf6b572a8e00e88780ea13d6906764dd Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 18 Nov 2022 12:16:04 +0100 Subject: [PATCH] GODT-2110: Force attachment disposition if content ID is missing We now set disposition during attachment upload. However, this presents a problem: some clients use inline disposition but don't provide a content ID. Our API doesn't support this. To mitigate the issue, we just fall back to attachment disposition in this case. --- internal/user/smtp.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/user/smtp.go b/internal/user/smtp.go index 0c7ca8f5..dced0428 100644 --- a/internal/user/smtp.go +++ b/internal/user/smtp.go @@ -245,6 +245,7 @@ func createDraft( }) } +// nolint:funlen func createAttachments( ctx context.Context, client *liteapi.Client, @@ -268,6 +269,12 @@ func createAttachments( return attKey{}, fmt.Errorf("failed to encrypt attachment: %w", err) } + // Some clients use inline disposition but don't set a content ID. Our API doesn't support this. + // We could generate our own content ID, but for simplicity, we just set the disposition to attachment. + if att.Disposition == string(liteapi.InlineDisposition) && att.ContentID == "" { + att.Disposition = string(liteapi.AttachmentDisposition) + } + attachment, err := client.UploadAttachment(ctx, liteapi.CreateAttachmentReq{ Filename: att.Name, MessageID: draftID,