make exiles expire after 1 month

pull/222/head
Aevann 2024-02-12 16:50:59 +02:00
parent cd054bdb03
commit 7d2d1d502a
2 changed files with 10 additions and 5 deletions

View File

@ -251,11 +251,11 @@ FEATURES = {
'PING_GROUPS': True, 'PING_GROUPS': True,
'BOTS': True, 'BOTS': True,
'IP_LOGGING': False, 'IP_LOGGING': False,
'BLOCK_MUTE_EXPIRY': False, 'BLOCK_MUTE_EXILE_EXPIRY': False,
} }
if SITE_NAME == 'rDrama': if SITE_NAME == 'rDrama':
FEATURES['BLOCK_MUTE_EXPIRY'] = True FEATURES['BLOCK_MUTE_EXILE_EXPIRY'] = True
CURSORMARSEY_DEFAULT = True CURSORMARSEY_DEFAULT = True
DEFAULT_COLOR = "ff459a" DEFAULT_COLOR = "ff459a"

View File

@ -88,8 +88,8 @@ def cron_fn(every_5m, every_1d, every_1mo):
_leaderboard_task() _leaderboard_task()
g.db.commit() g.db.commit()
if FEATURES['BLOCK_MUTE_EXPIRY']: if FEATURES['BLOCK_MUTE_EXILE_EXPIRY']:
_expire_blocks_mutes() _expire_blocks_mutes_exiles()
g.db.commit() g.db.commit()
if every_1mo: if every_1mo:
@ -343,7 +343,7 @@ def _give_marseybux_salary():
u.pay_account('marseybux', marseybux_salary) u.pay_account('marseybux', marseybux_salary)
send_repeatable_notification(u.id, f"You have received your monthly janny salary of {marseybux_salary} Marseybux!") send_repeatable_notification(u.id, f"You have received your monthly janny salary of {marseybux_salary} Marseybux!")
def _expire_blocks_mutes(): def _expire_blocks_mutes_exiles():
one_month_ago = time.time() - 2629800 one_month_ago = time.time() - 2629800
blocks = g.db.query(UserBlock).filter(UserBlock.created_utc < one_month_ago) blocks = g.db.query(UserBlock).filter(UserBlock.created_utc < one_month_ago)
@ -357,3 +357,8 @@ def _expire_blocks_mutes():
send_repeatable_notification(mute.user_id, f"Your mute of @{mute.target.username} has passed 1 month and expired!") 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!") send_repeatable_notification(mute.target_id, f"@{mute.user.username}'s mute of you has passed 1 month and expired!")
g.db.delete(mute) g.db.delete(mute)
exiles = g.db.query(Exile).filter(Exile.created_utc < one_month_ago)
for exile in exiles:
send_repeatable_notification(exile.user_id, f"Your exile from /h/{exile.hole} has passed 1 month and expired!")
g.db.delete(exile)