Merge pull request #35 from heikkari/34

This commit is contained in:
Paul Makles
2021-08-15 23:45:12 +01:00
committed by GitHub
3 changed files with 19 additions and 2 deletions

View File

@@ -152,6 +152,17 @@ impl User {
user.status = None;
}
// If the user's status is `Presence::Invisible`, return it as `Presence::Offline`
if let Some(mut status) = user.status {
if let Some(presence) = status.presence {
if presence == Presence::Invisible {
status.presence = Some(Presence::Offline);
user.status = Some(status);
user.online = Some(False);
}
}
}
user.profile = None;
user
}

View File

@@ -116,7 +116,13 @@ async fn accept(stream: TcpStream) {
}
} {
if let Ok(user) = (Ref { id: id.clone() }).fetch_user().await {
let is_invisible = if let Some(status) = user.status {
if let Some(presence) = status.presence {
presence == Presence::Invisible
}
};
let was_online = is_online(&id);
{
match USERS.write() {
Ok(mut map) => {
@@ -152,7 +158,7 @@ async fn accept(stream: TcpStream) {
Ok(payload) => {
send(payload);
if !was_online {
if !was_online && !is_invisible {
ClientboundNotification::UserUpdate {
id: id.clone(),
data: json!({

View File

@@ -5,7 +5,7 @@ use rocket::serde::json::Value;
#[get("/<target>")]
pub async fn req(user: User, target: Ref) -> Result<Value> {
let target = target.fetch_user().await?;
let mut target = target.fetch_user().await?;
let perm = permissions::PermissionCalculator::new(&user)
.with_user(&target)