mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 21:47:02 +00:00
Switch to async Rust and break all logic.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use super::events::Notification;
|
||||
use super::websocket;
|
||||
// use super::websocket;
|
||||
use crate::database::get_collection;
|
||||
|
||||
use hive_pubsub::backend::mongo::{listen_thread, MongodbPubSub};
|
||||
use hive_pubsub::backend::mongo::MongodbPubSub;
|
||||
use hive_pubsub::PubSub;
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde_json::to_string;
|
||||
@@ -12,12 +12,12 @@ static HIVE: OnceCell<MongodbPubSub<String, String, Notification>> = OnceCell::n
|
||||
|
||||
pub fn init_hive() {
|
||||
let hive = MongodbPubSub::new(
|
||||
|ids, notification| {
|
||||
|_ids, notification| {
|
||||
if let Ok(data) = to_string(¬ification) {
|
||||
debug!("Pushing out notification. {}", data);
|
||||
if let Err(err) = websocket::publish(ids, data) {
|
||||
error!("Failed to publish notification through WebSocket! {}", err);
|
||||
}
|
||||
// if let Err(err) = websocket::publish(ids, data) {
|
||||
// error!("Failed to publish notification through WebSocket! {}", err);
|
||||
// }
|
||||
} else {
|
||||
error!("Failed to serialise notification.");
|
||||
}
|
||||
@@ -25,7 +25,7 @@ pub fn init_hive() {
|
||||
get_collection("hive"),
|
||||
);
|
||||
|
||||
listen_thread(hive.clone());
|
||||
//listen_thread(hive.clone());
|
||||
|
||||
if HIVE.set(hive).is_err() {
|
||||
panic!("Failed to set global pubsub instance.");
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub mod events;
|
||||
pub mod hive;
|
||||
pub mod websocket;
|
||||
// pub mod websocket;
|
||||
|
||||
@@ -57,7 +57,7 @@ impl Handler for Client {
|
||||
FindOneOptions::builder()
|
||||
.projection(doc! { "_id": 1 })
|
||||
.build(),
|
||||
);
|
||||
).await;
|
||||
|
||||
if let Ok(result) = user {
|
||||
if let Some(doc) = result {
|
||||
Reference in New Issue
Block a user