@@ -11,6 +11,16 @@ import (
1111 "github.com/NdoleStudio/httpsms/pkg/services"
1212)
1313
14+ // MessageAttachment represents a single MMS attachment in a receive request
15+ type MessageAttachment struct {
16+ // Name is the original filename of the attachment
17+ Name string `json:"name" example:"photo.jpg"`
18+ // ContentType is the MIME type of the attachment
19+ ContentType string `json:"content_type" example:"image/jpeg"`
20+ // Content is the base64-encoded attachment data
21+ Content string `json:"content" example:"base64data..."`
22+ }
23+
1424// MessageReceive is the payload for sending and SMS message
1525type MessageReceive struct {
1626 request
@@ -23,6 +33,8 @@ type MessageReceive struct {
2333 SIM entities.SIM `json:"sim" example:"SIM1"`
2434 // Timestamp is the time when the event was emitted, Please send the timestamp in UTC with as much precision as possible
2535 Timestamp time.Time `json:"timestamp" example:"2022-06-05T14:26:09.527976+03:00"`
36+ // Attachments is the list of MMS attachments received with the message
37+ Attachments []MessageAttachment `json:"attachments"`
2638}
2739
2840// Sanitize sets defaults to MessageReceive
@@ -38,14 +50,25 @@ func (input *MessageReceive) Sanitize() MessageReceive {
3850// ToMessageReceiveParams converts MessageReceive to services.MessageReceiveParams
3951func (input * MessageReceive ) ToMessageReceiveParams (userID entities.UserID , source string ) * services.MessageReceiveParams {
4052 phone , _ := phonenumbers .Parse (input .To , phonenumbers .UNKNOWN_REGION )
53+
54+ attachments := make ([]services.ServiceAttachment , len (input .Attachments ))
55+ for i , a := range input .Attachments {
56+ attachments [i ] = services.ServiceAttachment {
57+ Name : a .Name ,
58+ ContentType : a .ContentType ,
59+ Content : a .Content ,
60+ }
61+ }
62+
4163 return & services.MessageReceiveParams {
42- Source : source ,
43- Contact : input .From ,
44- UserID : userID ,
45- Timestamp : input .Timestamp ,
46- Encrypted : input .Encrypted ,
47- Owner : * phone ,
48- Content : input .Content ,
49- SIM : input .SIM ,
64+ Source : source ,
65+ Contact : input .From ,
66+ UserID : userID ,
67+ Timestamp : input .Timestamp ,
68+ Encrypted : input .Encrypted ,
69+ Owner : * phone ,
70+ Content : input .Content ,
71+ SIM : input .SIM ,
72+ Attachments : attachments ,
5073 }
5174}
0 commit comments