diff --git a/src/service/sending/sender.rs b/src/service/sending/sender.rs index a92cc195b..4f6a78ea4 100644 --- a/src/service/sending/sender.rs +++ b/src/service/sending/sender.rs @@ -1003,6 +1003,8 @@ impl Service { } } + let mut first_push_error = None; + for pdu in pdus { // Redacted events are not notification targets (we don't send push // for them) @@ -1028,15 +1030,27 @@ impl Service { .try_into() .expect("notification count can't go that high"); - let _response = self + let response = self .services .pusher .send_push_notice(&user_id, unread, &pusher, rules_for_user, &pdu) .await - .map_err(|e| (Destination::Push(user_id.clone(), pushkey.clone()), e)); + .map_err(|e| (Destination::Push(user_id.clone(), pushkey.clone()), Box::new(e))); + + if let Err(err) = response { + error!(event = %pdu.event_id, pusher = %pusher.app_display_name, "Failed to deliver push notification: {err:?}"); + + if first_push_error.is_none() { + first_push_error = Some(err); + } + } } - Ok(Destination::Push(user_id, pushkey)) + if let Some(err) = first_push_error { + Err(err) + } else { + Ok(Destination::Push(user_id, pushkey)) + } } async fn send_events_dest_federation(