Skip to content

Commit

Permalink
Clean up formatting of CreateMessageApp::filtered_endpoints (#1489)
Browse files Browse the repository at this point in the history
I noticed in #1487 that this
method was formatted quite badly. I removed the comments, let rustfmt do
its thing, then put the comments back in again (and made some small
manual adjustments).
  • Loading branch information
svix-jplatte authored Oct 18, 2024
2 parents 3a232c7 + cefa234 commit 81c567d
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions server/svix-server/src/core/message_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,33 +113,35 @@ impl CreateMessageApp {
event_type: &EventTypeName,
channels: Option<&EventChannelSet>,
) -> Vec<CreateMessageEndpoint> {
self
.endpoints
.iter()
.filter(|endpoint| {
// No disabled or deleted endpoints ever
!endpoint.disabled && !endpoint.deleted &&
(
// Manual attempt types go through regardless
trigger_type == MessageAttemptTriggerType::Manual
|| (
// If an endpoint has event types and it matches ours, or has no event types
endpoint
.event_types_ids
.as_ref()
.map(|x| x.0.contains(event_type))
.unwrap_or(true)
&&
// If an endpoint has no channels accept all messages, otherwise only if their channels overlap.
// A message with no channels doesn't match an endpoint with channels.
endpoint
.channels
.as_ref()
.map(|x| !x.0.is_disjoint(channels.map(|x| &x.0).unwrap_or(&HashSet::new())))
.unwrap_or(true)
))})
.cloned()
.collect()
self.endpoints
.iter()
.filter(|endpoint| {
// No disabled or deleted endpoints ever
!endpoint.disabled && !endpoint.deleted
// Manual attempt types go through regardless
&& (trigger_type == MessageAttemptTriggerType::Manual
|| (
// If an endpoint has event types and it matches ours, or has no event types
endpoint
.event_types_ids
.as_ref()
.map(|x| x.0.contains(event_type))
.unwrap_or(true)
// If an endpoint has no channels accept all messages, otherwise only if their channels overlap.
// A message with no channels doesn't match an endpoint with channels.
&& endpoint
.channels
.as_ref()
.map(|x| {
!x.0.is_disjoint(
channels.map(|x| &x.0).unwrap_or(&HashSet::new()),
)
})
.unwrap_or(true)
))
})
.cloned()
.collect()
}
}

Expand Down

0 comments on commit 81c567d

Please sign in to comment.