diff --git a/src/database/entities/user.rs b/src/database/entities/user.rs index a89b023b5755db9c9e430e59cd1c6e1d264dafb3..e7c0e614b60de2afe1e3d587fdc0fffae3957119 100644 --- a/src/database/entities/user.rs +++ b/src/database/entities/user.rs @@ -38,7 +38,7 @@ pub enum Presence { Online, Idle, Busy, - Invisible + Invisible, } #[derive(Validate, Serialize, Deserialize, Debug)] @@ -47,7 +47,7 @@ pub struct UserStatus { #[serde(skip_serializing_if = "Option::is_none")] text: Option<String>, #[serde(skip_serializing_if = "Option::is_none")] - presence: Option<Presence> + presence: Option<Presence>, } #[derive(Validate, Serialize, Deserialize, Debug)] diff --git a/src/database/migrations/scripts.rs b/src/database/migrations/scripts.rs index ace6f91a9ca0f5c9d7164147ca1e8d4d62b9b30d..055f2ec70b1e51fdd87b4666b0154af1dbd23772 100644 --- a/src/database/migrations/scripts.rs +++ b/src/database/migrations/scripts.rs @@ -1,8 +1,8 @@ use crate::database::get_collection; use log::info; -use serde::{Deserialize, Serialize}; use mongodb::bson::{doc, from_document}; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] struct MigrationInfo { @@ -59,21 +59,23 @@ pub async fn run_migrations(revision: i32) -> i32 { let messages = get_collection("messages"); let attachments = get_collection("attachments"); - messages.update_many( - doc! { "attachment": { "$exists": 1 } }, - doc! { "$set": { "attachment.tag": "attachments", "attachment.size": 0 } }, - None - ) - .await - .expect("Failed to update messages."); + messages + .update_many( + doc! { "attachment": { "$exists": 1 } }, + doc! { "$set": { "attachment.tag": "attachments", "attachment.size": 0 } }, + None, + ) + .await + .expect("Failed to update messages."); - attachments.update_many( - doc! { }, - doc! { "$set": { "tag": "attachments", "size": 0 } }, - None - ) - .await - .expect("Failed to update attachments."); + attachments + .update_many( + doc! {}, + doc! { "$set": { "tag": "attachments", "size": 0 } }, + None, + ) + .await + .expect("Failed to update attachments."); } // Reminder to update LATEST_REVISION when adding new migrations. diff --git a/src/main.rs b/src/main.rs index e1cc438adb5ff4dfc3f002fe2ae248768c2a50ba..48acd2bf746dd91e41c2a27fa36cc838be78ca4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ pub mod notifications; pub mod routes; pub mod util; +use async_std::task; use chrono::Duration; use futures::join; use log::info; @@ -50,10 +51,13 @@ async fn main() { }) .expect("Error setting Ctrl-C handler"); + let web_task = task::spawn(launch_web()); + let hive_task = task::spawn(notifications::hive::listen()); + join!( - launch_web(), - notifications::websocket::launch_server(), - notifications::hive::listen(), + web_task, + hive_task, + notifications::websocket::launch_server() ); }