forked from rDrama/rDrama
1
0
Fork 0

tweaking offsite mentions a little

master
Aevann1 2022-07-10 15:02:24 +02:00
parent 969841bb37
commit 9ea0f46250
3 changed files with 9 additions and 21 deletions

View File

@ -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

View File

@ -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'<p>New {mention_str}: <a href="https://old.reddit.com{permalink}' \
f'?context=89" rel="nofollow noopener noreferrer" target="_blank">' \
f'https://old.reddit.com{permalink}?context=89</a></p>{text}' \
f"""<p>New {mention_str} by <a href="https://old.reddit.com/u/{author}" rel="nofollow noopener noreferrer" target="_blank">/u/{author}</a></p><p><a href="https://old.reddit.com{permalink}?context=89" rel="nofollow noopener noreferrer" target="_blank">https://old.reddit.com{permalink}?context=89</a></p>{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)

View File

@ -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):