Ajusta auto-minimização do chat web e unifica realtime no desktop
This commit is contained in:
parent
c65e37e232
commit
3d45fe3b04
10 changed files with 279 additions and 635 deletions
|
|
@ -83,6 +83,8 @@ pub struct ChatSessionSummary {
|
|||
pub struct ChatMessagesResponse {
|
||||
pub messages: Vec<ChatMessage>,
|
||||
pub has_session: bool,
|
||||
#[serde(default)]
|
||||
pub unread_count: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -259,6 +261,36 @@ pub async fn send_message(
|
|||
.map_err(|e| format!("Falha ao parsear resposta de send: {e}"))
|
||||
}
|
||||
|
||||
pub async fn mark_messages_read(
|
||||
base_url: &str,
|
||||
token: &str,
|
||||
ticket_id: &str,
|
||||
message_ids: &[String],
|
||||
) -> Result<(), String> {
|
||||
let url = format!("{}/api/machines/chat/read", base_url);
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"machineToken": token,
|
||||
"ticketId": ticket_id,
|
||||
"messageIds": message_ids,
|
||||
});
|
||||
|
||||
let response = CHAT_CLIENT
|
||||
.post(&url)
|
||||
.json(&payload)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Falha na requisicao de mark read: {e}"))?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
let status = response.status();
|
||||
let body = response.text().await.unwrap_or_default();
|
||||
return Err(format!("Mark read falhou: status={}, body={}", status, body));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// UPLOAD DE ARQUIVOS
|
||||
// ============================================================================
|
||||
|
|
@ -835,4 +867,3 @@ pub fn set_chat_minimized(app: &tauri::AppHandle, ticket_id: &str, minimized: bo
|
|||
crate::log_info!("Chat {} -> minimized={}", ticket_id, minimized);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue