Skip to content

Commit

Permalink
Fix removing of sandbox tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Apr 17, 2024
1 parent d167f9c commit 794fbf9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ async fn wakeup(
info!("sending notifications to {} devices", tokens.len());
metrics.set_heartbeat_token_count(tokens.len());

for device_token in tokens {
info!("notify: {}", device_token);
for key_device_token in tokens {
info!("notify: {}", key_device_token);

let (client, device_token) =
if let Some(sandbox_token) = device_token.strip_prefix("sandbox:") {
if let Some(sandbox_token) = key_device_token.strip_prefix("sandbox:") {
(sandbox_client, sandbox_token)
} else {
(production_client, device_token.as_str())
(production_client, key_device_token.as_str())
};

// Send silent notification.
Expand Down Expand Up @@ -90,13 +90,19 @@ async fn wakeup(
}
},
Err(ResponseError(res)) => {
info!("Removing token {} due to error {:?}.", &device_token, res);
if let Err(err) = db.remove(device_token) {
error!("failed to remove {}: {:?}", &device_token, err);
info!(
"Removing token {} due to error {:?}.",
&key_device_token, res
);
if let Err(err) = db.remove(&key_device_token) {
error!("failed to remove {}: {:?}", &key_device_token, err);
}
}
Err(err) => {
error!("failed to send notification: {}, {:?}", device_token, err);
error!(
"failed to send notification: {}, {:?}",
key_device_token, err
);
}
}
}
Expand Down

0 comments on commit 794fbf9

Please sign in to comment.