forked from rDrama/rDrama
tweaking offsite mentions a little
parent
969841bb37
commit
9ea0f46250
|
@ -825,13 +825,13 @@ NOTIF_MODACTION_PREFIX = '[Modaction] '
|
||||||
NOTIF_MODACTION_JL_MIN = 2
|
NOTIF_MODACTION_JL_MIN = 2
|
||||||
|
|
||||||
REDDIT_NOTIFS_JL_MIN = 1
|
REDDIT_NOTIFS_JL_MIN = 1
|
||||||
REDDIT_NOTIFS_SITE = []
|
REDDIT_NOTIFS_SITE = [SITE_NAME]
|
||||||
REDDIT_NOTIFS_USERS = {}
|
REDDIT_NOTIFS_USERS = {}
|
||||||
|
|
||||||
if SITE != 'localhost':
|
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_SITE.append(['rdrama', 'marsey',])
|
||||||
REDDIT_NOTIFS_USERS = {
|
REDDIT_NOTIFS_USERS = {
|
||||||
'idio3': IDIO_ID,
|
'idio3': IDIO_ID,
|
||||||
|
@ -842,7 +842,7 @@ if SITE_NAME == 'rDrama':
|
||||||
'the_homocracy': HOMO_ID,
|
'the_homocracy': HOMO_ID,
|
||||||
}
|
}
|
||||||
elif SITE_NAME == 'WPD':
|
elif SITE_NAME == 'WPD':
|
||||||
REDDIT_NOTIFS_SITE.append(['watchpeopledie', 'makemycoffin',])
|
REDDIT_NOTIFS_SITE.append(['watchpeopledie', 'makemycoffin'])
|
||||||
|
|
||||||
discounts = {
|
discounts = {
|
||||||
# Big Spender badges, 2pp additive discount each
|
# Big Spender badges, 2pp additive discount each
|
||||||
|
|
|
@ -25,8 +25,6 @@ def offsite_mentions_task():
|
||||||
|
|
||||||
if const.REDDIT_NOTIFS_USERS:
|
if const.REDDIT_NOTIFS_USERS:
|
||||||
for query, send_user in const.REDDIT_NOTIFS_USERS.items():
|
for query, send_user in const.REDDIT_NOTIFS_USERS.items():
|
||||||
if not send_user: continue
|
|
||||||
|
|
||||||
user_mentions = get_mentions([query])
|
user_mentions = get_mentions([query])
|
||||||
notify_mentions([send_user], user_mentions, mention_str='mention of you')
|
notify_mentions([send_user], user_mentions, mention_str='mention of you')
|
||||||
|
|
||||||
|
@ -57,6 +55,7 @@ def get_mentions(queries):
|
||||||
|
|
||||||
mentions.append({
|
mentions.append({
|
||||||
'permalink': i['permalink'],
|
'permalink': i['permalink'],
|
||||||
|
'author': i['author'],
|
||||||
'text': text,
|
'text': text,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -64,18 +63,17 @@ def get_mentions(queries):
|
||||||
|
|
||||||
def notify_mentions(send_to, mentions, mention_str='site mention'):
|
def notify_mentions(send_to, mentions, mention_str='site mention'):
|
||||||
for m in mentions:
|
for m in mentions:
|
||||||
|
author = m['author']
|
||||||
permalink = m['permalink']
|
permalink = m['permalink']
|
||||||
text = sanitize(m['text'])
|
text = sanitize(m['text'])
|
||||||
notif_text = \
|
notif_text = \
|
||||||
f'<p>New {mention_str}: <a href="https://old.reddit.com{permalink}' \
|
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}"""
|
||||||
f'?context=89" rel="nofollow noopener noreferrer" target="_blank">' \
|
|
||||||
f'https://old.reddit.com{permalink}?context=89</a></p>{text}' \
|
|
||||||
|
|
||||||
existing_comment = g.db.query(Comment.id).filter_by(
|
existing_comment = g.db.query(Comment.id).filter_by(
|
||||||
author_id=const.AUTOJANNY_ID,
|
author_id=const.AUTOJANNY_ID,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
body_html=notif_text).one_or_none()
|
body_html=notif_text).one_or_none()
|
||||||
if existing_comment: continue
|
if existing_comment: break
|
||||||
|
|
||||||
new_comment = Comment(
|
new_comment = Comment(
|
||||||
author_id=const.AUTOJANNY_ID,
|
author_id=const.AUTOJANNY_ID,
|
||||||
|
@ -89,5 +87,3 @@ def notify_mentions(send_to, mentions, mention_str='site mention'):
|
||||||
for user_id in send_to:
|
for user_id in send_to:
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=user_id)
|
notif = Notification(comment_id=new_comment.id, user_id=user_id)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,6 @@ import requests
|
||||||
from urllib.parse import quote, urlencode
|
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')
|
@app.post('/kippy')
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
def kippy(v):
|
def kippy(v):
|
||||||
|
|
Loading…
Reference in New Issue