Skip to content

Commit

Permalink
Merge pull request #796 from nyaruka/prevent-failed-msgs-status-update
Browse files Browse the repository at this point in the history
Prevent failed msgs to change status back to some other status
  • Loading branch information
norkans7 authored Nov 1, 2024
2 parents ad459db + b4734c6 commit d6d449b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions backends/rapidpro/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ func (ts *BackendTestSuite) TestMsgStatus() {
ts.Equal(pq.StringArray(nil), m.LogUUIDs)

// update to FAILED using external id
clog5 := updateStatusByExtID("ext1", courier.MsgStatusFailed)
clog5 := updateStatusByExtID("ext1", courier.MsgStatusQueued)

m = readMsgFromDB(ts.b, 10000)
ts.Equal(courier.MsgStatusFailed, m.Status_)
ts.Equal(courier.MsgStatusQueued, m.Status_)
ts.True(m.ModifiedOn_.After(now))
ts.Nil(m.SentOn_)
ts.Equal(pq.StringArray([]string{string(clog5.UUID)}), m.LogUUIDs)
Expand Down Expand Up @@ -992,7 +992,7 @@ func (ts *BackendTestSuite) TestOutgoingStatusUpdateOutOfOrder() {

time.Sleep(2 * time.Millisecond)
m = readMsgFromDB(ts.b, msg.ID())
ts.Equal(m.Status_, courier.MsgStatusWired)
ts.Equal(m.Status_, courier.MsgStatusFailed) // status should remain failed

}

Expand Down
2 changes: 1 addition & 1 deletion backends/rapidpro/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const sqlUpdateMsgByID = `
UPDATE msgs_msg SET
status = CASE
WHEN
s.status = 'E'
s.status = 'E' OR msgs_msg.status = 'F'
THEN CASE
WHEN
error_count >= 2 OR msgs_msg.status = 'F'
Expand Down

0 comments on commit d6d449b

Please sign in to comment.