fix some warnings

This commit is contained in:
2026-03-24 03:18:41 +08:00
parent 8e386d98d0
commit 0487427342
5 changed files with 21 additions and 16 deletions

View File

@@ -33,8 +33,8 @@ pub struct CommentOutput {
blocked: bool,
}
pub async fn c2output<'r>(
p: &'r Post,
pub async fn c2output(
p: &Post,
cs: &[Comment],
user: &CurrentUser,
cached_block_dict: &HashMap<String, bool>,

View File

@@ -87,7 +87,11 @@ async fn p2output(p: &Post, user: &CurrentUser, db: &Db, rconn: &RdsConn) -> Api
Ok(PostOutput {
pid: p.id,
room_id: p.room_id,
text: can_view.then_some(p.content.clone()).unwrap_or_default(),
text: if can_view {
p.content.clone()
} else {
Default::default()
},
cw: (!p.cw.is_empty()).then_some(p.cw.clone()),
n_attentions: p.n_attentions,
n_comments: p.n_comments,

View File

@@ -180,7 +180,7 @@ impl PostListCache {
let list_ref = post_list_cache()
.try_get_with(self.key.clone(), async {
let mut items: Vec<(i64, i32)> =
query_posts.await?.iter().map(|p| self.p2pair(&p)).collect();
query_posts.await?.iter().map(|p| self.p2pair(p)).collect();
items.sort_by(|a, b| a.0.cmp(&b.0));
Ok(Arc::new(RwLock::new(items)))
})

View File

@@ -389,7 +389,7 @@ impl User {
}
pub async fn get_by_token(db: &Db, token: &str) -> Option<Self> {
let mut cacher = UserCache::init(token);
let cacher = UserCache::init(token);
if let Some(u) = cacher.get().await {
return Some(u);
}
@@ -406,7 +406,7 @@ impl User {
_ => token,
};
// dbg!(token);
let mut cacher = UserCache::init(token);
let cacher = UserCache::init(token);
if let Some(u) = cacher.get().await {
Some(u)
} else {

View File

@@ -176,7 +176,9 @@ impl Systemlog {
pub async fn create(&self, rconn: &RdsConn) -> RedisResult<()> {
let mut rconn = rconn.clone();
if rconn.llen::<&str, isize>(KEY_SYSTEMLOG).await? > SYSTEMLOG_MAX_LEN {
rconn.ltrim(KEY_SYSTEMLOG, 0, SYSTEMLOG_MAX_LEN - 1).await?;
rconn
.ltrim::<_, ()>(KEY_SYSTEMLOG, 0, SYSTEMLOG_MAX_LEN - 1)
.await?;
}
rconn
.lpush(KEY_SYSTEMLOG, serde_json::to_string(&self).unwrap())
@@ -258,9 +260,9 @@ pub struct CustomTitle;
impl CustomTitle {
async fn gen_and_set_secret(rconn: &RdsConn, title: &str) -> RedisResult<String> {
let secret = random_string(8);
rconn
() = rconn
.clone()
.set_ex(KEY_TITLE_SECRET!(&title), &secret, CUSTOM_TITLE_KEEP_TIME)
.set_ex::<_, _, ()>(KEY_TITLE_SECRET!(&title), &secret, CUSTOM_TITLE_KEEP_TIME)
.await?;
Ok(secret)
}
@@ -283,8 +285,8 @@ impl CustomTitle {
if let Some(t) = old_title {
clear_title_from_admins(&rconn, &t).await?;
}
rconn.hset(KEY_CUSTOM_TITLE, namehash, title).await?;
rconn.hset(KEY_CUSTOM_TITLE, title, namehash).await?;
() = rconn.hset(KEY_CUSTOM_TITLE, namehash, title).await?;
() = rconn.hset(KEY_CUSTOM_TITLE, title, namehash).await?;
Ok(Self::gen_and_set_secret(&rconn, title).await?)
}
}
@@ -297,7 +299,7 @@ impl CustomTitle {
Ok(if let Some(title) = t {
let s: Option<String> = rconn.clone().get(KEY_TITLE_SECRET!(title)).await?;
let secret = if let Some(ss) = s {
rconn
() = rconn
.clone()
.expire(KEY_TITLE_SECRET!(title), CUSTOM_TITLE_KEEP_TIME as i64)
.await?;
@@ -345,7 +347,7 @@ impl PollOption {
init!(i32, "hole_thu:poll_opts:{}");
pub async fn set_list(&mut self, v: &Vec<String>) -> RedisResult<()> {
self.rconn.del(&self.key).await?;
() = self.rconn.del(&self.key).await?;
self.rconn.rpush(&self.key, v).await
}
@@ -409,9 +411,8 @@ pub async fn get_candidate_list(rconn: &RdsConn) -> RedisResult<Vec<String>> {
pub async fn clear_title_from_admins(rconn: &RdsConn, title: &str) -> RedisResult<()> {
let mut rconn = rconn.clone();
rconn.srem(KEY_CANDIDATE, title).await?;
rconn.srem(KEY_ADMIN, title).await?;
Ok(())
() = rconn.srem(KEY_CANDIDATE, title).await?;
rconn.srem(KEY_ADMIN, title).await
}
pub(crate) use clear_all;