Skip to content

Commit 6f6a42a

Browse files
committed
fix
1 parent 409078c commit 6f6a42a

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

main_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -644,18 +644,18 @@ func TestIntegration_SendAndFetchImageMessages(t *testing.T) {
644644
}
645645

646646
attachment := imageMsg.Attachments[0]
647-
t.Logf("Attachment content-type: %s, url: %s, size: %d", attachment.ContentType, attachment.ContentURL, attachment.ContentSize)
647+
t.Logf("Attachment type: %s, url: %s, size: %d", attachment.Type, attachment.URL, attachment.Size)
648648

649-
if attachment.ContentType == "" {
650-
t.Errorf("attachment content-type is empty")
649+
if attachment.Type == "" {
650+
t.Errorf("attachment type is empty")
651651
}
652652

653-
if attachment.ContentURL == "" {
654-
t.Errorf("attachment content-url is empty")
653+
if attachment.URL == "" {
654+
t.Errorf("attachment url is empty")
655655
}
656656

657-
if attachment.ContentSize == 0 {
658-
t.Errorf("attachment content-size is 0")
657+
if attachment.Size == 0 {
658+
t.Errorf("attachment size is 0")
659659
}
660660

661661
// Verify preview exists
@@ -671,8 +671,8 @@ func TestIntegration_SendAndFetchImageMessages(t *testing.T) {
671671
}
672672

673673
preview := imageMsg.Attachments[0].Preview
674-
if preview.ContentType != "image/jpeg" {
675-
t.Errorf("preview content-type is %s, expected image/jpeg", preview.ContentType)
674+
if preview.Type != "image/jpeg" {
675+
t.Errorf("preview type is %s, expected image/jpeg", preview.Type)
676676
}
677677

678678
if preview.Content == "" {
@@ -690,10 +690,10 @@ func TestIntegration_SendAndFetchImageMessages(t *testing.T) {
690690
}
691691

692692
// Verify the attachment structure
693-
t.Logf("Attachment structure verified: ContentType=%s, ContentURL=%s, ContentSize=%d, HasPreview=%v",
694-
imageMsg.Attachments[0].ContentType,
695-
imageMsg.Attachments[0].ContentURL,
696-
imageMsg.Attachments[0].ContentSize,
693+
t.Logf("Attachment structure verified: Type=%s, URL=%s, Size=%d, HasPreview=%v",
694+
imageMsg.Attachments[0].Type,
695+
imageMsg.Attachments[0].URL,
696+
imageMsg.Attachments[0].Size,
697697
imageMsg.Attachments[0].Preview != nil)
698698
})
699699
})

models/messages.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ type SMS struct {
4747

4848
// Attachment represents a file attachment in the Acrobits x-acro-filetransfer format.
4949
type Attachment struct {
50-
ContentType string `json:"content-type,omitempty"`
51-
ContentURL string `json:"content-url"`
52-
ContentSize int `json:"content-size,omitempty"`
50+
Type string `json:"type,omitempty"`
51+
URL string `json:"url"`
52+
Size int `json:"size,omitempty"`
5353
Filename string `json:"filename,omitempty"`
5454
Description string `json:"description,omitempty"`
55-
EncryptionKey string `json:"encryption-key,omitempty"`
55+
EncryptionKey string `json:"encryption_key,omitempty"`
5656
Hash string `json:"hash,omitempty"`
5757
Preview *AttachmentPreview `json:"preview,omitempty"`
5858
}
5959

6060
// AttachmentPreview represents a low-quality preview of an attachment.
6161
type AttachmentPreview struct {
62-
ContentType string `json:"content-type,omitempty"`
63-
Content string `json:"content"` // BASE64 encoded
62+
Type string `json:"type,omitempty"`
63+
Content string `json:"content"` // BASE64 encoded
6464
}
6565

6666
// Message is a helper struct for internal use.

service/messages.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,16 @@ func (s *MessageService) FetchMessages(ctx context.Context, req *models.FetchMes
328328
publicURL := s.buildMediaURL(mxcURL)
329329

330330
attachment := models.Attachment{
331-
ContentType: contentType,
332-
ContentURL: publicURL,
333-
ContentSize: contentSize,
334-
Filename: body, // Use body as filename if available
331+
Type: contentType,
332+
URL: publicURL,
333+
Size: contentSize,
334+
Filename: body, // Use body as filename if available
335335
}
336336

337337
if preview != "" {
338338
attachment.Preview = &models.AttachmentPreview{
339-
ContentType: "image/jpeg",
340-
Content: preview,
339+
Type: "image/jpeg",
340+
Content: preview,
341341
}
342342
}
343343

0 commit comments

Comments
 (0)