diff --git a/src/api/comment.rs b/src/api/comment.rs index 2d0d66e..a0ea831 100644 --- a/src/api/comment.rs +++ b/src/api/comment.rs @@ -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, diff --git a/src/api/post.rs b/src/api/post.rs index 70d2c6d..aa3c502 100644 --- a/src/api/post.rs +++ b/src/api/post.rs @@ -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, diff --git a/src/cache.rs b/src/cache.rs index 36d5982..ddc1e4b 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -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))) }) diff --git a/src/models.rs b/src/models.rs index 05da0af..1830cbc 100644 --- a/src/models.rs +++ b/src/models.rs @@ -389,7 +389,7 @@ impl User { } pub async fn get_by_token(db: &Db, token: &str) -> Option { - 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 { diff --git a/src/rds_models.rs b/src/rds_models.rs index 223ce69..3ff4bd2 100644 --- a/src/rds_models.rs +++ b/src/rds_models.rs @@ -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 { 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 = 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) -> 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> { 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;