From 64659825801b52624b6faa9af786844766530ca0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 15 Oct 2022 12:08:14 +0200 Subject: [PATCH] decouple v.last_active from the calc_users --- files/helpers/wrappers.py | 14 ++++++++------ files/routes/comments.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 6072a86af..6bd5672a8 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -15,11 +15,6 @@ def calc_users(v): if v: if session["session_id"] in loggedout: del loggedout[session["session_id"]] loggedin[v.id] = timestamp - # Check against last_active + ACTIVE_TIME to reduce frequency of - # UPDATEs in exchange for a ±ACTIVE_TIME margin of error. - if (v.last_active + LOGGEDIN_ACTIVE_TIME) < timestamp: - v.last_active = timestamp - g.db.add(v) else: ua = str(user_agents.parse(g.agent)) if 'spider' not in ua.lower() and 'bot' not in ua.lower(): @@ -75,7 +70,14 @@ def get_logged_in_user(): g.v = v - if v: v.poor = session.get('poor') + if v: + v.poor = session.get('poor') + # Check against last_active + ACTIVE_TIME to reduce frequency of + # UPDATEs in exchange for a ±ACTIVE_TIME margin of error. + timestamp = int(time.time()) + if (v.last_active + LOGGEDIN_ACTIVE_TIME) < timestamp: + v.last_active = timestamp + g.db.add(v) if AEVANN_ID and request.headers.get("Cf-Ipcountry") == 'EG': if v and not v.username.startswith('Aev'): diff --git a/files/routes/comments.py b/files/routes/comments.py index d80bb272e..0efbd291f 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -255,7 +255,7 @@ def comment(v): if parent.author.any_block_exists(v) and v.admin_level < PERMS['POST_COMMENT_MODERATION']: abort(403, "You can't reply to users who have blocked you or users that you have blocked.") - is_bot = v.id != BBBB_ID and v.client or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID)) + is_bot = v.id != BBBB_ID and v.client or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID) execute_antispam_comment_check(body, v)