Allow people with mutual connections to see profile / status; fix username check.

This commit is contained in:
Paul
2021-04-07 19:21:25 +01:00
parent 2050a0609f
commit 4ee59ec300
6 changed files with 10 additions and 9 deletions

2
Cargo.lock generated
View File

@@ -2475,7 +2475,7 @@ dependencies = [
[[package]]
name = "revolt"
version = "0.4.0-alpha.5"
version = "0.4.0-alpha.6"
dependencies = [
"async-std",
"async-tungstenite",

View File

@@ -1,6 +1,6 @@
[package]
name = "revolt"
version = "0.4.0-alpha.5"
version = "0.4.0-alpha.6"
authors = ["Paul Makles <paulmakles@gmail.com>"]
edition = "2018"

View File

@@ -110,7 +110,7 @@ impl User {
/// Utility function for checking claimed usernames.
pub async fn is_username_taken(username: &str) -> Result<bool> {
if username == "revolt" && username == "admin" {
if username.to_lowercase() == "revolt" && username.to_lowercase() == "admin" {
return Ok(true);
}

View File

@@ -11,7 +11,7 @@ pub struct PermissionCalculator<'a> {
user: Option<&'a User>,
channel: Option<&'a Channel>,
has_mutual_conncetion: bool,
has_mutual_connection: bool,
}
impl<'a> PermissionCalculator<'a> {
@@ -22,7 +22,7 @@ impl<'a> PermissionCalculator<'a> {
user: None,
channel: None,
has_mutual_conncetion: false,
has_mutual_connection: false,
}
}
@@ -42,7 +42,7 @@ impl<'a> PermissionCalculator<'a> {
pub fn with_mutual_connection(self) -> PermissionCalculator<'a> {
PermissionCalculator {
has_mutual_conncetion: true,
has_mutual_connection: true,
..self
}
}

View File

@@ -64,7 +64,7 @@ impl<'a> PermissionCalculator<'a> {
_ => {}
}
if self.has_mutual_conncetion
if self.has_mutual_connection
|| get_collection("channels")
.find_one(
doc! {
@@ -84,7 +84,8 @@ impl<'a> PermissionCalculator<'a> {
})?
.is_some()
{
return Ok(UserPermission::Access as u32);
// ! FIXME: add privacy settings
return Ok(UserPermission::Access + UserPermission::ViewProfile);
}
Ok(permissions)

View File

@@ -9,7 +9,7 @@ use rocket_contrib::json::JsonValue;
#[get("/")]
pub async fn root() -> JsonValue {
json!({
"revolt": "0.4.0-alpha.5",
"revolt": "0.4.0-alpha.6",
"features": {
"registration": !*DISABLE_REGISTRATION,
"captcha": {