Skip to content

Commit 3e3e5bd

Browse files
committed
Fix the thread update to not throw errors
1 parent 431c2cf commit 3e3e5bd

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

api/pkg/services/message_service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ func (service *MessageService) HandleMessageDelivered(ctx context.Context, param
489489

490490
if !message.IsSent() && !message.IsSending() && !message.IsExpired() && !message.IsScheduled() {
491491
msg := fmt.Sprintf("message has wrong status [%s]. expected [%s, %s, %s, %s]", message.Status, entities.MessageStatusSent, entities.MessageStatusScheduled, entities.MessageStatusSending, entities.MessageStatusExpired)
492-
return service.tracer.WrapErrorSpan(span, stacktrace.NewError(msg))
492+
ctxLogger.Warn(stacktrace.NewError(msg))
493+
return nil
493494
}
494495

495496
if err = service.repository.Update(ctx, message.Delivered(params.Timestamp)); err != nil {

api/pkg/services/message_thread_service.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ func (service *MessageThreadService) UpdateThread(ctx context.Context, params Me
6363
}
6464

6565
if thread.OrderTimestamp.Unix() > params.Timestamp.Unix() && thread.Status != entities.MessageStatusSending {
66-
ctxLogger.Info(fmt.Sprintf("thread [%s] has timestamp [%s] and status [%s] which is greater than timestamp [%s] for message [%s] and status [%s]", thread.ID, thread.OrderTimestamp, thread.Status, params.Timestamp, params.MessageID, params.Status))
66+
ctxLogger.Warn(stacktrace.NewError(fmt.Sprintf("thread [%s] has timestamp [%s] and status [%s] which is greater than timestamp [%s] for message [%s] and status [%s]", thread.ID, thread.OrderTimestamp, thread.Status, params.Timestamp, params.MessageID, params.Status)))
67+
return nil
68+
}
69+
70+
if thread.Status == entities.MessageStatusDelivered {
71+
ctxLogger.Warn(stacktrace.NewError(fmt.Sprintf("thread [%s] already has status [%s] not updating with status [%s] for message [%s]", thread.ID, thread.Status, params.Status, params.MessageID)))
6772
return nil
6873
}
6974

0 commit comments

Comments
 (0)