chore: clippy fix
This commit is contained in:
parent
a580ceac44
commit
1a35924e8b
@ -69,18 +69,9 @@ impl Analytics for PlausibleAnalytics {
|
|||||||
None => return Ok(()), // ignore request
|
None => return Ok(()), // ignore request
|
||||||
},
|
},
|
||||||
url: req.uri().to_string(),
|
url: req.uri().to_string(),
|
||||||
referrer: match req.headers().get_one("Referer") {
|
referrer: req.headers().get_one("Referer").map(|s| s.to_string()),
|
||||||
Some(s) => Some(s.to_string()),
|
user_agent: req.headers().get_one("User-Agent").map(|s| s.to_string()),
|
||||||
None => None,
|
xff: req.headers().get_one("X-Forwarded-For").map(|s| s.to_string()),
|
||||||
},
|
|
||||||
user_agent: match req.headers().get_one("User-Agent") {
|
|
||||||
Some(s) => Some(s.to_string()),
|
|
||||||
None => None,
|
|
||||||
},
|
|
||||||
xff: match req.headers().get_one("X-Forwarded-For") {
|
|
||||||
Some(s) => Some(s.to_string()),
|
|
||||||
None => None,
|
|
||||||
},
|
|
||||||
})?)
|
})?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ impl Database {
|
|||||||
.bind(file.width)
|
.bind(file.width)
|
||||||
.bind(file.height)
|
.bind(file.height)
|
||||||
.bind(&file.alt)
|
.bind(&file.alt)
|
||||||
.bind(&file.created);
|
.bind(file.created);
|
||||||
tx.execute(q).await?;
|
tx.execute(q).await?;
|
||||||
|
|
||||||
let q2 = sqlx::query("insert ignore into user_uploads(file,user_id) values(?,?)")
|
let q2 = sqlx::query("insert ignore into user_uploads(file,user_id) values(?,?)")
|
||||||
|
@ -147,7 +147,7 @@ async fn list_files(
|
|||||||
Ok((files, _count)) => BlossomResponse::BlobDescriptorList(Json(
|
Ok((files, _count)) => BlossomResponse::BlobDescriptorList(Json(
|
||||||
files
|
files
|
||||||
.iter()
|
.iter()
|
||||||
.map(|f| BlobDescriptor::from_upload(&settings, f))
|
.map(|f| BlobDescriptor::from_upload(settings, f))
|
||||||
.collect(),
|
.collect(),
|
||||||
)),
|
)),
|
||||||
Err(e) => BlossomResponse::error(format!("Could not list files: {}", e)),
|
Err(e) => BlossomResponse::error(format!("Could not list files: {}", e)),
|
||||||
@ -174,13 +174,13 @@ async fn upload_head(auth: BlossomAuth, settings: &State<Settings>) -> BlossomHe
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if let None = auth.x_sha_256 {
|
if auth.x_sha_256.is_none() {
|
||||||
return BlossomHead {
|
return BlossomHead {
|
||||||
msg: Some("Missing x-sha-256 header"),
|
msg: Some("Missing x-sha-256 header"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if let None = auth.x_content_type {
|
if auth.x_content_type.is_none() {
|
||||||
return BlossomHead {
|
return BlossomHead {
|
||||||
msg: Some("Missing x-content-type header"),
|
msg: Some("Missing x-content-type header"),
|
||||||
};
|
};
|
||||||
@ -313,7 +313,7 @@ async fn process_upload(
|
|||||||
BlossomResponse::error(format!("Error saving file (db): {}", e))
|
BlossomResponse::error(format!("Error saving file (db): {}", e))
|
||||||
} else {
|
} else {
|
||||||
BlossomResponse::BlobDescriptor(Json(BlobDescriptor::from_upload(
|
BlossomResponse::BlobDescriptor(Json(BlobDescriptor::from_upload(
|
||||||
&settings,
|
settings,
|
||||||
&blob.upload,
|
&blob.upload,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ async fn upload(
|
|||||||
|
|
||||||
// account for upload speeds as slow as 1MB/s (8 Mbps)
|
// account for upload speeds as slow as 1MB/s (8 Mbps)
|
||||||
let mbs = form.size / 1.megabytes().as_u64();
|
let mbs = form.size / 1.megabytes().as_u64();
|
||||||
let max_time = 60.max(mbs) as u64;
|
let max_time = 60.max(mbs);
|
||||||
if auth.event.created_at < Timestamp::now().sub(Duration::from_secs(max_time)) {
|
if auth.event.created_at < Timestamp::now().sub(Duration::from_secs(max_time)) {
|
||||||
return Nip96Response::error("Auth event timestamp out of range");
|
return Nip96Response::error("Auth event timestamp out of range");
|
||||||
}
|
}
|
||||||
@ -208,10 +208,7 @@ async fn upload(
|
|||||||
Some(c) => c.to_string(),
|
Some(c) => c.to_string(),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
blob.upload.alt = match &form.alt {
|
blob.upload.alt = form.alt.as_ref().map(|s| s.to_string());
|
||||||
Some(s) => Some(s.to_string()),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
||||||
if let Some(wh) = webhook.as_ref() {
|
if let Some(wh) = webhook.as_ref() {
|
||||||
match wh.store_file(&pubkey_vec, blob.clone()) {
|
match wh.store_file(&pubkey_vec, blob.clone()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user