mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
chore(task_queue): add logging
This commit is contained in:
@@ -5,9 +5,7 @@ use crate::{
|
||||
util::result::{Error, Result},
|
||||
};
|
||||
|
||||
use mongodb::{
|
||||
bson::{doc, to_bson, DateTime, Document},
|
||||
};
|
||||
use mongodb::bson::{doc, to_bson, DateTime};
|
||||
use rocket::serde::json::Value;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ulid::Ulid;
|
||||
@@ -325,15 +323,3 @@ impl Message {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
async fn update_channels_last_message(channels: &Collection, channel_id: &String, set: &Document) {
|
||||
channels
|
||||
.update_one(
|
||||
doc! { "_id": channel_id },
|
||||
doc! { "$set": set },
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.expect("Server should not run with no, or a corrupted db");
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
// Queue Type: Debounced
|
||||
// TODO: Group similar events together with $in.
|
||||
|
||||
use std::{collections::HashMap, time::{Duration, Instant}};
|
||||
|
||||
use async_channel::{ Sender, Receiver, bounded };
|
||||
use log::info;
|
||||
use mongodb::{bson::doc, options::UpdateOptions};
|
||||
|
||||
use crate::database::*;
|
||||
@@ -76,6 +79,8 @@ pub async fn run() {
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
|
||||
info!("Added mentions for {} in {}.", user, channel);
|
||||
},
|
||||
AckEvent::AckMessage { id } => {
|
||||
unreads.update_one(
|
||||
@@ -95,6 +100,8 @@ pub async fn run() {
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
|
||||
info!("User {} acknowledged {}.", user, channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
use std::{collections::HashMap, time::{Duration, Instant}};
|
||||
|
||||
use async_channel::{ Sender, Receiver, bounded };
|
||||
use log::info;
|
||||
use mongodb::bson::doc;
|
||||
|
||||
use crate::database::*;
|
||||
@@ -51,7 +52,7 @@ pub async fn run() {
|
||||
// Commit any due tasks to the database.
|
||||
for key in &keys {
|
||||
if let Some(Task { id, is_dm, .. }) = tasks.remove(key) {
|
||||
let mut set = doc! { "last_message_id": id.clone() };
|
||||
let mut set = doc! { "last_message_id": &id };
|
||||
|
||||
if is_dm {
|
||||
set.insert("active", true);
|
||||
@@ -65,6 +66,8 @@ pub async fn run() {
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
|
||||
info!("Updated last_message_id for {} to {}.", key, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Queue Type: Linear
|
||||
use async_channel::{ Sender, Receiver, bounded };
|
||||
use log::info;
|
||||
use mongodb::bson::{doc, to_bson};
|
||||
|
||||
use crate::{database::*, notifications::events::ClientboundNotification};
|
||||
@@ -38,6 +39,7 @@ pub async fn run() {
|
||||
)
|
||||
.await
|
||||
{
|
||||
info!("Generated embeds for {}.", &id);
|
||||
ClientboundNotification::MessageUpdate {
|
||||
id,
|
||||
channel: channel.clone(),
|
||||
|
||||
@@ -63,6 +63,8 @@ pub async fn run() {
|
||||
|
||||
let msg = builder.build().unwrap();
|
||||
client.send(msg).await.ok();
|
||||
|
||||
info!("Sent Web Push notification to {:?}.", session.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user