feat: idempotent handlers, deterministic activity ids
This commit is contained in:
@@ -38,3 +38,34 @@ pub fn watchlist_entry_url(
|
||||
))
|
||||
.expect("base_url is always a valid URL prefix")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// k-ap derives the Create activity id from the object id (UUIDv5), so
|
||||
/// re-handling an event only re-sends the same activity id if our object
|
||||
/// ids are pure functions of the entity. Update/Delete/Move ids are minted
|
||||
/// randomly inside k-ap 0.5 with no override (see ADR-0015): those repeat
|
||||
/// semantically idempotent activities under a fresh id.
|
||||
#[test]
|
||||
fn activitypub_object_ids_are_stable_across_event_redelivery() {
|
||||
let instance = InstanceIdentity::new("https://diary.example");
|
||||
let review = ReviewId::from_uuid(uuid::Uuid::new_v4());
|
||||
let user = uuid::Uuid::new_v4();
|
||||
let movie = uuid::Uuid::new_v4();
|
||||
|
||||
assert_eq!(
|
||||
review_url(&instance, &review),
|
||||
review_url(&instance, &review)
|
||||
);
|
||||
assert_eq!(
|
||||
goal_url(&instance, user, 2026),
|
||||
goal_url(&instance, user, 2026)
|
||||
);
|
||||
assert_eq!(
|
||||
watchlist_entry_url(&instance, user, movie),
|
||||
watchlist_entry_url(&instance, user, movie)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user