From 0a5af9f35fc74db67740170103181eb4c927dbc8 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Thu, 20 Oct 2022 23:02:23 +0800 Subject: [PATCH] stop use 114514 --- src/api/operation.rs | 4 +++- src/rds_models.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/operation.rs b/src/api/operation.rs index 8772106..7ff956f 100644 --- a/src/api/operation.rs +++ b/src/api/operation.rs @@ -182,7 +182,9 @@ pub async fn block(bi: Form, user: CurrentUser, db: Db, rconn: RdsCo let curr = if blk.add(&nh_to_block).await? > 0 { BlockCounter::count_incr(&rconn, &nh_to_block).await? } else { - 114514 + BlockCounter::get_count(&rconn, &nh_to_block) + .await? + .unwrap_or_default() }; BlockDictCache::init(&user.namehash, pid, &rconn) diff --git a/src/rds_models.rs b/src/rds_models.rs index da6be76..bbb2199 100644 --- a/src/rds_models.rs +++ b/src/rds_models.rs @@ -241,7 +241,7 @@ impl BlockedUsers { pub struct BlockCounter; impl BlockCounter { - pub async fn count_incr(rconn: &RdsConn, namehash: &str) -> RedisResult { + pub async fn count_incr(rconn: &RdsConn, namehash: &str) -> RedisResult { rconn.clone().hincr(KEY_BLOCKED_COUNTER, namehash, 1).await }