From 57ca9f41d3808731e60c40c00469985a2c28b52b Mon Sep 17 00:00:00 2001 From: hole-thu Date: Mon, 20 Dec 2021 13:05:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=91=E7=AE=A1=E7=90=86=E5=91=98=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E8=A2=AB=E6=8B=89=E9=BB=91=E4=B8=8E=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 2305f3d..db1f585 100644 --- a/utils.py +++ b/utils.py @@ -76,6 +76,9 @@ def map_post(p, name, mc=50): } if is_admin(name): r['hot_score'] = p.hot_score + if rds.sismember(RDS_KEY_DANGEROUS_USERS, p.name_hash): + r['dangerous_user'] = p.name_hash[:4] + r['blocked_count'] = rds.hget(RDS_KEY_BLOCKED_COUNT, p.name_hash) return r @@ -134,7 +137,12 @@ def map_comment(p, name): 'pid': p.id, 'text': '' if blocked else c.content, 'timestamp': c.timestamp, - 'can_del': check_can_del(name, c.name_hash) + 'can_del': check_can_del(name, c.name_hash), + **({ + 'dangerous_user': c.name_hash[:4] if rds.sismember( + RDS_KEY_DANGEROUS_USERS, c.name_hash) else None, + 'blocked_count': rds.hget(RDS_KEY_BLOCKED_COUNT, c.name_hash) + } if is_admin(name) else {}) } for c in p.comments if not (c.deleted and gen_name_id(c.name_hash) >= 0) ]