Breaking: Provide new user object instead of id.
Fix rustup complaining about join macros.
This commit is contained in:
@@ -9,6 +9,7 @@ pub struct PermissionCalculator<'a> {
|
||||
perspective: &'a User,
|
||||
|
||||
user: Option<&'a User>,
|
||||
relationship: Option<&'a RelationshipStatus>,
|
||||
channel: Option<&'a Channel>,
|
||||
|
||||
has_mutual_connection: bool,
|
||||
@@ -20,6 +21,7 @@ impl<'a> PermissionCalculator<'a> {
|
||||
perspective,
|
||||
|
||||
user: None,
|
||||
relationship: None,
|
||||
channel: None,
|
||||
|
||||
has_mutual_connection: false,
|
||||
@@ -33,6 +35,13 @@ impl<'a> PermissionCalculator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_relationship(self, relationship: &'a RelationshipStatus) -> PermissionCalculator {
|
||||
PermissionCalculator {
|
||||
relationship: Some(&relationship),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_channel(self, channel: &'a Channel) -> PermissionCalculator {
|
||||
PermissionCalculator {
|
||||
channel: Some(&channel),
|
||||
|
||||
@@ -49,7 +49,7 @@ impl<'a> PermissionCalculator<'a> {
|
||||
}
|
||||
|
||||
let mut permissions: u32 = 0;
|
||||
match get_relationship(&self.perspective, &target) {
|
||||
match self.relationship.clone().map(|v| v.to_owned()).unwrap_or_else(|| get_relationship(&self.perspective, &target)) {
|
||||
RelationshipStatus::Friend => return Ok(u32::MAX),
|
||||
RelationshipStatus::Blocked | RelationshipStatus::BlockedOther => {
|
||||
return Ok(UserPermission::Access as u32)
|
||||
|
||||
Reference in New Issue
Block a user