Fix Webhooks: event IDs collide for same event type emitted in the same second

This commit is contained in:
Maurus Decimus
2026-06-24 15:03:14 +02:00
parent d1dd00558f
commit 4bb2c687e1
2 changed files with 10 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ If you are upgrading from v0.16.x, replace the binary (or run `docker pull`). If
- DANE: Verify DNSSEC is supported by the resolver before attempting to validate TLSA records.
- TLS: Update search index when file-backed certificates are refreshed.
- JMAP: `Principal/query` returns broad results when a `name` or `email` filter cannot be resolved.
- Webhooks: event IDs collide for same event type emitted in the same second.
## [0.16.10] - 2026-06-21

View File

@@ -12,6 +12,9 @@ use serde::{
Serialize, Serializer,
ser::{SerializeMap, SerializeSeq},
};
use std::sync::atomic::{AtomicU64, Ordering};
static EVENT_ID_COUNTER: AtomicU64 = AtomicU64::new(0);
struct Keys<'x> {
keys: &'x [(Key, Value)],
@@ -83,7 +86,12 @@ impl<T: AsRef<Event<EventDetails>>> Serialize for JsonEventSerializer<T> {
if self.with_id {
map.serialize_entry(
"id",
&format!("{}{}", event.inner.timestamp, event.inner.typ.to_id()),
&format!(
"{}{}{}",
event.inner.timestamp,
EVENT_ID_COUNTER.fetch_add(1, Ordering::Relaxed),
event.inner.typ.to_id()
),
)?;
}
if self.with_description {