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]] [[package]]
name = "revolt" name = "revolt"
version = "0.4.0-alpha.5" version = "0.4.0-alpha.6"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-tungstenite", "async-tungstenite",

View File

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

View File

@@ -110,7 +110,7 @@ impl User {
/// Utility function for checking claimed usernames. /// Utility function for checking claimed usernames.
pub async fn is_username_taken(username: &str) -> Result<bool> { 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); return Ok(true);
} }

View File

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

View File

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

View File

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