fix(db): limit event transactions to listener mention kinds (#7932)

## 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>
This commit is contained in:
Jarrod Sibbison
2026-09-28 23:17:40 +10:00
committed by GitHub
parent c4c86006f2
commit 1846094b31

View File

@@ -355,15 +355,19 @@ pub async fn insert_event(
event: &Event,
channel_id: Option<Uuid>,
) -> 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.