Accepts ad with no pubkey

This commit is contained in:
Pascal Engélibert 2020-12-08 22:45:29 +01:00
parent 59c69765d7
commit 6a70bfc032
1 changed files with 31 additions and 28 deletions

View File

@ -121,8 +121,7 @@ pub async fn start_server(
.and(warp::get())
.and(warp::fs::dir(opt.dir.0.join(static_files::STATIC_DIR)));
let handle_new_ad =
{
let handle_new_ad = {
let handle_index = handle_index.clone();
let dbs = dbs.clone();
let cache_ads = cache_ads.clone();
@ -136,13 +135,17 @@ pub async fn start_server(
author: query.author,
password: hasher.finalize()[..].try_into().unwrap(),
price: query.price,
pubkey: (!query.pubkey.is_empty()).then_some(match format_pubkey(&query.pubkey) {
pubkey: if query.pubkey.is_empty() {
None
} else {
Some(match format_pubkey(&query.pubkey) {
Ok(pubkey) => pubkey,
Err(e) => return handle_index(&[ErrorTemplate{text: match e {
PubkeyDecodeError::BadChecksum => "La somme de contrôle de la clé publique est incorrecte.",
PubkeyDecodeError::BadFormat => "Le format de la clé publique est incorrect.",
}}])
}),
})
},
quantity: query.quantity,
time: 0,
title: query.title,