Skip to content

Commit 8fb277f

Browse files
AchoArnoldCopilot
andcommitted
feat(handlers): replace 1s hack with rate-based delay for bulk send
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 42c6fc4 commit 8fb277f

2 files changed

Lines changed: 1 addition & 7 deletions

File tree

api/pkg/handlers/message_handler.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ func (h *MessageHandler) BulkSend(c *fiber.Ctx) error {
161161
wg.Add(1)
162162
go func(message services.MessageSendParams, index int) {
163163
count.Add(1)
164-
if message.SendAt == nil {
165-
sentAt := time.Now().UTC().Add(time.Duration(index) * time.Second)
166-
message.SendAt = &sentAt
167-
}
168-
169164
response, err := h.service.SendMessage(ctx, message)
170165
if err != nil {
171166
count.Add(-1)

api/pkg/requests/message_bulk_send_request.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (input *MessageBulkSend) ToMessageSendParams(userID entities.UserID, source
5454

5555
var result []services.MessageSendParams
5656
for index, to := range input.To {
57-
sendAt := time.Now().UTC().Add(time.Duration(index) * time.Second)
5857
result = append(result, services.MessageSendParams{
5958
Source: source,
6059
Owner: from,
@@ -63,9 +62,9 @@ func (input *MessageBulkSend) ToMessageSendParams(userID entities.UserID, source
6362
UserID: userID,
6463
RequestReceivedAt: time.Now().UTC(),
6564
Contact: to,
66-
SendAt: &sendAt,
6765
Content: input.Content,
6866
Attachments: input.Attachments,
67+
Index: index,
6968
})
7069
}
7170

0 commit comments

Comments
 (0)