mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user