parent
37986f8b0b
commit
6f6827d4d9
3 changed files with 27 additions and 5 deletions
|
|
@ -91,10 +91,15 @@ impl PushSender {
|
||||||
let client = IsahcWebPushClient::new()
|
let client = IsahcWebPushClient::new()
|
||||||
.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||||
|
|
||||||
client
|
client.send(message).await.map_err(|e| {
|
||||||
.send(message)
|
tracing::error!("Failed to send push notification: {}", e);
|
||||||
.await
|
crate::error::AppError::Internal(e.to_string())
|
||||||
.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
})?;
|
||||||
|
|
||||||
|
tracing::info!(
|
||||||
|
"Push notification sent successfully to {}",
|
||||||
|
subscription.endpoint
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,13 +140,25 @@ pub async fn execute_agent_run(
|
||||||
.await
|
.await
|
||||||
.map_err(crate::error::AppError::Database)?;
|
.map_err(crate::error::AppError::Database)?;
|
||||||
|
|
||||||
|
tracing::info!(
|
||||||
|
"Found {} task subscriptions for task {}",
|
||||||
|
subscriptions.len(),
|
||||||
|
task_id
|
||||||
|
);
|
||||||
|
|
||||||
for sub in subscriptions {
|
for sub in subscriptions {
|
||||||
let push_subs = push_subscription::Entity::find()
|
let push_subs = push_subscription::Entity::find()
|
||||||
.filter(push_subscription::Column::UserSub.eq(sub.user_sub))
|
.filter(push_subscription::Column::UserSub.eq(sub.user_sub.clone()))
|
||||||
.all(db)
|
.all(db)
|
||||||
.await
|
.await
|
||||||
.map_err(crate::error::AppError::Database)?;
|
.map_err(crate::error::AppError::Database)?;
|
||||||
|
|
||||||
|
tracing::info!(
|
||||||
|
"Found {} push subscriptions for user {}",
|
||||||
|
push_subs.len(),
|
||||||
|
sub.user_sub
|
||||||
|
);
|
||||||
|
|
||||||
for push_sub in push_subs {
|
for push_sub in push_subs {
|
||||||
let sender = _scheduler.push_sender.clone();
|
let sender = _scheduler.push_sender.clone();
|
||||||
let goal = task_response.goal.clone();
|
let goal = task_response.goal.clone();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@ pub async fn register_push(
|
||||||
Json(payload): Json<RegisterPushRequest>,
|
Json(payload): Json<RegisterPushRequest>,
|
||||||
) -> AppResult<Json<serde_json::Value>> {
|
) -> AppResult<Json<serde_json::Value>> {
|
||||||
let user_sub = user.0.sub;
|
let user_sub = user.0.sub;
|
||||||
|
tracing::info!(
|
||||||
|
"Registering push subscription for user: {} with endpoint: {}",
|
||||||
|
user_sub,
|
||||||
|
payload.endpoint
|
||||||
|
);
|
||||||
|
|
||||||
// Check if subscription exists
|
// Check if subscription exists
|
||||||
let existing = push_subscription::Entity::find()
|
let existing = push_subscription::Entity::find()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue