Skip to content

Commit

Permalink
subscription: rename PrincsFilter::princs to princ_literals
Browse files Browse the repository at this point in the history
This is a preparation step before adding support for wildcard filters.
  • Loading branch information
MrAnno committed Oct 30, 2024
1 parent fbdbf58 commit 895974d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions common/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub mod tests {
PrincsFilterOperation::Only
);
assert_eq!(
tata.princs_filter().princs(),
tata.princs_filter().princ_literals(),
&HashSet::from(["couscous".to_string(), "boulette".to_string()])
);

Expand Down Expand Up @@ -297,7 +297,7 @@ pub mod tests {
PrincsFilterOperation::Only
);
assert_eq!(
tata2.princs_filter().princs(),
tata2.princs_filter().princ_literals(),
&HashSet::from([
"couscous".to_string(),
"boulette".to_string(),
Expand Down Expand Up @@ -328,7 +328,7 @@ pub mod tests {
PrincsFilterOperation::Except
);
assert_eq!(
tata2_clone.princs_filter().princs(),
tata2_clone.princs_filter().princ_literals(),
&HashSet::from(["boulette".to_string(), "semoule".to_string()])
);

Expand All @@ -347,7 +347,7 @@ pub mod tests {
.await?
.unwrap();
assert_eq!(tata2_clone_clone.princs_filter().operation(), None);
assert_eq!(tata2_clone_clone.princs_filter().princs(), &HashSet::new());
assert_eq!(tata2_clone_clone.princs_filter().princ_literals(), &HashSet::new());
assert_eq!(tata2_clone_clone.is_active_for("couscous"), true);
assert_eq!(tata2_clone_clone.is_active_for("semoule"), true);
assert_eq!(tata2_clone_clone.is_active_for("boulette"), true);
Expand Down
2 changes: 1 addition & 1 deletion common/src/models/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ pub mod v2 {
fn from(value: crate::subscription::PrincsFilter) -> Self {
Self {
operation: value.operation().map(|x| x.clone().into()),
princs: value.princs().clone(),
princs: value.princ_literals().clone(),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions common/src/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,20 @@ impl PrincsFilter {
})
}

pub fn princs(&self) -> &HashSet<String> {
pub fn princ_literals(&self) -> &HashSet<String> {
&self.princs
}

pub fn princs_to_string(&self) -> String {
self.princs()
self.princs
.iter()
.cloned()
.collect::<Vec<String>>()
.join(",")
}

pub fn princs_to_opt_string(&self) -> Option<String> {
if self.princs().is_empty() {
if self.princs.is_empty() {
None
} else {
Some(self.princs_to_string())
Expand Down Expand Up @@ -813,9 +813,9 @@ impl SubscriptionData {

match self.princs_filter().operation {
None => true,
Some(PrincsFilterOperation::Only) => self.princs_filter().princs().contains(principal),
Some(PrincsFilterOperation::Only) => self.princs_filter().princ_literals().contains(principal),
Some(PrincsFilterOperation::Except) => {
!self.princs_filter().princs().contains(principal)
!self.princs_filter().princ_literals().contains(principal)
}
}
}
Expand Down

0 comments on commit 895974d

Please sign in to comment.