Skip to content
Snippets Groups Projects
Commit 124aa8a9 authored by insert's avatar insert
Browse files

Fix user permissions.

parent af8731ac
No related merge requests found
...@@ -28,11 +28,23 @@ pub async fn calculate(user: &User, target: &str) -> UserPermissions<[u32; 1]> { ...@@ -28,11 +28,23 @@ pub async fn calculate(user: &User, target: &str) -> UserPermissions<[u32; 1]> {
// otherwise -> Access // otherwise -> Access
// otherwise; None // otherwise; None
if let RelationshipStatus::Friend = get_relationship(&user, &target) { let mut permissions: u32 = 0;
UserPermissions([UserPermission::Access + UserPermission::SendMessage + UserPermission::Invite]) match get_relationship(&user, &target) {
} else { RelationshipStatus::Friend => {
UserPermissions([ 0 ]) return UserPermissions([ UserPermission::Access + UserPermission::SendMessage + UserPermission::Invite ])
}
RelationshipStatus::Blocked |
RelationshipStatus::BlockedOther => {
return UserPermissions([ UserPermission::Access as u32 ])
}
RelationshipStatus::Incoming |
RelationshipStatus::Outgoing => {
permissions = UserPermission::Access as u32;
}
_ => {}
} }
UserPermissions([ permissions ])
} }
pub fn get_relationship(a: &User, b: &str) -> RelationshipStatus { pub fn get_relationship(a: &User, b: &str) -> RelationshipStatus {
......
...@@ -8,7 +8,7 @@ use rocket_contrib::json::JsonValue; ...@@ -8,7 +8,7 @@ use rocket_contrib::json::JsonValue;
#[get("/")] #[get("/")]
pub async fn root() -> JsonValue { pub async fn root() -> JsonValue {
json!({ json!({
"revolt": "0.3.0-alpha", "revolt": "0.3.1-alpha.0",
"features": { "features": {
"registration": !*DISABLE_REGISTRATION, "registration": !*DISABLE_REGISTRATION,
"captcha": { "captcha": {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment