Add basic presence tracking.

This commit is contained in:
Paul Makles
2021-01-09 20:49:36 +00:00
parent 5e70ceea01
commit f6c52de171
5 changed files with 97 additions and 54 deletions

View File

@@ -9,7 +9,9 @@ use mongodb::{
options::FindOptions,
};
pub async fn generate_ready(user: User) -> Result<ClientboundNotification> {
use super::websocket::is_online;
pub async fn generate_ready(mut user: User) -> Result<ClientboundNotification> {
let mut users = vec![];
if let Some(relationships) = &user.relations {
@@ -52,11 +54,14 @@ pub async fn generate_ready(user: User) -> Result<ClientboundNotification> {
.clone(),
);
user.online = Some(is_online(&user.id));
users.push(user);
}
}
}
user.online = Some(is_online(&user.id));
users.push(user);
Ok(ClientboundNotification::Ready { users })