Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions database/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -1362,19 +1362,24 @@ func (db *dbClient) deleteExpiredEvents(ctx context.Context) (err error) {
events
WHERE
expiration <= :cutoff
and hidden = false
and deleted = false
Comment on lines +1365 to +1366
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new filtering conditions hidden = false AND deleted = false change the behavior of expired event cleanup by excluding hidden and deleted events from being deleted based on expiration. This means that events marked as hidden or deleted will persist even if they have expired, which could lead to accumulation of expired events that were previously marked for deletion. If this is intentional to prevent double-processing of already-deleted events, this should be documented. Otherwise, this could lead to a buildup of expired events in the database that were marked as hidden or deleted but never actually removed.

Suggested change
and hidden = false
and deleted = false

Copilot uses AI. Check for mistakes.
ORDER BY lookup_created_at ASC
LIMIT :batch_size
FOR UPDATE SKIP LOCKED
)
DELETE FROM events
WHERE id IN (SELECT id FROM expired_events)
DELETE FROM events AS de
USING expired_events AS ee
WHERE
de.id = ee.id
RETURNING
kind,
created_at,
id,
pubkey,
sig,
content,
tags`
de.kind,
de.created_at,
de.id,
de.pubkey,
de.sig,
de.content,
de.tags`
params := map[string]any{
"batch_size": batchSize,
"cutoff": time.Now().UnixNano(),
Expand All @@ -1393,7 +1398,7 @@ func (db *dbClient) deleteExpiredEvents(ctx context.Context) (err error) {
}
}

if len(events) < batchSize {
if len(events) < batchSize || ctx.Err() != nil {
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context cancellation check ctx.Err() != nil on this line is redundant. The loop condition on line 1388 already checks ctx.Err() == nil, and there's another context cancellation check in the select statement at lines 1405-1407. If the context is cancelled, the loop will exit on the next iteration due to the loop condition. This redundant check adds unnecessary complexity without providing additional benefit.

Suggested change
if len(events) < batchSize || ctx.Err() != nil {
if len(events) < batchSize {

Copilot uses AI. Check for mistakes.
break
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/davidbyttow/govips/v2 v2.16.0
github.com/dchenk/go-render-quill v0.0.0-20211110010230-f51106477162
github.com/docker/go-connections v0.6.0
github.com/dundee/gdu/v5 v5.32.1-0.20260119094913-d7f79fbbf366
github.com/dundee/gdu/v5 v5.32.1-0.20260204201143-0aad7bef5cac
github.com/forPelevin/gomoji v1.4.1
github.com/fsnotify/fsnotify v1.9.0
github.com/georgysavva/scany/v2 v2.1.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pM
github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dundee/gdu/v5 v5.32.1-0.20260119094913-d7f79fbbf366 h1:qgH1Xn1veDxQsvUbe3HIz2ishnLHI75cnTmYfnFmOKQ=
github.com/dundee/gdu/v5 v5.32.1-0.20260119094913-d7f79fbbf366/go.mod h1:ERJWB673cEpklxhem67U/AfhyMsFUVzxb81P8VSiJ/4=
github.com/dundee/gdu/v5 v5.32.1-0.20260204201143-0aad7bef5cac h1:YuF92xeKZq0CT1gaevnjnwCk4aJe3cjHfQpb6d0S0OI=
github.com/dundee/gdu/v5 v5.32.1-0.20260204201143-0aad7bef5cac/go.mod h1:2vMckWa9UrPI/nXamn4rWS2pJ/0vSsGsbJxdR3CQ0eQ=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/ebitengine/purego v0.9.1 h1:a/k2f2HQU3Pi399RPW1MOaZyhKJL9w/xFpKAg4q1s0A=
Expand Down
1 change: 1 addition & 0 deletions validation/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ var (
"tx_amount",
).
Optional("p").
Optional("k", "token_symbol"). // TODO: Make required later.
Forbidden("expiration").
ContentEmpty().
Validate(validateInternalTopicTC).
Expand Down
Loading