From 8472104315318b40748fed0dfa8eace7ad0f25aa Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 13 Jun 2023 03:55:54 +0200 Subject: [PATCH] Run mobile push requests in background --- src/api/push.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/api/push.rs b/src/api/push.rs index 3c39c0ae85..4b60424002 100644 --- a/src/api/push.rs +++ b/src/api/push.rs @@ -265,16 +265,17 @@ async fn send_to_push_relay(data: Value) { }; let auth_header = format!("Bearer {}", &auth_push_token); - - if let Err(e) = get_reqwest_client() - .post(CONFIG.push_relay_uri() + "/push/send") - .header(ACCEPT, "application/json") - .header(CONTENT_TYPE, "application/json") - .header(AUTHORIZATION, auth_header) - .json(&data) - .send() - .await - { - error!("An error occured while sending a send update to the push relay: {}", e); - }; + tokio::task::spawn(async move { + if let Err(e) = get_reqwest_client() + .post(CONFIG.push_relay_uri() + "/push/send") + .header(ACCEPT, "application/json") + .header(CONTENT_TYPE, "application/json") + .header(AUTHORIZATION, auth_header) + .json(&data) + .send() + .await + { + error!("An error occured while sending a send update to the push relay: {}", e); + }; + }); }