diff --git a/files/assets/images/emojis/marseyfox.webp b/files/assets/images/emojis/marseyfox.webp index 0069ac469..f8af6547b 100644 Binary files a/files/assets/images/emojis/marseyfox.webp and b/files/assets/images/emojis/marseyfox.webp differ diff --git a/files/classes/comment.py b/files/classes/comment.py index 34f1332db..5230836a3 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -281,7 +281,7 @@ class Comment(Base): 'level': self.level, 'parent': self.parent_fullname } - elif self.deleted_utc > 0: + elif self.deleted_utc: data= {'deleted_utc': self.deleted_utc, 'id': self.id, 'post': self.post.id if self.post else 0, @@ -305,7 +305,7 @@ class Comment(Base): data=self.json_core - if self.deleted_utc > 0 or self.is_banned: + if self.deleted_utc or self.is_banned: return data data["author"]=self.author.json_core diff --git a/files/classes/submission.py b/files/classes/submission.py index 179682878..b279660eb 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -317,7 +317,7 @@ class Submission(Base): data=self.json_core - if self.deleted_utc > 0 or self.is_banned: + if self.deleted_utc or self.is_banned: return data data["author"]=self.author.json_core diff --git a/files/classes/user.py b/files/classes/user.py index 03c37fa9c..00816c675 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -530,7 +530,7 @@ class User(Base): self.bannerurl = None def ban(self, admin=None, reason=None, days=0): - if days > 0: + if days: ban_time = int(time.time()) + (days * 86400) self.unban_utc = ban_time else: diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index fde34f3cf..0885ce871 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -243,8 +243,8 @@ def sanitize(sanitized, noimages=False, alert=False): for i in re.finditer('
(https:.*?\.(mp4|webm|mov))
', sanitized): sanitized = sanitized.replace(i.group(0), f'')
- for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]:
- sanitized = sanitized.replace(rd, "https://old.reddit.com/")
+ for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]:
+ sanitized = sanitized.replace(rd, "://old.reddit.com")
sanitized = sanitized.replace("old.reddit.com/gallery", "new.reddit.com/gallery")
sanitized = re.sub(' (https:\/\/[^ <>]*)', r' \1', sanitized)
diff --git a/files/routes/admin.py b/files/routes/admin.py
index 3d7c975ee..949e1535f 100644
--- a/files/routes/admin.py
+++ b/files/routes/admin.py
@@ -207,7 +207,7 @@ def monthly(v):
emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5).json()["subscribers"]]
- for u in g.db.query(User).filter(User.patron > 0).all():
+ for u in g.db.query(User).filter(User.patron).all():
if u.patron == 5 or u.email and u.email.lower() in emails or u.id == 1379:
if u.patron == 1: procoins = 2500
elif u.patron == 2: procoins = 5000
@@ -716,7 +716,7 @@ def agendaposter(user_id, v):
user.agendaposter_expires_utc = expiry
g.db.add(user)
for alt in user.alts:
- if alt.admin_level > 0: break
+ if alt.admin_level: break
alt.agendaposter = user.agendaposter
alt.agendaposter_expires_utc = expiry
g.db.add(alt)
@@ -763,7 +763,7 @@ def shadowban(user_id, v):
user.shadowbanned = v.username
g.db.add(user)
for alt in user.alts:
- if alt.admin_level > 0: break
+ if alt.admin_level: break
alt.shadowbanned = v.username
g.db.add(alt)
ma = ModAction(
@@ -894,10 +894,10 @@ def ban_user(user_id, v):
if request.values.get("alts"):
for x in user.alts:
- if x.admin_level > 0: break
+ if x.admin_level: break
user.ban(admin=v, reason=reason, days=days)
- if days > 0:
+ if days:
if message: text = f"Your account has been suspended for {days} days for the following reason:\n\n> {message}"
else: text = f"Your account has been suspended for {days} days."
else:
diff --git a/files/routes/awards.py b/files/routes/awards.py
index ade38963b..e80a28894 100644
--- a/files/routes/awards.py
+++ b/files/routes/awards.py
@@ -223,7 +223,7 @@ def award_post(pid, v):
if not author.is_suspended:
author.ban(reason=f"1-Day ban award used by @{v.username} on /post/{post.id}", days=1)
send_repeatable_notification(author.id, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.")
- elif author.unban_utc > 0:
+ elif author.unban_utc:
author.unban_utc += 86400
send_repeatable_notification(author.id, f"Your account has been suspended for yet another day for {link}. Seriously man?")
elif kind == "unban":
@@ -410,7 +410,7 @@ def award_comment(cid, v):
if not author.is_suspended:
author.ban(reason=f"1-Day ban award used by @{v.username} on /comment/{c.id}", days=1)
send_repeatable_notification(author.id, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.")
- elif author.unban_utc > 0:
+ elif author.unban_utc:
author.unban_utc += 86400
send_repeatable_notification(author.id, f"Your account has been suspended for yet another day for {link}. Seriously man?")
elif kind == "unban":
@@ -580,7 +580,7 @@ def admin_userawards_post(v):
if int(value) > 10: abort(403)
- if int(value) > 0: notify_awards[key] = int(value)
+ if int(value): notify_awards[key] = int(value)
for x in range(int(value)):
thing += 1
diff --git a/files/routes/comments.py b/files/routes/comments.py
index 47d5f863d..1e002b96c 100644
--- a/files/routes/comments.py
+++ b/files/routes/comments.py
@@ -72,7 +72,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
except: context = 0
comment_info = comment
c = comment
- while context > 0 and c.level > 1:
+ while context and c.level > 1:
c = c.parent_comment
context -= 1
top_comment = c
@@ -213,7 +213,7 @@ def api_comment(v):
body_html = sanitize(body)
- if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403
+ if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))): return {"error":"You can only type marseys!"}, 403
if v.longpost:
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
@@ -591,7 +591,7 @@ def edit_comment(cid, v):
body_html = sanitize(body)
- if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403
+ if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))): return {"error":"You can only type marseys!"}, 403
if v.longpost:
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
diff --git a/files/routes/feeds.py b/files/routes/feeds.py
index 54c6f26df..de35acd7f 100644
--- a/files/routes/feeds.py
+++ b/files/routes/feeds.py
@@ -42,7 +42,7 @@ def feeds_user(v=None, sort='hot', t='all'):
with tag("id"):
text(post.fullname)
- if (post.edited_utc > 0):
+ if (post.edited_utc):
with tag("updated"):
text(datetime.utcfromtimestamp(post.edited_utc).isoformat())
@@ -61,7 +61,7 @@ def feeds_user(v=None, sort='hot', t='all'):
doc.stag("media:thumbnail", url=image_url)
- if len(post.body_html) > 0:
+ if len(post.body_html):
with tag("content", type="html"):
doc.cdata(f'''
{post.realbody(None)}''')
diff --git a/files/routes/login.py b/files/routes/login.py
index 10718e296..373ca6c55 100644
--- a/files/routes/login.py
+++ b/files/routes/login.py
@@ -300,7 +300,7 @@ def sign_up_post(v):
ref_user = g.db.query(User).filter_by(id=ref_id).one_or_none()
if ref_user:
- if ref_user.referral_count > 0:
+ if ref_user.referral_count:
new_badge = Badge(user_id=ref_user.id, badge_id=10)
g.db.add(new_badge)
if ref_user.referral_count > 9:
diff --git a/files/routes/posts.py b/files/routes/posts.py
index 2b6274dfd..547c120f3 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -436,7 +436,7 @@ def edit_post(pid, v):
if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username)
title_html = filter_emojis_only(title)
- if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403
+ if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))): return {"error":"You can only type marseys!"}, 403
p.title = title[:500]
p.title_html = title_html
@@ -485,7 +485,7 @@ def edit_post(pid, v):
return {"error": reason}, 403
p.body = body
- if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 40
+ if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))): return {"error":"You can only type marseys!"}, 40
if v.longpost:
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
@@ -724,7 +724,7 @@ def submit_post(v):
title_html = filter_emojis_only(title)
body = request.values.get("body", "").strip().replace('','')
- if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40
+ if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))): return {"error":"You can only type marseys!"}, 40
if v.longpost:
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
@@ -736,8 +736,8 @@ def submit_post(v):
elif "/media.giphy.com/" in url or "/c.tenor.com/" in url: url = url.replace(".gif", ".webp")
elif "/i.ibb.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp").replace(".gif", ".webp")
- for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]:
- url = url.replace(rd, "https://old.reddit.com/")
+ for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]:
+ url = url.replace(rd, "://old.reddit.com")
url = url.replace("old.reddit.com/gallery", "new.reddit.com/gallery").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube")
@@ -944,7 +944,7 @@ def submit_post(v):
body_html = sanitize(body)
- if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 400
+ if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))): return {"error":"You can only type marseys!"}, 400
if v.longpost:
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
diff --git a/files/routes/settings.py b/files/routes/settings.py
index 523a4cdb0..49a479b2c 100644
--- a/files/routes/settings.py
+++ b/files/routes/settings.py
@@ -519,7 +519,7 @@ def gumroad(v):
v.procoins += procoins
send_repeatable_notification(v.id, f"You have received {procoins} Marseybux! You can use them to buy awards in the [shop](/shop).")
- if v.truecoins > 150 and v.patron > 0: v.cluballowed = True
+ if v.truecoins > 150 and v.patron: v.cluballowed = True
if v.patron > 3 and v.verified == None: v.verified = "Verified"
g.db.add(v)
diff --git a/files/routes/static.py b/files/routes/static.py
index e44f7a689..4b6e9884d 100644
--- a/files/routes/static.py
+++ b/files/routes/static.py
@@ -49,7 +49,7 @@ def participation_stats(v):
data = {"marseys": len(marseys),
"users": g.db.query(User.id).count(),
"private_users": g.db.query(User.id).filter_by(is_private=True).count(),
- "banned_users": g.db.query(User.id).filter(User.is_banned > 0).count(),
+ "banned_users": g.db.query(User.id).filter(User.is_banned).count(),
"verified_email_users": g.db.query(User.id).filter_by(is_activated=True).count(),
"total_coins": g.db.query(func.sum(User.coins)).scalar(),
"signups_last_24h": g.db.query(User.id).filter(User.created_utc > day).count(),
@@ -57,7 +57,7 @@ def participation_stats(v):
"posting_users": g.db.query(Submission.author_id).distinct().count(),
"listed_posts": g.db.query(Submission.id).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
"removed_posts": g.db.query(Submission.id).filter_by(is_banned=True).count(),
- "deleted_posts": g.db.query(Submission.id).filter(Submission.deleted_utc > 0).count(),
+ "deleted_posts": g.db.query(Submission.id).filter(Submission.deleted_utc).count(),
"posts_last_24h": g.db.query(Submission.id).filter(Submission.created_utc > day).count(),
"total_comments": g.db.query(Comment.id).filter(Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
"commenting_users": g.db.query(Comment.author_id).distinct().count(),
@@ -166,7 +166,7 @@ def cached_chart(days):
@app.get("/paypigs")
@admin_level_required(3)
def patrons(v):
- users = g.db.query(User).filter(User.patron > 0).order_by(User.patron.desc(), User.id).all()
+ users = g.db.query(User).filter(User.patron).order_by(User.patron.desc(), User.id).all()
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
@@ -383,7 +383,7 @@ def blocks(v):
@auth_required
def banned(v):
- users = [x for x in g.db.query(User).filter(User.is_banned > 0, User.unban_utc == 0).all()]
+ users = [x for x in g.db.query(User).filter(User.is_banned, User.unban_utc == 0).all()]
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
return render_template(f"{template}banned.html", v=v, users=users)
diff --git a/files/routes/users.py b/files/routes/users.py
index e80a2f69f..ae7ae4808 100644
--- a/files/routes/users.py
+++ b/files/routes/users.py
@@ -190,7 +190,7 @@ def steal(v):
@app.get("/rentoids")
@auth_required
def rentoids(v):
- users = g.db.query(User).filter(User.rent_utc > 0).all()
+ users = g.db.query(User).filter(User.rent_utc).all()
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
return render_template(f"{template}rentoids.html", v=v, users=users)
@@ -199,9 +199,9 @@ def rentoids(v):
@app.get("/thiefs")
@auth_required
def thiefs(v):
- successful = g.db.query(User).filter(User.steal_utc > 0).all()
- failed = g.db.query(User).filter(User.fail_utc > 0).all()
- failed2 = g.db.query(User).filter(User.fail2_utc > 0).all()
+ successful = g.db.query(User).filter(User.steal_utc).all()
+ failed = g.db.query(User).filter(User.fail_utc).all()
+ failed2 = g.db.query(User).filter(User.fail2_utc).all()
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
return render_template(f"{template}thiefs.html", v=v, successful=successful, failed=failed, failed2=failed2)
diff --git a/files/templates/comments.html b/files/templates/comments.html
index 374c3826e..6b7a8ce13 100644
--- a/files/templates/comments.html
+++ b/files/templates/comments.html
@@ -77,7 +77,7 @@
{% set replies=c.replies %}
{% endif %}
-{% if (c.is_banned or c.deleted_utc > 0 or c.is_blocking) and not (v and v.admin_level > 1) and not (v and v.id==c.author_id) %}
+{% if (c.is_banned or c.deleted_utc or c.is_blocking) and not (v and v.admin_level > 1) and not (v and v.id==c.author_id) %}