moved user status data validation from front to backend

This commit is contained in:
2026-03-09 12:45:34 +08:00
parent 69cfebee3d
commit 03ae3e0829
4 changed files with 23 additions and 8 deletions

View File

@@ -122,6 +122,10 @@ pub fn on_friend_user_status(payload: Payload, _socket: RawClient) {
if let Ok(data) =
utils::extract_and_parse::<FriendUserStatusPayload>(payload, "friend-user-status")
{
if !data.status.has_presence_content() {
return;
}
emitter::emit_to_frontend_typed(&FriendUserStatusChanged(data));
}
}

View File

@@ -1,6 +1,6 @@
use once_cell::sync::Lazy;
use tauri_specta::Event as _;
use tauri::async_runtime::{self, JoinHandle};
use tauri_specta::Event as _;
use tokio::sync::Mutex;
use tokio::time::Duration;
use tracing::warn;
@@ -24,6 +24,10 @@ pub async fn report_user_status(status: UserStatusPayload) {
handle.abort();
}
if !status.has_presence_content() {
return;
}
if let Err(e) = UserStatusChanged(status.clone()).emit(crate::get_app_handle()) {
warn!("Failed to emit user-status-changed event: {e}");
}