Skip to content

Commit 09cf30b

Browse files
Added Attachments to APISentPayload & send request
1 parent 072be0c commit 09cf30b

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

api/pkg/events/message_api_sent_event.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ const EventTypeMessageAPISent = "message.api.sent"
1313

1414
// MessageAPISentPayload is the payload of the EventTypeMessageSent event
1515
type MessageAPISentPayload struct {
16-
MessageID uuid.UUID `json:"message_id"`
17-
UserID entities.UserID `json:"user_id"`
18-
Owner string `json:"owner"`
19-
RequestID *string `json:"request_id"`
20-
MaxSendAttempts uint `json:"max_send_attempts"`
21-
Contact string `json:"contact"`
22-
ScheduledSendTime *time.Time `json:"scheduled_send_time"`
23-
RequestReceivedAt time.Time `json:"request_received_at"`
24-
Content string `json:"content"`
25-
Encrypted bool `json:"encrypted"`
26-
SIM entities.SIM `json:"sim"`
16+
MessageID uuid.UUID `json:"message_id"`
17+
UserID entities.UserID `json:"user_id"`
18+
Owner string `json:"owner"`
19+
RequestID *string `json:"request_id"`
20+
MaxSendAttempts uint `json:"max_send_attempts"`
21+
Contact string `json:"contact"`
22+
ScheduledSendTime *time.Time `json:"scheduled_send_time"`
23+
RequestReceivedAt time.Time `json:"request_received_at"`
24+
Content string `json:"content"`
25+
Attachments []entities.MessageAttachment `json:"attachments"`
26+
Encrypted bool `json:"encrypted"`
27+
SIM entities.SIM `json:"sim"`
2728
}

api/pkg/requests/message_send_request.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import (
1414
// MessageSend is the payload for sending and SMS message
1515
type MessageSend struct {
1616
request
17-
From string `json:"from" example:"+18005550199"`
18-
To string `json:"to" example:"+18005550100"`
19-
Content string `json:"content" example:"This is a sample text message"`
17+
From string `json:"from" example:"+18005550199"`
18+
To string `json:"to" example:"+18005550100"`
19+
Content string `json:"content" example:"This is a sample text message"`
20+
Attachments []entities.MessageAttachment `json:"attachments" validate:"optional"`
2021

2122
// Encrypted is an optional parameter used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app
2223
Encrypted bool `json:"encrypted" example:"false" validate:"optional"`
@@ -47,5 +48,6 @@ func (input *MessageSend) ToMessageSendParams(userID entities.UserID, source str
4748
RequestReceivedAt: time.Now().UTC(),
4849
Contact: input.sanitizeAddress(input.To),
4950
Content: input.Content,
51+
Attachments: input.Attachments,
5052
}
5153
}

api/pkg/services/message_service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ type MessageSendParams struct {
430430
Contact string
431431
Encrypted bool
432432
Content string
433+
Attachments []entities.MessageAttachment
433434
Source string
434435
SendAt *time.Time
435436
RequestID *string
@@ -456,6 +457,7 @@ func (service *MessageService) SendMessage(ctx context.Context, params MessageSe
456457
Contact: params.Contact,
457458
RequestReceivedAt: params.RequestReceivedAt,
458459
Content: params.Content,
460+
Attachments: params.Attachments,
459461
ScheduledSendTime: params.SendAt,
460462
SIM: sim,
461463
}
@@ -968,6 +970,7 @@ func (service *MessageService) storeSentMessage(ctx context.Context, payload eve
968970
Contact: payload.Contact,
969971
UserID: payload.UserID,
970972
Content: payload.Content,
973+
Attachments: payload.Attachments,
971974
RequestID: payload.RequestID,
972975
SIM: payload.SIM,
973976
Encrypted: payload.Encrypted,

0 commit comments

Comments
 (0)