From 3c697f5fb1b8dbad46eac8fa299ed7cebfb36159 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 9 Dec 2025 15:13:21 -0500 Subject: Factor push message publication out to its own helper component. The `Publisher` component handles the details of web push delivery. Callers must provide the subscription set, the current signer, and the message, while the publisher handles encoding and communication with web push endpoints. To facilitate testing, `Publisher` implements `Publish`, which is a new trait with the same interface. Components that might publish web push messages should rely on the trait where possible. The test suite now constructs an app with a dummy `Publish` impl, which captures push messages for examination. Note that the testing implementation of `Publish` is hand-crafted, and presently only acts to record the arguments it receives. The other alternative was to use a mocking library, such as `mockit`, and while I've used that approach before, I'm not super comfortable with the complexity in this situation. I think we can maintain a more reasonable testing `Publish` impl by hand, at least for now, and we can revisit that decision later if need be. Tests for the `ping` endpoint have been migrated to this endpoint. --- src/push/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/push/mod.rs') diff --git a/src/push/mod.rs b/src/push/mod.rs index 1394ea4..042991f 100644 --- a/src/push/mod.rs +++ b/src/push/mod.rs @@ -1,3 +1,6 @@ pub mod app; pub mod handlers; +mod publisher; pub mod repo; + +pub use publisher::{Publish, Publisher}; -- cgit v1.2.3