mirror of
https://github.com/freedit-org/freedit.git
synced 2026-04-25 03:05:37 -04:00
clippy
This commit is contained in:
@@ -103,32 +103,32 @@ pub(crate) async fn admin_view(
|
||||
"users" => {
|
||||
let key = ivec_to_u32(&k);
|
||||
let (one, _): (User, usize) = bincode::decode_from_slice(&v, standard())?;
|
||||
let one_fmt = unescape(&format!("{:?}", one)).unwrap();
|
||||
let one_fmt = unescape(&format!("{one:?}")).unwrap();
|
||||
ones.push(format!("{key}: {one_fmt}"));
|
||||
}
|
||||
"solos" => {
|
||||
let key = ivec_to_u32(&k);
|
||||
let (one, _): (Solo, usize) = bincode::decode_from_slice(&v, standard())?;
|
||||
let one_fmt = unescape(&format!("{:?}", one)).unwrap();
|
||||
let one_fmt = unescape(&format!("{one:?}")).unwrap();
|
||||
ones.push(format!("{key}: {one_fmt}"));
|
||||
}
|
||||
"inns" => {
|
||||
let key = ivec_to_u32(&k);
|
||||
let (one, _): (Inn, usize) = bincode::decode_from_slice(&v, standard())?;
|
||||
let one_fmt = unescape(&format!("{:?}", one)).unwrap();
|
||||
let one_fmt = unescape(&format!("{one:?}")).unwrap();
|
||||
ones.push(format!("{key}: {one_fmt}"));
|
||||
}
|
||||
"posts" => {
|
||||
let key = ivec_to_u32(&k);
|
||||
let (one, _): (Post, usize) = bincode::decode_from_slice(&v, standard())?;
|
||||
let one_fmt = unescape(&format!("{:?}", one)).unwrap();
|
||||
let one_fmt = unescape(&format!("{one:?}")).unwrap();
|
||||
ones.push(format!("{key}: {one_fmt}"));
|
||||
}
|
||||
"post_comments" => {
|
||||
let pid = u8_slice_to_u32(&k[0..4]);
|
||||
let cid = u8_slice_to_u32(&k[4..8]);
|
||||
let (one, _): (Comment, usize) = bincode::decode_from_slice(&v, standard())?;
|
||||
let one_fmt = unescape(&format!("{:?}", one)).unwrap();
|
||||
let one_fmt = unescape(&format!("{one:?}")).unwrap();
|
||||
ones.push(format!("pid: {pid}, cid: {cid}, comment: {one_fmt}",));
|
||||
}
|
||||
"user_comments" => {
|
||||
@@ -257,7 +257,7 @@ pub(crate) async fn admin_view(
|
||||
"feeds" => {
|
||||
let key = ivec_to_u32(&k);
|
||||
let (one, _): (Feed, usize) = bincode::decode_from_slice(&v, standard())?;
|
||||
let one_fmt = unescape(&format!("{:?}", one)).unwrap();
|
||||
let one_fmt = unescape(&format!("{one:?}")).unwrap();
|
||||
ones.push(format!("{key}: {one_fmt}"));
|
||||
}
|
||||
"feed_errs" | "pub_keys" => {
|
||||
@@ -273,7 +273,7 @@ pub(crate) async fn admin_view(
|
||||
"items" => {
|
||||
let key = ivec_to_u32(&k);
|
||||
let (one, _): (Item, usize) = bincode::decode_from_slice(&v, standard())?;
|
||||
let one_fmt = unescape(&format!("{:?}", one)).unwrap();
|
||||
let one_fmt = unescape(&format!("{one:?}")).unwrap();
|
||||
ones.push(format!("{key}: {one_fmt}"));
|
||||
}
|
||||
"home_pages" => {
|
||||
@@ -287,7 +287,7 @@ pub(crate) async fn admin_view(
|
||||
}
|
||||
"tan" => {
|
||||
let id = String::from_utf8_lossy(&k);
|
||||
ones.push(format!("{id}: {:?}", v));
|
||||
ones.push(format!("{id}: {v:?}"));
|
||||
}
|
||||
"messages" => {
|
||||
let mid = u8_slice_to_u32(&k);
|
||||
|
||||
@@ -662,7 +662,7 @@ pub(super) async fn update(
|
||||
};
|
||||
item_links_tree.insert(&item.link, u32_to_ivec(item_id))?;
|
||||
set_one(db, "items", item_id, &item)?;
|
||||
tan_tree.insert(format!("item{}", item_id), &[])?;
|
||||
tan_tree.insert(format!("item{item_id}"), &[])?;
|
||||
item_ids.push((item_id, source_item.updated));
|
||||
};
|
||||
}
|
||||
@@ -692,7 +692,7 @@ pub(super) async fn update(
|
||||
};
|
||||
item_links_tree.insert(&item.link, u32_to_ivec(item_id))?;
|
||||
set_one(db, "items", item_id, &item)?;
|
||||
tan_tree.insert(format!("item{}", item_id), &[])?;
|
||||
tan_tree.insert(format!("item{item_id}"), &[])?;
|
||||
item_ids.push((item_id, source_item.updated));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SyntaxPreprocessor<'a, I> {
|
||||
return Some(Event::Html(
|
||||
latex2mathml::latex_to_mathml(&c, latex2mathml::DisplayStyle::Inline)
|
||||
.unwrap_or_else(|e| {
|
||||
format!("Convert math {} failed, error: {}, check with https://osanshouo.github.io/latex2mathml-web/index.html", c, e, )
|
||||
format!("Convert math {c} failed, error: {e}, check with https://osanshouo.github.io/latex2mathml-web/index.html")
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
@@ -113,7 +113,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SyntaxPreprocessor<'a, I> {
|
||||
return Some(Event::Html(
|
||||
latex2mathml::latex_to_mathml(&c, latex2mathml::DisplayStyle::Block)
|
||||
.unwrap_or_else(|e| {
|
||||
format!("Convert math {} failed, error: {}, check with https://osanshouo.github.io/latex2mathml-web/index.html", c, e, )
|
||||
format!("Convert math {c} failed, error: {e}, check with https://osanshouo.github.io/latex2mathml-web/index.html")
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
|
||||
@@ -811,7 +811,7 @@ pub(crate) async fn edit_post_post(
|
||||
claim.update_last_write(&DB)?;
|
||||
|
||||
if inn.is_open_access() {
|
||||
DB.open_tree("tan")?.insert(format!("post{}", pid), &[])?;
|
||||
DB.open_tree("tan")?.insert(format!("post{pid}"), &[])?;
|
||||
}
|
||||
|
||||
let target = format!("/post/{iid}/{pid}");
|
||||
@@ -1613,11 +1613,10 @@ pub(crate) async fn post(
|
||||
<p>Warning</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
This post was published <b>{} days ago</b>. The information described in this article may have changed.
|
||||
This post was published <b>{diff} days ago</b>. The information described in this article may have changed.
|
||||
</div>
|
||||
</article>
|
||||
"#,
|
||||
diff
|
||||
"#
|
||||
);
|
||||
content.push_str(&post.content.to_html(&DB)?);
|
||||
content
|
||||
@@ -1879,7 +1878,7 @@ pub(crate) async fn comment_post(
|
||||
|
||||
if inn.is_open_access() {
|
||||
DB.open_tree("tan")?
|
||||
.insert(format!("comt{}/{}", pid, cid), &[])?;
|
||||
.insert(format!("comt{pid}/{cid}"), &[])?;
|
||||
}
|
||||
|
||||
let target = format!("/post/{iid}/{pid}");
|
||||
@@ -1948,8 +1947,7 @@ pub(crate) async fn comment_delete(
|
||||
|
||||
inn_add_index(&DB, iid, pid, timestamp as u32, inn_type)?;
|
||||
|
||||
DB.open_tree("tan")?
|
||||
.remove(format!("comt{}/{}", pid, cid))?;
|
||||
DB.open_tree("tan")?.remove(format!("comt{pid}/{cid}"))?;
|
||||
|
||||
let target = format!("/post/{pid}/{cid}");
|
||||
Ok(Redirect::to(&target))
|
||||
|
||||
@@ -49,7 +49,7 @@ pub(crate) async fn message(
|
||||
.get(u32_to_ivec(uid))?
|
||||
.map(|s| String::from_utf8_lossy(&s).to_string());
|
||||
|
||||
let title = format!("Sending e2ee Message to {}", uid);
|
||||
let title = format!("Sending e2ee Message to {uid}");
|
||||
let user: User = get_one(&DB, "users", uid)?;
|
||||
|
||||
let page_message = PageMessage {
|
||||
@@ -93,7 +93,7 @@ pub(crate) async fn message_post(
|
||||
let k = [&u32_to_ivec(uid), &u32_to_ivec(mid)].concat();
|
||||
DB.open_tree("user_message")?.insert(k, &[])?;
|
||||
|
||||
let redirect = format!("/user/{}", uid);
|
||||
let redirect = format!("/user/{uid}");
|
||||
Ok(Redirect::to(&redirect))
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ pub(super) enum PostStatus {
|
||||
|
||||
impl Display for PostStatus {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
write!(f, "{self:?}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,9 +566,9 @@ mod filters {
|
||||
Ok(v)
|
||||
} else {
|
||||
let Some(en) = I18N.get(&("en", s)) else {
|
||||
panic!("No translation for {} in en", s);
|
||||
panic!("No translation for {s} in en");
|
||||
};
|
||||
error!("No translation for {} in {}", s, lang);
|
||||
error!("No translation for {s} in {lang}");
|
||||
Ok(en)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ pub(crate) async fn solo_post(
|
||||
claim.update_last_write(&DB)?;
|
||||
|
||||
if solo_type == SoloType::Public {
|
||||
DB.open_tree("tan")?.insert(format!("solo{}", sid), &[])?;
|
||||
DB.open_tree("tan")?.insert(format!("solo{sid}"), &[])?;
|
||||
}
|
||||
|
||||
let target = if input.reply_to > 0 {
|
||||
@@ -584,7 +584,7 @@ pub(crate) async fn solo_delete(
|
||||
let k = [&u32_to_ivec(solo.uid), &sid_ivec].concat();
|
||||
DB.open_tree("user_solos")?.remove(k)?;
|
||||
|
||||
DB.open_tree("tan")?.remove(format!("solo{}", sid))?;
|
||||
DB.open_tree("tan")?.remove(format!("solo{sid}"))?;
|
||||
|
||||
if solo.uid != claim.uid {
|
||||
add_notification(&DB, solo.uid, NtType::SoloDelete, claim.uid, solo.sid)?;
|
||||
|
||||
@@ -222,7 +222,7 @@ impl Tan {
|
||||
for i in &db.open_tree("items")? {
|
||||
let (k, _) = i?;
|
||||
let id = u8_slice_to_u32(&k);
|
||||
batch.insert(format!("item{}", id).as_bytes(), &[]);
|
||||
batch.insert(format!("item{id}").as_bytes(), &[]);
|
||||
}
|
||||
|
||||
tan_tree.apply_batch(batch)?;
|
||||
@@ -380,7 +380,7 @@ impl OutSearch {
|
||||
"item" => {
|
||||
let item: Item = get_one(db, "items", id1).ok()?;
|
||||
Some(Self {
|
||||
url: format!("/feed/read/{}", id1),
|
||||
url: format!("/feed/read/{id1}"),
|
||||
title: item.title,
|
||||
date: ts_to_date(item.updated),
|
||||
uid: None,
|
||||
|
||||
@@ -191,7 +191,7 @@ pub(crate) async fn image_delete(
|
||||
let target = if let Some(referer) = get_referer(referer) {
|
||||
referer
|
||||
} else {
|
||||
format!("/gallery/{}", uid)
|
||||
format!("/gallery/{uid}")
|
||||
};
|
||||
Ok(Redirect::to(&target))
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ impl From<u8> for Role {
|
||||
|
||||
impl Display for Role {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
write!(f, "{self:?}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ impl From<u8> for InnRole {
|
||||
|
||||
impl Display for InnRole {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
write!(f, "{self:?}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -943,7 +943,7 @@ pub(crate) async fn signup() -> Result<impl IntoResponse, AppError> {
|
||||
|
||||
/// Captcha with digits
|
||||
///
|
||||
/// From: https://github.com/daniel-e/captcha/blob/master/examples/captcha.rs
|
||||
/// From: <https://github.com/daniel-e/captcha/blob/master/examples/captcha.rs>
|
||||
fn captcha_digits() -> Captcha {
|
||||
let mut c = Captcha::new();
|
||||
c.set_chars(&['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']);
|
||||
|
||||
Reference in New Issue
Block a user