From 9ea0f46250c868f3de703b5ccc3cbfe3412411d8 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 10 Jul 2022 15:02:24 +0200 Subject: [PATCH] tweaking offsite mentions a little --- files/helpers/const.py | 8 ++++---- files/helpers/offsitementions.py | 14 +++++--------- files/routes/admin.py | 8 -------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index fc910daac5..8af8d749b9 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -825,13 +825,13 @@ NOTIF_MODACTION_PREFIX = '[Modaction] ' NOTIF_MODACTION_JL_MIN = 2 REDDIT_NOTIFS_JL_MIN = 1 -REDDIT_NOTIFS_SITE = [] +REDDIT_NOTIFS_SITE = [SITE_NAME] REDDIT_NOTIFS_USERS = {} if SITE != 'localhost': - REDDIT_NOTIFS_SITE = [SITE] + REDDIT_NOTIFS_SITE.append(SITE) -if SITE_NAME == 'rDrama': +if SITE == 'rdrama.net': REDDIT_NOTIFS_SITE.append(['rdrama', 'marsey',]) REDDIT_NOTIFS_USERS = { 'idio3': IDIO_ID, @@ -842,7 +842,7 @@ if SITE_NAME == 'rDrama': 'the_homocracy': HOMO_ID, } elif SITE_NAME == 'WPD': - REDDIT_NOTIFS_SITE.append(['watchpeopledie', 'makemycoffin',]) + REDDIT_NOTIFS_SITE.append(['watchpeopledie', 'makemycoffin']) discounts = { # Big Spender badges, 2pp additive discount each diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index 4eb295a62c..6062b8f080 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -25,8 +25,6 @@ def offsite_mentions_task(): if const.REDDIT_NOTIFS_USERS: for query, send_user in const.REDDIT_NOTIFS_USERS.items(): - if not send_user: continue - user_mentions = get_mentions([query]) notify_mentions([send_user], user_mentions, mention_str='mention of you') @@ -57,6 +55,7 @@ def get_mentions(queries): mentions.append({ 'permalink': i['permalink'], + 'author': i['author'], 'text': text, }) @@ -64,18 +63,17 @@ def get_mentions(queries): def notify_mentions(send_to, mentions, mention_str='site mention'): for m in mentions: + author = m['author'] permalink = m['permalink'] text = sanitize(m['text']) notif_text = \ - f'

New {mention_str}: ' \ - f'https://old.reddit.com{permalink}?context=89

{text}' \ + f"""

New {mention_str} by /u/{author}

https://old.reddit.com{permalink}?context=89

{text}""" existing_comment = g.db.query(Comment.id).filter_by( author_id=const.AUTOJANNY_ID, parent_submission=None, body_html=notif_text).one_or_none() - if existing_comment: continue + if existing_comment: break new_comment = Comment( author_id=const.AUTOJANNY_ID, @@ -88,6 +86,4 @@ def notify_mentions(send_to, mentions, mention_str='site mention'): for user_id in send_to: notif = Notification(comment_id=new_comment.id, user_id=user_id) - g.db.add(notif) - - + g.db.add(notif) \ No newline at end of file diff --git a/files/routes/admin.py b/files/routes/admin.py index 4d8ebdfacd..a3389fd13a 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -21,14 +21,6 @@ import requests from urllib.parse import quote, urlencode -@app.get('/confidential') -@admin_level_required(3) -def confidential(v): - if v.id != AEVANN_ID: abort(403) - - resp = make_response(send_from_directory('assets', 'confedntial')) - return resp - @app.post('/kippy') @admin_level_required(3) def kippy(v):