diff --git a/files/classes/comment.py b/files/classes/comment.py index cce22d1f8..856bdd99f 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -355,7 +355,7 @@ class Comment(Base): if not v: return False - if v.filter_words and any([x in self.body for x in v.filter_words]): return True + if v.filter_words and self.body and any([x in self.body for x in v.filter_words]): return True if self.is_banned or (self.author and self.author.shadowbanned): return True diff --git a/files/helpers/const.py b/files/helpers/const.py index 1d6aa0f6d..547814dc5 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -5,6 +5,10 @@ SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() SLURS = { + "retarded": "r-slurred", + "retard": "r-slur", + "tard": "r-slur", + "faggot": "cute twink", "faggot": "cute twink", "fag": "cute twink", "pedophile": "libertarian", diff --git a/files/routes/awards.py b/files/routes/awards.py index 00122d491..100738c86 100755 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -47,6 +47,7 @@ def shop(v): "description": "Makes flies swarm a post.", "icon": "fas fa-poop", "color": "text-black-50", + "owned": 0, "price": 500 }, "fireflies": { @@ -55,6 +56,7 @@ def shop(v): "description": "Puts fireflies on the post.", "icon": "fas fa-sparkles", "color": "text-warning", + "owned": 0, "price": 500 }, "train": { @@ -63,6 +65,7 @@ def shop(v): "description": "Summons a train on the post.", "icon": "fas fa-train", "color": "text-pink", + "owned": 0, "price": 500 }, "pin": { @@ -71,6 +74,7 @@ def shop(v): "description": "Pins the post.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", + "owned": 0, "price": 750 }, "unpin": { @@ -79,6 +83,7 @@ def shop(v): "description": "Removes 1 hour from the pin duration of the post.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", + "owned": 0, "price": 1000 }, "flairlock": { @@ -87,6 +92,7 @@ def shop(v): "description": "Sets a flair for the author and locks it or 24 hours.", "icon": "fas fa-lock", "color": "text-black", + "owned": 0, "price": 1250 }, "agendaposter": { @@ -95,6 +101,7 @@ def shop(v): "description": "Forces the agendaposter theme on the author for 24 hours.", "icon": "fas fa-snooze", "color": "text-purple", + "owned": 0, "price": 2000 }, "ban": { @@ -103,6 +110,7 @@ def shop(v): "description": "Bans the author for a day.", "icon": "fas fa-gavel", "color": "text-danger", + "owned": 0, "price": 3000 }, "unban": { @@ -111,6 +119,7 @@ def shop(v): "description": "Removes 1 day from the ban duration of the recipient.", "icon": "fas fa-gavel", "color": "text-success", + "owned": 0, "price": 3500 }, "grass": { @@ -119,6 +128,7 @@ def shop(v): "description": "Ban the author permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", "icon": "fas fa-seedling", "color": "text-success", + "owned": 0, "price": 10000 }, } @@ -130,6 +140,7 @@ def shop(v): "description": "Makes flies swarm a post.", "icon": "fas fa-poop", "color": "text-black-50", + "owned": 0, "price": 500 }, "fireflies": { @@ -138,6 +149,7 @@ def shop(v): "description": "Puts fireflies on the post.", "icon": "fas fa-sparkles", "color": "text-warning", + "owned": 0, "price": 500 }, "train": { @@ -146,6 +158,7 @@ def shop(v): "description": "Summons a train on the post.", "icon": "fas fa-train", "color": "text-pink", + "owned": 0, "price": 50 }, "pin": { @@ -154,6 +167,7 @@ def shop(v): "description": "Pins the post.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", + "owned": 0, "price": 750 }, "unpin": { @@ -162,27 +176,13 @@ def shop(v): "description": "Removes 1 hour from the pin duration of the post.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", + "owned": 0, "price": 1000 }, } - query = g.db.query( - User.id, User.username, User.patron, User.namecolor, - AwardRelationship.kind.label('last_award_kind'), func.count(AwardRelationship.id).label('last_award_count') - ).filter(AwardRelationship.submission_id==None, AwardRelationship.comment_id==None, User.patron > 0) \ - .group_by(User.username, User.patron, User.id, User.namecolor, AwardRelationship.kind) \ - .order_by(User.patron.desc(), AwardRelationship.kind.desc()) \ - .join(User).filter(User.id == v.id).all() + for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all(): AWARDS[useraward.kind]["owned"] += 1 - owned = [] - for row in (r._asdict() for r in query): - kind = row['last_award_kind'] - if kind in AWARDS.keys(): - award = AWARDS[kind] - award["owned_num"] = row['last_award_count'] - owned.append(award) - - owned = sorted(owned, key=lambda x: x['price']) if v.patron: for val in AWARDS.values(): if v.patron == 1: val["price"] = int(val["price"]*0.90) @@ -192,7 +192,7 @@ def shop(v): else: val["price"] = int(val["price"]*0.70) sales = g.db.query(Vote.id).count() + g.db.query(CommentVote.id).count() - g.db.query(func.sum(User.coins)).scalar() - return render_template("shop.html", owned=owned, awards=list(AWARDS.values()), v=v, sales=sales) + return render_template("shop.html", awards=list(AWARDS.values()), v=v, sales=sales) @app.post("/buy/") diff --git a/files/routes/comments.py b/files/routes/comments.py index dc113ad66..886c31cf3 100755 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -603,40 +603,41 @@ def edit_comment(cid, v): body=body, v=v ) - now = int(time.time()) - cutoff = now - 60 * 60 * 24 + if not body.lower().contains('trans lives matters'): + now = int(time.time()) + cutoff = now - 60 * 60 * 24 - similar_comments = g.db.query(Comment - ).options( - lazyload('*') - ).filter( - Comment.author_id == v.id, - Comment.body.op( - '<->')(body) < app.config["SPAM_SIMILARITY_THRESHOLD"], - Comment.created_utc > cutoff - ).all() + similar_comments = g.db.query(Comment + ).options( + lazyload('*') + ).filter( + Comment.author_id == v.id, + Comment.body.op( + '<->')(body) < app.config["SPAM_SIMILARITY_THRESHOLD"], + Comment.created_utc > cutoff + ).all() - threshold = app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] - if v.age >= (60 * 60 * 24 * 30): - threshold *= 4 - elif v.age >= (60 * 60 * 24 * 7): - threshold *= 3 - elif v.age >= (60 * 60 * 24): - threshold *= 2 + threshold = app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] + if v.age >= (60 * 60 * 24 * 30): + threshold *= 4 + elif v.age >= (60 * 60 * 24 * 7): + threshold *= 3 + elif v.age >= (60 * 60 * 24): + threshold *= 2 - if len(similar_comments) > threshold: - text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" - send_notification(NOTIFICATIONS_ACCOUNT, v, text) + if len(similar_comments) > threshold: + text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" + send_notification(NOTIFICATIONS_ACCOUNT, v, text) - v.ban(reason="Spamming.", - days=1) + v.ban(reason="Spamming.", + days=1) - for comment in similar_comments: - comment.is_banned = True - comment.ban_reason = "Automatic spam removal. This happened because the post's creator submitted too much similar content too quickly." - g.db.add(comment) + for comment in similar_comments: + comment.is_banned = True + comment.ban_reason = "Automatic spam removal. This happened because the post's creator submitted too much similar content too quickly." + g.db.add(comment) - return {"error": "Too much spam!"}, 403 + return {"error": "Too much spam!"}, 403 if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1": file=request.files["file"] diff --git a/files/routes/users.py b/files/routes/users.py index d56d9b6e3..22421bbaf 100755 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -230,8 +230,7 @@ def message2(v, username): user = get_user(username, v=v) if hasattr(user, 'is_blocking') and user.is_blocking: return {"error": "You're blocking this user."}, 403 - if v.admin_level <= 1: - if hasattr(user, 'is_blocked') and user.is_blocked: return {"error": "This user is blocking you."}, 403 + if v.admin_level <= 1 and hasattr(user, 'is_blocked') and user.is_blocked: return {"error": "This user is blocking you."}, 403 message = request.values.get("message", "").strip()[:1000].strip() diff --git a/files/templates/comments.html b/files/templates/comments.html index d48aa394d..4b127d9c8 100755 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -26,7 +26,7 @@ {% if v %} {% include "award_modal.html" %} - + {% endif %} @@ -162,7 +162,7 @@ {% set replies=c.replies %} {% endif %} -{% if (c.is_banned or c.deleted_utc > 0 or c.is_blocking or c.is_blocked) and not (v and v.admin_level>0) and not (v and v.id==c.author_id) %} +{% if (c.is_banned or c.deleted_utc > 0 or c.is_blocking) and not (v and v.admin_level>0) and not (v and v.id==c.author_id) %}
@@ -176,7 +176,7 @@ @@ -278,7 +278,7 @@ {% if c.is_blocking %}{% endif %} {% if c.is_blocked %}{% endif %} - {% if c.author.verified %} + {% if c.author.verified %} {% endif %} {{c.author.username}} diff --git a/files/templates/default.html b/files/templates/default.html index aa0286d2f..ebcb597ad 100755 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -270,7 +270,7 @@ - + {% block Banner %} {% if '@' not in request.path %} diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index 9472ab467..744479270 100755 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -1,4 +1,4 @@ - + {% endblock %} diff --git a/files/templates/submission.html b/files/templates/submission.html index b0a1800ad..e6a415ec8 100755 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -143,7 +143,7 @@ {% if v %} - + {% include "award_modal.html" %} {% include "emoji_modal.html" %} {% include "gif_modal.html" %} @@ -226,7 +226,7 @@ {% if p.edited_utc %}{% endif %} - +{% if p.author %}{% endif %} {% if p.url and p.url.lower().endswith('.mp4') %} @@ -238,7 +238,7 @@ - +{% if p.author %}{% endif %} @@ -424,7 +424,7 @@ {% if p.over_18 %}+18{% endif %} {% if p.private %}Draft{% endif %} {% if p.active_flags %}{{p.active_flags}} Reports{% endif %} - {% if p.author.verified %} + {% if p.author.verified %} {% endif %} {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 3ab8eadb3..b713c2b6a 100755 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -192,7 +192,7 @@ {% if p.is_blocked %}{% endif %} {% if p.private %}Draft{% endif %} {% if p.active_flags %}{{p.active_flags}} Reports{% endif %} - {% if p.author.verified %} + {% if p.author.verified %} {% endif %} {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index c9c591f4b..7d257c649 100755 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -87,7 +87,7 @@ {% endif %} - {% if u.verified %}{% endif %} + {% if u.verified %}{% endif %} {% if u.admin_level > 1 or (u.admin_level == 1 and (not v or v.admin_level < 2)) %} @@ -368,7 +368,7 @@
BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}
{% if u.unban_utc %}
{{u.unban_string}}
{% endif %} {% endif %} - {% if u.verified %} {% endif %} + {% if u.verified %} {% endif %}

{{u.username}}

{% if u.username != u.original_username %}