Skip to content

Commit c559419

Browse files
committed
webhook status
1 parent 2147650 commit c559419

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

internal/repository/message_history_postgre.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func (r *MessageHistoryRepository) SetStatusesIfNotSet(ctx context.Context, work
470470
query := fmt.Sprintf(`
471471
UPDATE message_history
472472
SET %s = updates.timestamp,
473-
status_info = COALESCE(updates.status_info, status_info),
473+
status_info = COALESCE(updates.status_info, message_history.status_info),
474474
updated_at = $1::TIMESTAMP WITH TIME ZONE
475475
FROM (VALUES %s) AS updates(id, timestamp, status_info)
476476
WHERE message_history.id = updates.id AND %s IS NULL

internal/repository/message_history_postgre_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ func TestMessageHistoryRepository_SetStatusesIfNotSet(t *testing.T) {
10621062
Return(db, nil)
10631063

10641064
// Expect batch query for delivered status updates (2 messages)
1065-
mock.ExpectExec(`UPDATE message_history SET delivered_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\), \(\$5, \$6::TIMESTAMP WITH TIME ZONE, \$7\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND delivered_at IS NULL`).
1065+
mock.ExpectExec(`UPDATE message_history SET delivered_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, message_history\.status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\), \(\$5, \$6::TIMESTAMP WITH TIME ZONE, \$7\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND delivered_at IS NULL`).
10661066
WithArgs(
10671067
sqlmock.AnyArg(), // updated_at timestamp
10681068
"msg-123",
@@ -1093,7 +1093,7 @@ func TestMessageHistoryRepository_SetStatusesIfNotSet(t *testing.T) {
10931093
Return(db, nil)
10941094

10951095
// Expect batch query for bounced status updates (1 message)
1096-
mock.ExpectExec(`UPDATE message_history SET bounced_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND bounced_at IS NULL`).
1096+
mock.ExpectExec(`UPDATE message_history SET bounced_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, message_history\.status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND bounced_at IS NULL`).
10971097
WithArgs(
10981098
sqlmock.AnyArg(), // updated_at timestamp
10991099
"msg-789",
@@ -1126,7 +1126,7 @@ func TestMessageHistoryRepository_SetStatusesIfNotSet(t *testing.T) {
11261126
Return(db, nil)
11271127

11281128
// Expect single batch query for opened status updates (2 messages)
1129-
mock.ExpectExec(`UPDATE message_history SET opened_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\), \(\$5, \$6::TIMESTAMP WITH TIME ZONE, \$7\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND opened_at IS NULL`).
1129+
mock.ExpectExec(`UPDATE message_history SET opened_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, message_history\.status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\), \(\$5, \$6::TIMESTAMP WITH TIME ZONE, \$7\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND opened_at IS NULL`).
11301130
WithArgs(
11311131
sqlmock.AnyArg(), // updated_at timestamp
11321132
"msg-123",
@@ -1181,7 +1181,7 @@ func TestMessageHistoryRepository_SetStatusesIfNotSet(t *testing.T) {
11811181
GetConnection(gomock.Any(), workspaceID).
11821182
Return(db, nil)
11831183

1184-
mock.ExpectExec(`UPDATE message_history SET delivered_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\), \(\$5, \$6::TIMESTAMP WITH TIME ZONE, \$7\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND delivered_at IS NULL`).
1184+
mock.ExpectExec(`UPDATE message_history SET delivered_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, message_history\.status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\), \(\$5, \$6::TIMESTAMP WITH TIME ZONE, \$7\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND delivered_at IS NULL`).
11851185
WithArgs(
11861186
sqlmock.AnyArg(),
11871187
"msg-123",
@@ -1218,7 +1218,7 @@ func TestMessageHistoryRepository_SetStatusesIfNotSet(t *testing.T) {
12181218
Return(db, nil)
12191219

12201220
// Expect the batch version to be called with a single update
1221-
mock.ExpectExec(`UPDATE message_history SET delivered_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND delivered_at IS NULL`).
1221+
mock.ExpectExec(`UPDATE message_history SET delivered_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, message_history\.status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND delivered_at IS NULL`).
12221222
WithArgs(
12231223
sqlmock.AnyArg(),
12241224
"msg-123",
@@ -1256,7 +1256,7 @@ func TestMessageHistoryRepository_SetStatusesIfNotSet(t *testing.T) {
12561256
Return(db, nil)
12571257

12581258
// Expect batch query for bounced status updates (1 message with status_info)
1259-
mock.ExpectExec(`UPDATE message_history SET bounced_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND bounced_at IS NULL`).
1259+
mock.ExpectExec(`UPDATE message_history SET bounced_at = updates\.timestamp, status_info = COALESCE\(updates\.status_info, message_history\.status_info\), updated_at = \$1::TIMESTAMP WITH TIME ZONE FROM \(VALUES \(\$2, \$3::TIMESTAMP WITH TIME ZONE, \$4\)\) AS updates\(id, timestamp, status_info\) WHERE message_history\.id = updates\.id AND bounced_at IS NULL`).
12601260
WithArgs(
12611261
sqlmock.AnyArg(), // updated_at timestamp
12621262
"msg-123",

0 commit comments

Comments
 (0)