From 3bf846698ed41c3ef2e6e37e85c54ba5596af7a5 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 12 Feb 2024 14:10:46 +0200 Subject: [PATCH] add block mute expiry for rdrama --- files/helpers/config/const.py | 54 +++++++++++++++++++---------------- files/helpers/cron.py | 19 ++++++++++++ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index a3ab3668b..8a4dc13c6 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -227,7 +227,36 @@ PERMS = { # Minimum admin_level to perform action. 'INFINITE_CURRENCY': 5, } +FEATURES = { + 'MARSEYBUX': True, + 'AWARDS': True, + 'CHAT': True, + 'PINS': True, + 'PRONOUNS': False, + 'BADGES': True, + 'HATS': True, + 'HOUSES': True, + 'GAMBLING': True, + 'USERS_PROFILE_BANNER': True, + 'USERS_PROFILE_BODYTEXT': True, + 'USERS_PROFILE_SONG': True, + 'USERS_PERMANENT_WORD_FILTERS': False, + 'USERS_SUICIDE': True, + 'MARKUP_COMMANDS': True, + 'REPOST_DETECTION': True, + 'PATRON_ICONS': False, + 'EMOJI_SUBMISSIONS': True, + 'HAT_SUBMISSIONS': True, + 'NSFW_MARKING': True, + 'PING_GROUPS': True, + 'BOTS': True, + 'IP_LOGGING': False, + 'BLOCK_MUTE_EXPIRY': False, +} + if SITE_NAME == 'rDrama': + FEATURES['BLOCK_MUTE_EXPIRY'] = True + CURSORMARSEY_DEFAULT = True DEFAULT_COLOR = "ff459a" @@ -415,31 +444,6 @@ HOLE_MARSEY_URL_LENGTH = 60 ### SITE SPECIFIC CONSTANTS ################################################################################ -FEATURES = { - 'MARSEYBUX': True, - 'AWARDS': True, - 'CHAT': True, - 'PINS': True, - 'PRONOUNS': False, - 'BADGES': True, - 'HATS': True, - 'HOUSES': True, - 'GAMBLING': True, - 'USERS_PROFILE_BANNER': True, - 'USERS_PROFILE_BODYTEXT': True, - 'USERS_PROFILE_SONG': True, - 'USERS_PERMANENT_WORD_FILTERS': False, - 'USERS_SUICIDE': True, - 'MARKUP_COMMANDS': True, - 'REPOST_DETECTION': True, - 'PATRON_ICONS': False, - 'EMOJI_SUBMISSIONS': True, - 'HAT_SUBMISSIONS': True, - 'NSFW_MARKING': True, - 'PING_GROUPS': True, - 'BOTS': True, - 'IP_LOGGING': False, -} HOUSES = ["Furry","Femboy","Vampire","Racist","Edgy"] WERKZEUG_ERROR_DESCRIPTIONS = { diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 95f71ee56..8160833db 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -88,6 +88,10 @@ def cron_fn(every_5m, every_1d, every_1mo): _leaderboard_task() g.db.commit() + if FEATURES['BLOCK_MUTE_EXPIRY']: + _expire_blocks_mutes() + g.db.commit() + if every_1mo: _give_marseybux_salary() g.db.commit() @@ -338,3 +342,18 @@ def _give_marseybux_salary(): marseybux_salary = u.admin_level * 10000 u.pay_account('marseybux', marseybux_salary) send_repeatable_notification(u.id, f"You have received your monthly janny salary of {marseybux_salary} Marseybux!") + +def _expire_blocks_mutes(): + one_month_ago = time.time() - 2629800 + + blocks = g.db.query(UserBlock).filter(UserBlock.created_utc < one_month_ago) + for block in blocks: + send_repeatable_notification(block.user_id, f"Your block of @{block.target.username} has passed 1 month and expired!") + send_repeatable_notification(block.target_id, f"@{block.user.username}'s block of you has passed 1 month and expired!") + g.db.delete(block) + + mutes = g.db.query(UserMute).filter(UserMute.created_utc < one_month_ago) + for mute in mutes: + send_repeatable_notification(mute.user_id, f"Your mute of @{mute.target.username} has passed 1 month and expired!") + send_repeatable_notification(mute.target_id, f"@{mute.user.username}'s mute of you has passed 1 month and expired!") + g.db.delete(mute)