Handle errors sending positive reports

This commit is contained in:
Vecna 2024-07-07 11:30:39 -04:00
parent 84d431e21a
commit 135d2c6b02
2 changed files with 22 additions and 23 deletions

View File

@ -126,22 +126,22 @@ impl Censor {
}
let (cred, _) = &self.lox_credentials.get(fingerprint).unwrap();
let pr = PositiveReport::from_lox_credential(
if let Ok(pr) = PositiveReport::from_lox_credential(
*fingerprint,
None,
cred,
get_lox_pub(&config.la_pubkeys),
config.country.clone(),
)
.unwrap();
if config
.tp_net
.request("/positivereport".to_string(), pr.to_json().into_bytes())
.await
.is_err()
{
// failed to send positive report
return false;
) {
if config
.tp_net
.request("/positivereport".to_string(), pr.to_json().into_bytes())
.await
.is_err()
{
// failed to send positive report
return false;
}
}
true
}

View File

@ -589,16 +589,15 @@ impl User {
bridge.first_positive_report = get_date();
}
positive_reports.push(
PositiveReport::from_lox_credential(
fingerprint,
None,
&self.primary_cred,
get_lox_pub(&config.la_pubkeys),
config.country.to_string(),
)
.unwrap(),
);
if let Ok(pr) = PositiveReport::from_lox_credential(
fingerprint,
None,
&self.primary_cred,
get_lox_pub(&config.la_pubkeys),
config.country.to_string(),
) {
positive_reports.push(pr)
}
}
}
}
@ -628,7 +627,7 @@ impl User {
level_up(
&config.la_net,
&self.primary_cred,
&reachcred.unwrap(),
&reachcred.unwrap(), // must be Some
get_lox_pub(&config.la_pubkeys),
get_reachability_pub(&config.la_pubkeys),
)
@ -806,7 +805,7 @@ impl User {
level_up(
&config.la_net,
&self.primary_cred,
&reachcred.unwrap(),
&reachcred.unwrap(), // must be Some
get_lox_pub(&config.la_pubkeys),
get_reachability_pub(&config.la_pubkeys),
)