Skip to content

Clean up formatting of CreateMessageApp::filtered_endpoints #1489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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