|
|
@@ -12,6 +12,7 @@ pub enum NegativeReportError {
|
|
|
DateInFuture,
|
|
|
FailedToDeserialize, // couldn't deserialize to SerializableNegativeReport
|
|
|
InvalidCountryCode,
|
|
|
+ MissingCountryCode,
|
|
|
}
|
|
|
|
|
|
/// A report that the user was unable to connect to the bridge
|
|
|
@@ -20,7 +21,7 @@ pub struct NegativeReport {
|
|
|
pub fingerprint: [u8; 20],
|
|
|
/// some way to prove knowledge of bridge
|
|
|
bridge_pok: ProofOfBridgeKnowledge,
|
|
|
- /// user's country code, may be an empty string
|
|
|
+ /// user's country code
|
|
|
pub country: String,
|
|
|
/// today's Julian date
|
|
|
pub date: u32,
|
|
|
@@ -116,7 +117,10 @@ pub struct SerializableNegativeReport {
|
|
|
|
|
|
impl SerializableNegativeReport {
|
|
|
pub fn to_report(self) -> Result<NegativeReport, NegativeReportError> {
|
|
|
- if self.country != "" && !COUNTRY_CODES.contains(self.country.as_str()) {
|
|
|
+ if self.country == "" {
|
|
|
+ return Err(NegativeReportError::MissingCountryCode);
|
|
|
+ }
|
|
|
+ if !COUNTRY_CODES.contains(self.country.as_str()) {
|
|
|
return Err(NegativeReportError::InvalidCountryCode);
|
|
|
}
|
|
|
if self.date > get_date().into() {
|