|
@@ -33,7 +33,14 @@ pub async fn handle(db: &Db, req: Request<Body>) -> Result<Response<Body>, Infal
|
|
|
return Ok(prepare_header(val));
|
|
|
}
|
|
|
};
|
|
|
- let pubkey = get_negative_report_public_key(&db, date);
|
|
|
+ // Get the current key or generate a new one. Note that
|
|
|
+ // this code is only called in simulation. In
|
|
|
+ // production, users should not be able to induce Troll
|
|
|
+ // Patrol to generate new keys.
|
|
|
+ let pubkey = match get_negative_report_public_key(&db, date) {
|
|
|
+ Some(k) => Some(k),
|
|
|
+ None => new_negative_report_key(&db, date),
|
|
|
+ };
|
|
|
prepare_header(serde_json::to_string(&pubkey).unwrap())
|
|
|
}),
|
|
|
(&Method::POST, "/negativereport") => Ok::<_, Infallible>({
|