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 (cred, _) = &self.lox_credentials.get(fingerprint).unwrap();
let pr = PositiveReport::from_lox_credential( if let Ok(pr) = PositiveReport::from_lox_credential(
*fingerprint, *fingerprint,
None, None,
cred, cred,
get_lox_pub(&config.la_pubkeys), get_lox_pub(&config.la_pubkeys),
config.country.clone(), config.country.clone(),
) ) {
.unwrap(); if config
if config .tp_net
.tp_net .request("/positivereport".to_string(), pr.to_json().into_bytes())
.request("/positivereport".to_string(), pr.to_json().into_bytes()) .await
.await .is_err()
.is_err() {
{ // failed to send positive report
// failed to send positive report return false;
return false; }
} }
true true
} }

View File

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