mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2025-03-14 17:37:12 -04:00
refactor: clippy suggestions
This commit is contained in:
parent
d73cde2844
commit
b4234eae25
src
@ -15,7 +15,6 @@ use tracing::info;
|
||||
/// Bulk load JSONL data from STDIN to the database specified in config.toml (or ./nostr.db as a default).
|
||||
/// The database must already exist, this will not create a new one.
|
||||
/// Tested against schema v13.
|
||||
|
||||
pub fn main() -> Result<()> {
|
||||
let _trace_sub = tracing_subscriber::fmt::try_init();
|
||||
println!("Nostr-rs-relay Bulk Loader");
|
||||
|
@ -121,7 +121,7 @@ fn body_contains_user(username: &str, address: &str, bytes: &hyper::body::Bytes)
|
||||
// get the pubkey for the requested user
|
||||
let check_name = names_map.get(username).and_then(serde_json::Value::as_str);
|
||||
// ensure the address is a match
|
||||
Ok(check_name.map_or(false, |x| x == address))
|
||||
Ok(check_name == Some(address))
|
||||
}
|
||||
|
||||
impl Verifier {
|
||||
@ -243,7 +243,11 @@ impl Verifier {
|
||||
let response_content_length = match response.body().size_hint().upper() {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
info!("missing content length header for account {:?} at URL: {}", nip.to_string(), url);
|
||||
info!(
|
||||
"missing content length header for account {:?} at URL: {}",
|
||||
nip.to_string(),
|
||||
url
|
||||
);
|
||||
return Ok(UserWebVerificationStatus::Unknown);
|
||||
}
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ impl ClnRestPaymentProcessor {
|
||||
.ok_or(ConfigError::NotFound("rune_path".to_string()))?;
|
||||
let rune = String::from_utf8(fs::read(rune_path)?)
|
||||
.map_err(|_| ConfigError::Message("Rune should be UTF8".to_string()))?;
|
||||
let mut rune_header = HeaderValue::from_str(&rune.trim())
|
||||
let mut rune_header = HeaderValue::from_str(rune.trim())
|
||||
.map_err(|_| ConfigError::Message("Invalid Rune header".to_string()))?;
|
||||
rune_header.set_sensitive(true);
|
||||
|
||||
|
@ -55,12 +55,12 @@ pub enum InvoiceStatus {
|
||||
Expired,
|
||||
}
|
||||
|
||||
impl ToString for InvoiceStatus {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for InvoiceStatus {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
InvoiceStatus::Paid => "Paid".to_string(),
|
||||
InvoiceStatus::Unpaid => "Unpaid".to_string(),
|
||||
InvoiceStatus::Expired => "Expired".to_string(),
|
||||
InvoiceStatus::Paid => write!(f, "Paid"),
|
||||
InvoiceStatus::Unpaid => write!(f, "Unpaid"),
|
||||
InvoiceStatus::Expired => write!(f, "Expired"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,28 +177,25 @@ ON CONFLICT (id) DO NOTHING"#,
|
||||
let tag_val = &tag[1];
|
||||
// only single-char tags are searchable
|
||||
let tag_char_opt = single_char_tagname(tag_name);
|
||||
match &tag_char_opt {
|
||||
Some(_) => {
|
||||
// if tag value is lowercase hex;
|
||||
if is_lower_hex(tag_val) && (tag_val.len() % 2 == 0) {
|
||||
sqlx::query("INSERT INTO tag (event_id, \"name\", value, value_hex) VALUES($1, $2, NULL, $3) \
|
||||
ON CONFLICT (event_id, \"name\", value, value_hex) DO NOTHING")
|
||||
if tag_char_opt.is_some() {
|
||||
// if tag value is lowercase hex;
|
||||
if is_lower_hex(tag_val) && (tag_val.len() % 2 == 0) {
|
||||
sqlx::query("INSERT INTO tag (event_id, \"name\", value, value_hex) VALUES($1, $2, NULL, $3) \
|
||||
ON CONFLICT (event_id, \"name\", value, value_hex) DO NOTHING")
|
||||
.bind(&id_blob)
|
||||
.bind(tag_name)
|
||||
.bind(hex::decode(tag_val).ok())
|
||||
.execute(&mut tx)
|
||||
.await?;
|
||||
} else {
|
||||
sqlx::query("INSERT INTO tag (event_id, \"name\", value, value_hex) VALUES($1, $2, $3, NULL) \
|
||||
ON CONFLICT (event_id, \"name\", value, value_hex) DO NOTHING")
|
||||
.bind(tag_name)
|
||||
.bind(hex::decode(tag_val).ok())
|
||||
.execute(&mut tx)
|
||||
.await?;
|
||||
} else {
|
||||
sqlx::query("INSERT INTO tag (event_id, \"name\", value, value_hex) VALUES($1, $2, $3, NULL) \
|
||||
ON CONFLICT (event_id, \"name\", value, value_hex) DO NOTHING")
|
||||
.bind(&id_blob)
|
||||
.bind(tag_name)
|
||||
.bind(tag_val.as_bytes())
|
||||
.execute(&mut tx)
|
||||
.await?;
|
||||
}
|
||||
.bind(tag_name)
|
||||
.bind(tag_val.as_bytes())
|
||||
.execute(&mut tx)
|
||||
.await?;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,14 +156,11 @@ impl SqliteRepo {
|
||||
let tagval = &tag[1];
|
||||
// only single-char tags are searchable
|
||||
let tagchar_opt = single_char_tagname(tagname);
|
||||
match &tagchar_opt {
|
||||
Some(_) => {
|
||||
tx.execute(
|
||||
"INSERT OR IGNORE INTO tag (event_id, name, value, kind, created_at) VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
params![ev_id, &tagname, &tagval, e.kind, e.created_at],
|
||||
)?;
|
||||
}
|
||||
None => {}
|
||||
if tagchar_opt.is_some() {
|
||||
tx.execute(
|
||||
"INSERT OR IGNORE INTO tag (event_id, name, value, kind, created_at) VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
params![ev_id, &tagname, &tagval, e.kind, e.created_at],
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user