This commit is contained in:
parent
779500d22e
commit
42a78c529d
5 changed files with 74 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use crate::error::AppResult;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use web_push::*;
|
||||
|
||||
pub struct PushSender {
|
||||
|
|
@ -56,6 +57,8 @@ impl PushSender {
|
|||
subscription: &PushSubscription,
|
||||
title: &str,
|
||||
body: &str,
|
||||
task_id: Option<Uuid>,
|
||||
run_id: Option<Uuid>,
|
||||
) -> AppResult<()> {
|
||||
let subscription_info = SubscriptionInfo::new(
|
||||
subscription.endpoint.clone(),
|
||||
|
|
@ -81,6 +84,8 @@ impl PushSender {
|
|||
let payload = serde_json::to_vec(&serde_json::json!({
|
||||
"title": title,
|
||||
"body": body,
|
||||
"task_id": task_id,
|
||||
"run_id": run_id,
|
||||
}))
|
||||
.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,13 @@ pub async fn execute_agent_run(
|
|||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = sender
|
||||
.send_notification(&sub_data, &format!("Task Completed: {}", status), &goal)
|
||||
.send_notification(
|
||||
&sub_data,
|
||||
&format!("Task Completed: {}", status),
|
||||
&goal,
|
||||
Some(task_id),
|
||||
Some(run_id),
|
||||
)
|
||||
.await
|
||||
{
|
||||
tracing::error!("Failed to send notification in background task: {}", e);
|
||||
|
|
|
|||
|
|
@ -201,6 +201,8 @@ impl Scheduler {
|
|||
&sub_data,
|
||||
&format!("Scheduled Task Completed: {}", status),
|
||||
&goal,
|
||||
Some(task_id),
|
||||
Some(run_id),
|
||||
)
|
||||
.await;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue