diff --git a/postgresql/postgresql.go b/postgresql/postgresql.go index bac89ea..1e79450 100644 --- a/postgresql/postgresql.go +++ b/postgresql/postgresql.go @@ -12,6 +12,7 @@ type PostgresBackend struct { QueryAuthorsLimit int QueryKindsLimit int QueryTagsLimit int + KeepRecentEvents bool } func (b *PostgresBackend) Close() { diff --git a/postgresql/save.go b/postgresql/save.go index 7120fa0..2958767 100644 --- a/postgresql/save.go +++ b/postgresql/save.go @@ -32,6 +32,9 @@ func (b *PostgresBackend) BeforeSave(ctx context.Context, evt *nostr.Event) { } func (b *PostgresBackend) AfterSave(evt *nostr.Event) { + if b.KeepRecentEvents { + return + } // delete all but the 100 most recent ones for each key b.DB.Exec(`DELETE FROM event WHERE pubkey = $1 AND kind = $2 AND created_at < ( SELECT created_at FROM event WHERE pubkey = $1