fixes and cleanup
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use std::error::Error;
|
||||
use std::fmt::Write as _;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use crate::util::requester;
|
||||
use dashmap::DashMap;
|
||||
use once_cell::sync::Lazy;
|
||||
use serde_json::json;
|
||||
use crate::util::requester;
|
||||
use std::error::Error;
|
||||
use std::fmt::Write as _;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
// Global cache: Map<ErrorSignature, LastSentTimestamp>
|
||||
static ERROR_CACHE: Lazy<DashMap<String, u64>> = Lazy::new(DashMap::new);
|
||||
@@ -42,11 +42,11 @@ pub async fn send_discord_error_report(
|
||||
|
||||
if let Some(_) = ERROR_CACHE.get(&error_signature) {
|
||||
// if now - *last_sent < COOLDOWN_SECONDS {
|
||||
// Error is still in cooldown, skip sending
|
||||
return;
|
||||
// Error is still in cooldown, skip sending
|
||||
return;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// Update the cache with the current timestamp
|
||||
ERROR_CACHE.insert(error_signature, now);
|
||||
// ---------------------------
|
||||
@@ -104,4 +104,4 @@ pub async fn send_discord_error_report(
|
||||
|
||||
let mut requester = requester::Requester::new();
|
||||
let _ = requester.post_json(&webhook_url, &payload, vec![]).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user