diff --git a/files/helpers/actions.py b/files/helpers/actions.py index ba5f4dabd..7ea26a628 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -44,6 +44,12 @@ def archive_url(url): url = url.replace('https://instagram.com/p/', 'https://imginn.com/p/') gevent.spawn(_archiveorg, url) +def snappy_report(post, reason): + flag = Flag(post_id=post.id, user_id=SNAPPY_ID, reason=reason) + g.db.add(flag) + message = f'@Snappy reported [{post.title}]({post.shortlink})\n\n> {reason}' + send_repeatable_notification(post.author_id, message) + def execute_snappy(post:Submission, v:User): ghost = post.ghost @@ -77,11 +83,9 @@ def execute_snappy(post:Submission, v:User): g.db.add(vote) post.downvotes += 1 if body.startswith('OP is a Trump supporter'): - flag = Flag(post_id=post.id, user_id=SNAPPY_ID, reason='Trump supporter') - g.db.add(flag) + snappy_report(post, 'Trump supporter') elif body.startswith('You had your chance. Downvoted and reported'): - flag = Flag(post_id=post.id, user_id=SNAPPY_ID, reason='Retard') - g.db.add(flag) + snappy_report(post, 'Retard') elif body.startswith('▲') or body.startswith(':#marseyupvote'): if body.startswith('▲'): body = body[1:] vote = Vote(user_id=SNAPPY_ID, diff --git a/files/routes/reporting.py b/files/routes/reporting.py index b5eb028e9..f5c4b5768 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -65,6 +65,10 @@ def flag_post(pid, v): flag = Flag(post_id=post.id, user_id=v.id, reason=reason) g.db.add(flag) + if v.id != post.author_id: + message = f'@{v.username} reported [{post.title}]({post.shortlink})\n\n> {reason}' + send_repeatable_notification(post.author_id, message) + return {"message": "Post reported!"} @@ -89,9 +93,12 @@ def flag_comment(cid, v): if len(reason) > 350: abort(400, "Too long!") flag = CommentFlag(comment_id=comment.id, user_id=v.id, reason=reason) - g.db.add(flag) + if v.id != comment.author_id: + message = f'@{v.username} reported your [comment]({comment.shortlink})\n\n> {reason}' + send_repeatable_notification(comment.author_id, message) + return {"message": "Comment reported!"}