From 869b972a50894540aa570912bc1a1bd7cf73c290 Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Mon, 16 Feb 2026 19:12:14 -0500 Subject: [PATCH] Manual review --- webpush/store_postgres.go | 3 ++- webpush/store_sqlite.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/webpush/store_postgres.go b/webpush/store_postgres.go index a37169b6..025e11c8 100644 --- a/webpush/store_postgres.go +++ b/webpush/store_postgres.go @@ -57,6 +57,7 @@ const ( DO UPDATE SET key_auth = excluded.key_auth, key_p256dh = excluded.key_p256dh, user_id = excluded.user_id, subscriber_ip = excluded.subscriber_ip, updated_at = excluded.updated_at, warned_at = excluded.warned_at ` pgUpdateSubscriptionWarningSentQuery = `UPDATE webpush_subscription SET warned_at = $1 WHERE id = $2` + pgUpdateSubscriptionUpdatedAtQuery = `UPDATE webpush_subscription SET updated_at = $1 WHERE endpoint = $2` pgDeleteSubscriptionByEndpointQuery = `DELETE FROM webpush_subscription WHERE endpoint = $1` pgDeleteSubscriptionByUserIDQuery = `DELETE FROM webpush_subscription WHERE user_id = $1` pgDeleteSubscriptionByAgeQuery = `DELETE FROM webpush_subscription WHERE updated_at <= $1` @@ -222,7 +223,7 @@ func (c *PostgresStore) RemoveExpiredSubscriptions(expireAfter time.Duration) er // SetSubscriptionUpdatedAt updates the updated_at timestamp for a subscription by endpoint. This is // exported for testing purposes and is not part of the Store interface. func (c *PostgresStore) SetSubscriptionUpdatedAt(endpoint string, updatedAt int64) error { - _, err := c.db.Exec("UPDATE webpush_subscription SET updated_at = $1 WHERE endpoint = $2", updatedAt, endpoint) + _, err := c.db.Exec(pgUpdateSubscriptionUpdatedAtQuery, updatedAt, endpoint) return err } diff --git a/webpush/store_sqlite.go b/webpush/store_sqlite.go index 3fae75a6..bbd9be48 100644 --- a/webpush/store_sqlite.go +++ b/webpush/store_sqlite.go @@ -63,6 +63,7 @@ const ( DO UPDATE SET key_auth = excluded.key_auth, key_p256dh = excluded.key_p256dh, user_id = excluded.user_id, subscriber_ip = excluded.subscriber_ip, updated_at = excluded.updated_at, warned_at = excluded.warned_at ` sqliteUpdateWebPushSubscriptionWarningSentQuery = `UPDATE subscription SET warned_at = ? WHERE id = ?` + sqliteUpdateWebPushSubscriptionUpdatedAtQuery = `UPDATE subscription SET updated_at = ? WHERE endpoint = ?` sqliteDeleteWebPushSubscriptionByEndpointQuery = `DELETE FROM subscription WHERE endpoint = ?` sqliteDeleteWebPushSubscriptionByUserIDQuery = `DELETE FROM subscription WHERE user_id = ?` sqliteDeleteWebPushSubscriptionByAgeQuery = `DELETE FROM subscription WHERE updated_at <= ?` // Full table scan! @@ -254,7 +255,7 @@ func (c *SQLiteStore) RemoveExpiredSubscriptions(expireAfter time.Duration) erro // SetSubscriptionUpdatedAt updates the updated_at timestamp for a subscription by endpoint. This is // exported for testing purposes and is not part of the Store interface. func (c *SQLiteStore) SetSubscriptionUpdatedAt(endpoint string, updatedAt int64) error { - _, err := c.db.Exec("UPDATE subscription SET updated_at = ? WHERE endpoint = ?", updatedAt, endpoint) + _, err := c.db.Exec(sqliteUpdateWebPushSubscriptionUpdatedAtQuery, updatedAt, endpoint) return err }