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.
This commit is contained in:
James Houlahan
2022-11-18 12:16:04 +01:00
parent f17b630b12
commit 65cc1d5ccf

View File

@ -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,