Compare commits
4 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
795eef4bda | ||
|
|
3ad8424d17 | ||
|
|
83feb5a5cf | ||
|
|
0dd97f3d7e |
@@ -16,9 +16,15 @@ pub async fn torrent_finished_handler(
|
|||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
Query(params): Query<TorrentFinishedQuery>,
|
Query(params): Query<TorrentFinishedQuery>,
|
||||||
) -> StatusCode {
|
) -> StatusCode {
|
||||||
tracing::info!("Torrent finished notification received: {} ({})", params.name, params.hash);
|
tracing::info!("WEBHOOK: Received notification from rTorrent. Name: {:?}, Hash: {:?}", params.name, params.hash);
|
||||||
|
|
||||||
let message = format!("Torrent tamamlandı: {}", params.name);
|
let torrent_name = if params.name.is_empty() || params.name == "$d.name=" {
|
||||||
|
"Bilinmeyen Torrent".to_string()
|
||||||
|
} else {
|
||||||
|
params.name.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
let message = format!("Torrent tamamlandı: {}", torrent_name);
|
||||||
|
|
||||||
// 1. Send to active SSE clients (for Toast)
|
// 1. Send to active SSE clients (for Toast)
|
||||||
let notification = SystemNotification {
|
let notification = SystemNotification {
|
||||||
@@ -33,13 +39,13 @@ pub async fn torrent_finished_handler(
|
|||||||
let push_store = state.push_store.clone();
|
let push_store = state.push_store.clone();
|
||||||
let title = "Torrent Tamamlandı".to_string();
|
let title = "Torrent Tamamlandı".to_string();
|
||||||
let body = message;
|
let body = message;
|
||||||
let torrent_name = params.name.clone();
|
let name_for_log = torrent_name.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
tracing::info!("Attempting to send Web Push notification for torrent: {}", torrent_name);
|
tracing::info!("Attempting to send Web Push notification for torrent: {}", name_for_log);
|
||||||
match crate::push::send_push_notification(&push_store, &title, &body).await {
|
match crate::push::send_push_notification(&push_store, &title, &body).await {
|
||||||
Ok(_) => tracing::info!("Web Push notification sent successfully for: {}", torrent_name),
|
Ok(_) => tracing::info!("Web Push notification task completed for: {}", name_for_log),
|
||||||
Err(e) => tracing::error!("Failed to send Web Push notification for {}: {:?}", torrent_name, e),
|
Err(e) => tracing::error!("Failed to send Web Push notification for {}: {:?}", name_for_log, e),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,10 +201,18 @@ pub async fn send_push_notification(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("Failed to build push message: {}", e);
|
let err_debug = format!("{:?}", e);
|
||||||
// Specific handling for encryption errors - often means invalid keys
|
let err_display = format!("{}", e);
|
||||||
if format!("{:?}", e).contains("encrypting") {
|
tracing::error!("Failed to build push message for {}: (Debug: {}) (Display: {})", subscription.endpoint, err_debug, err_display);
|
||||||
tracing::warn!("Encryption error for subscriber {}, removing suspect subscription", subscription.endpoint);
|
|
||||||
|
// Broaden error matching to catch various encryption and auth failures
|
||||||
|
let is_critical_error = err_debug.to_lowercase().contains("encrypt")
|
||||||
|
|| err_debug.to_lowercase().contains("vapid")
|
||||||
|
|| err_debug.to_lowercase().contains("unauthorized")
|
||||||
|
|| err_debug.to_lowercase().contains("unknown error");
|
||||||
|
|
||||||
|
if is_critical_error {
|
||||||
|
tracing::warn!("Critical push error detected, removing invalid subscription: {}", subscription.endpoint);
|
||||||
let _ = store.remove_subscription(&subscription.endpoint).await;
|
let _ = store.remove_subscription(&subscription.endpoint).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user