From 1846094b3111a059f856bb4f3466c102fad17ef7 Mon Sep 17 00:00:00 2001 From: Jarrod Sibbison <72240382+jsibbison-square@users.noreply.github.com> Date: Mon, 28 Sep 2026 23:17:40 +1000 Subject: [PATCH] fix(db): limit event transactions to listener mention kinds (#7932) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Keep non-listener-mention event writes on the plain insert path without opening a transaction. - Preserve the transaction around listener mention event insertion and outbox enqueue. ## Validation - `cargo fmt --all -- --check` (Hermit) - Tests not run. Follow-up to Baxen’s review of #7793, point 1. Signed-off-by: Implementor <691cca7a870db1dad6990d5938d1b4a2a2ca9647ca81290b536c17b06b2e473f@buzz.block.builderlab.xyz> Co-authored-by: Implementor <691cca7a870db1dad6990d5938d1b4a2a2ca9647ca81290b536c17b06b2e473f@buzz.block.builderlab.xyz> --- crates/buzz-db/src/store/event.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/buzz-db/src/store/event.rs b/crates/buzz-db/src/store/event.rs index 537f338030..6259a02c5d 100644 --- a/crates/buzz-db/src/store/event.rs +++ b/crates/buzz-db/src/store/event.rs @@ -355,15 +355,19 @@ pub async fn insert_event( event: &Event, channel_id: Option, ) -> Result<(StoredEvent, bool)> { - let connection = crate::observability::acquire_writer( + let mut connection = crate::observability::acquire_writer( pool, crate::observability::WriterOperation::EventWrite, ) .await?; - let mut tx = Transaction::begin(connection, None).await?; - let result = insert_event_in_transaction(&mut tx, community_id, event, channel_id).await?; - tx.commit().await?; - Ok(result) + if crate::operator_listener::is_listener_mention_kind(u32::from(event.kind.as_u16())) { + let mut tx = Transaction::begin(connection, None).await?; + let result = insert_event_in_transaction(&mut tx, community_id, event, channel_id).await?; + tx.commit().await?; + Ok(result) + } else { + insert_event_on(&mut connection, community_id, event, channel_id).await + } } /// Insert a Nostr event in a caller-owned PostgreSQL transaction.