forked from MarseyWorld/MarseyWorld
fds
parent
0c9597b563
commit
6973e957e2
|
@ -9,7 +9,7 @@ from files.routes.front import comment_idlist
|
||||||
from pusher_push_notifications import PushNotifications
|
from pusher_push_notifications import PushNotifications
|
||||||
from flask import *
|
from flask import *
|
||||||
from files.__main__ import app, limiter
|
from files.__main__ import app, limiter
|
||||||
from sqlalchemy.orm import contains_eager
|
|
||||||
|
|
||||||
site = environ.get("DOMAIN").strip()
|
site = environ.get("DOMAIN").strip()
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ def api_comment(v):
|
||||||
Comment.parent_comment_id == parent_comment_id,
|
Comment.parent_comment_id == parent_comment_id,
|
||||||
Comment.parent_submission == parent_submission,
|
Comment.parent_submission == parent_submission,
|
||||||
CommentAux.body == body
|
CommentAux.body == body
|
||||||
).options(contains_eager(Comment.comment_aux)).first()
|
).first()
|
||||||
if existing:
|
if existing:
|
||||||
return {"error": f"You already made that comment: {existing.permalink}"}, 409
|
return {"error": f"You already made that comment: {existing.permalink}"}, 409
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ def api_comment(v):
|
||||||
CommentAux.body.op(
|
CommentAux.body.op(
|
||||||
'<->')(body) < app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"],
|
'<->')(body) < app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"],
|
||||||
Comment.created_utc > cutoff
|
Comment.created_utc > cutoff
|
||||||
).options(contains_eager(Comment.comment_aux)).all()
|
).all()
|
||||||
|
|
||||||
threshold = app.config["COMMENT_SPAM_COUNT_THRESHOLD"]
|
threshold = app.config["COMMENT_SPAM_COUNT_THRESHOLD"]
|
||||||
if v.age >= (60 * 60 * 24 * 7):
|
if v.age >= (60 * 60 * 24 * 7):
|
||||||
|
@ -671,7 +671,7 @@ def edit_comment(cid, v):
|
||||||
CommentAux.body.op(
|
CommentAux.body.op(
|
||||||
'<->')(body) < app.config["SPAM_SIMILARITY_THRESHOLD"],
|
'<->')(body) < app.config["SPAM_SIMILARITY_THRESHOLD"],
|
||||||
Comment.created_utc > cutoff
|
Comment.created_utc > cutoff
|
||||||
).options(contains_eager(Comment.comment_aux)).all()
|
).all()
|
||||||
|
|
||||||
threshold = app.config["SPAM_SIMILAR_COUNT_THRESHOLD"]
|
threshold = app.config["SPAM_SIMILAR_COUNT_THRESHOLD"]
|
||||||
if v.age >= (60 * 60 * 24 * 30):
|
if v.age >= (60 * 60 * 24 * 30):
|
||||||
|
|
|
@ -3,8 +3,7 @@ import re
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from flask import *
|
from flask import *
|
||||||
from files.__main__ import app
|
from files.__main__ import app
|
||||||
import random
|
|
||||||
from sqlalchemy.orm import contains_eager
|
|
||||||
|
|
||||||
query_regex=re.compile("(\w+):(\S+)")
|
query_regex=re.compile("(\w+):(\S+)")
|
||||||
valid_params=[
|
valid_params=[
|
||||||
|
@ -143,11 +142,6 @@ def searchposts(v):
|
||||||
cutoff = 0
|
cutoff = 0
|
||||||
posts = posts.filter(Submission.created_utc >= cutoff)
|
posts = posts.filter(Submission.created_utc >= cutoff)
|
||||||
|
|
||||||
posts=posts.options(
|
|
||||||
contains_eager(Submission.submission_aux),
|
|
||||||
contains_eager(Submission.author),
|
|
||||||
)
|
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
posts = posts.order_by(Submission.created_utc.desc())
|
posts = posts.order_by(Submission.created_utc.desc())
|
||||||
elif sort == "old":
|
elif sort == "old":
|
||||||
|
@ -245,9 +239,6 @@ def searchcomments(v):
|
||||||
cutoff = 0
|
cutoff = 0
|
||||||
comments = comments.filter(Comment.created_utc >= cutoff)
|
comments = comments.filter(Comment.created_utc >= cutoff)
|
||||||
|
|
||||||
comments=comments.options(contains_eager(Comment.comment_aux))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
|
|
|
@ -11,7 +11,6 @@ from files.mail import *
|
||||||
from flask import *
|
from flask import *
|
||||||
from files.__main__ import app, limiter
|
from files.__main__ import app, limiter
|
||||||
from pusher_push_notifications import PushNotifications
|
from pusher_push_notifications import PushNotifications
|
||||||
from sqlalchemy.orm import contains_eager
|
|
||||||
|
|
||||||
site = environ.get("DOMAIN").strip()
|
site = environ.get("DOMAIN").strip()
|
||||||
|
|
||||||
|
@ -228,7 +227,7 @@ def message2(v, username):
|
||||||
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.sentto == user.id,
|
Comment.sentto == user.id,
|
||||||
CommentAux.body == message,
|
CommentAux.body == message,
|
||||||
).options(contains_eager(Comment.comment_aux)).first()
|
).first()
|
||||||
if existing: return redirect('/notifications?messages=true')
|
if existing: return redirect('/notifications?messages=true')
|
||||||
|
|
||||||
text = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', message)
|
text = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', message)
|
||||||
|
@ -288,7 +287,7 @@ def messagereply(v):
|
||||||
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.sentto == user.id,
|
Comment.sentto == user.id,
|
||||||
CommentAux.body == message,
|
CommentAux.body == message,
|
||||||
).options(contains_eager(Comment.comment_aux)).first()
|
).first()
|
||||||
if existing:
|
if existing:
|
||||||
if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}')
|
if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}')
|
||||||
else: return redirect(f'/notifications?messages=true#comment-{existing.id}')
|
else: return redirect(f'/notifications?messages=true#comment-{existing.id}')
|
||||||
|
|
Loading…
Reference in New Issue