email attachment endpoint bc

Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
Ronni Skansing
2026-01-19 20:59:19 +01:00
parent 4b091a4d3c
commit efb35f6bcc

View File

@@ -27,8 +27,10 @@ var EmailOrderByMap = map[string]string{
}
// AddAttachmentsToEmailRequest is a request to add attachments to a message
// supports both old format (ids array) and new format (attachments array with isInline)
type AddAttachmentsToEmailRequest struct {
Attachments []AttachmentWithInline `json:"attachments"`
IDs []string `json:"ids"` // deprecated: old format for backward compatibility
Attachments []AttachmentWithInline `json:"attachments"` // new format with isInline support
}
// AttachmentWithInline represents an attachment ID with inline flag
@@ -72,6 +74,17 @@ func (m *Email) AddAttachments(g *gin.Context) {
if !ok {
return
}
// handle backward compatibility: if old format (ids) is used, convert to new format
if len(request.IDs) > 0 && len(request.Attachments) == 0 {
for _, idStr := range request.IDs {
request.Attachments = append(request.Attachments, AttachmentWithInline{
ID: idStr,
IsInline: false, // default to false for backward compatibility
})
}
}
if len(request.Attachments) == 0 {
m.Response.BadRequestMessage(g, "No attachments provided")
return