forked from rDrama/rDrama
1
0
Fork 0

Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost

master
Aevann1 2022-09-12 11:07:03 +00:00
commit 3ce8df6264
44 changed files with 253 additions and 111 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 295 KiB

View File

@ -16,8 +16,6 @@ function report_commentModal(id, author) {
document.getElementById("comment-author").textContent = author;
document.getElementById("reportCommentFormBefore").classList.remove('d-none');
reportCommentButton.innerHTML='Report comment';
reportCommentButton.disabled = false;
reportCommentButton.classList.remove('disabled');
@ -43,7 +41,6 @@ function report_commentModal(id, author) {
try {data = JSON.parse(xhr.response)}
catch(e) {console.log(e)}
if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) {
document.getElementById("reportCommentFormBefore").classList.add('d-none');
document.getElementById('toast-post-success-text').innerText = data["message"];
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show();
} else {

View File

@ -13,7 +13,6 @@ reason_post.addEventListener('keydown', (e) => {
function report_postModal(id) {
document.getElementById("reportPostFormBefore").classList.remove('d-none');
reportPostButton.disabled = false;
reportPostButton.classList.remove('disabled');
reportPostButton.innerHTML='Report post';
@ -41,7 +40,6 @@ function report_postModal(id) {
try {data = JSON.parse(xhr.response)}
catch(e) {console.log(e)}
if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) {
document.getElementById("reportPostFormBefore").classList.add('d-none');
document.getElementById('toast-post-success-text').innerText = data["message"];
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show();
} else {

View File

@ -1,6 +1,6 @@
from sqlalchemy import *
from files.__main__ import Base
import time
class Alt(Base):
__tablename__ = "alts"
@ -8,6 +8,11 @@ class Alt(Base):
user1 = Column(Integer, ForeignKey("users.id"), primary_key=True)
user2 = Column(Integer, ForeignKey("users.id"), primary_key=True)
is_manual = Column(Boolean, default=False)
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):

View File

@ -3,6 +3,7 @@ from sqlalchemy.orm import relationship
from files.__main__ import Base
from files.helpers.lazy import lazy
from files.helpers.const import *
import time
class AwardRelationship(Base):
@ -15,11 +16,16 @@ class AwardRelationship(Base):
kind = Column(String)
awarded_utc = Column(Integer)
granted = Column(Boolean)
created_utc = Column(Integer)
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards")
post = relationship("Submission", primaryjoin="AwardRelationship.submission_id==Submission.id", back_populates="awards")
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", back_populates="awards")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<AwardRelationship(id={self.id})>"

View File

@ -11,6 +11,11 @@ class BadgeDef(Base):
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String)
description = Column(String)
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<BadgeDef(id={self.id})>"

View File

@ -1,6 +1,7 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
import time
class Category(Base):
__tablename__ = "category"
@ -10,6 +11,14 @@ class Category(Base):
sub = Column(String(20), ForeignKey("subs.name"))
color_text = Column(String(6))
color_bg = Column(String(6))
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<Category(id={self.id})>"
def as_json(self):
data = {

View File

@ -18,9 +18,14 @@ class OauthApp(Base):
redirect_uri = Column(String)
description = Column(String)
author_id = Column(Integer, ForeignKey("users.id"))
created_utc = Column(Integer)
author = relationship("User", back_populates="apps")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<OauthApp(id={self.id})>"
@ -61,9 +66,14 @@ class ClientAuth(Base):
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
oauth_client = Column(Integer, ForeignKey("oauth_apps.id"), primary_key=True)
access_token = Column(String)
created_utc = Column(Integer)
user = relationship("User")
application = relationship("OauthApp")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<ClientAuth(user_id={self.user_id}, oauth_client={self.oauth_client})>"

View File

@ -1,11 +1,17 @@
from sqlalchemy import *
from files.__main__ import Base
import time
class BannedDomain(Base):
__tablename__ = "banneddomains"
domain = Column(String, primary_key=True)
reason = Column(String)
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<BannedDomain(domain={self.domain})>"

View File

@ -1,6 +1,7 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
import time
class Exile(Base):
@ -8,8 +9,13 @@ class Exile(Base):
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
sub = Column(String, ForeignKey("subs.name"), primary_key=True)
exiler_id = Column(Integer, ForeignKey("users.id"))
created_utc = Column(Integer)
exiler = relationship("User", primaryjoin="User.id==Exile.exiler_id")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<Exile(user_id={self.user_id}, sub={self.sub})>"

View File

@ -4,6 +4,7 @@ from files.__main__ import Base
from files.helpers.lazy import lazy
from files.helpers.regex import censor_slurs
from flask import g
import time
class HatDef(Base):
__tablename__ = "hat_defs"
@ -14,10 +15,18 @@ class HatDef(Base):
author_id = Column(Integer, ForeignKey('users.id'))
price = Column(Integer)
submitter_id = Column(Integer, ForeignKey("users.id"))
created_utc = Column(Integer)
author = relationship("User", primaryjoin="HatDef.author_id == User.id", back_populates="designed_hats")
submitter = relationship("User", primaryjoin="HatDef.submitter_id == User.id")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<HatDef(id={self.id})>"
@property
@lazy
def number_sold(self):
@ -33,10 +42,18 @@ class Hat(Base):
user_id = Column(Integer, ForeignKey('users.id'), primary_key=True)
hat_id = Column(Integer, ForeignKey('hat_defs.id'), primary_key=True)
equipped = Column(Boolean, default=False)
created_utc = Column(Integer)
hat_def = relationship("HatDef")
owners = relationship("User", back_populates="owned_hats")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<Hat(user_id={self.user_id}, hat_id={self.hat_id})>"
@property
@lazy
def name(self):

View File

@ -4,7 +4,6 @@ from files.__main__ import Base
from files.helpers.lazy import lazy
from files.helpers.const import *
class Lottery(Base):
__tablename__ = "lotteries"
@ -14,6 +13,11 @@ class Lottery(Base):
prize = Column(Integer, default=0)
tickets_sold = Column(Integer, default=0)
winner_id = Column(Integer, ForeignKey("users.id"))
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<Lottery(id={self.id})>"

View File

@ -1,5 +1,6 @@
from sqlalchemy import *
from files.__main__ import Base
import time
class Marsey(Base):
__tablename__ = "marseys"
@ -9,6 +10,11 @@ class Marsey(Base):
tags = Column(String)
count = Column(Integer, default=0)
submitter_id = Column(Integer, ForeignKey("users.id"))
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<Marsey(name={self.name})>"

View File

@ -12,10 +12,15 @@ class SubmissionOption(Base):
submission_id = Column(Integer, ForeignKey("submissions.id"))
body_html = Column(Text)
exclusive = Column(Integer)
created_utc = Column(Integer)
votes = relationship("SubmissionOptionVote")
post = relationship("Submission", back_populates="options")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<SubmissionOption(id={self.id})>"
@ -57,10 +62,15 @@ class CommentOption(Base):
comment_id = Column(Integer, ForeignKey("comments.id"))
body_html = Column(Text)
exclusive = Column(Integer)
created_utc = Column(Integer)
votes = relationship("CommentOptionVote")
comment = relationship("Comment", back_populates="options")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<CommentOption(id={self.id})>"

View File

@ -1,7 +1,7 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
import time
class SaveRelationship(Base):
@ -9,9 +9,14 @@ class SaveRelationship(Base):
user_id=Column(Integer, ForeignKey("users.id"), primary_key=True)
submission_id=Column(Integer, ForeignKey("submissions.id"), primary_key=True)
created_utc = Column(Integer)
post = relationship("Submission", uselist=False)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<SaveRelationship(user_id={self.user_id}, submission_id={self.submission_id})>"
@ -22,8 +27,13 @@ class CommentSaveRelationship(Base):
user_id=Column(Integer, ForeignKey("users.id"), primary_key=True)
comment_id=Column(Integer, ForeignKey("comments.id"), primary_key=True)
created_utc = Column(Integer)
comment = relationship("Comment", uselist=False)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<CommentSaveRelationship(user_id={self.user_id}, comment_id={self.comment_id})>"

View File

@ -5,6 +5,7 @@ from files.helpers.lazy import lazy
from os import environ
from .sub_block import *
from .sub_subscription import *
import time
SITE_NAME = environ.get("SITE_NAME", '').strip()
SITE = environ.get("DOMAIN", '').strip()
@ -21,10 +22,15 @@ class Sub(Base):
marseyurl = Column(String)
css = Column(String)
stealth = Column(Boolean)
created_utc = Column(Integer)
blocks = relationship("SubBlock", primaryjoin="SubBlock.sub==Sub.name")
followers = relationship("SubSubscription", primaryjoin="SubSubscription.sub==Sub.name")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return self.name

View File

@ -1,10 +1,16 @@
from sqlalchemy import *
from files.__main__ import Base
import time
class SubBlock(Base):
__tablename__ = "sub_blocks"
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
sub = Column(String(20), ForeignKey("subs.name"), primary_key=True)
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<SubBlock(user_id={self.user_id}, sub={self.sub})>"

View File

@ -1,10 +1,16 @@
from sqlalchemy import *
from files.__main__ import Base
import time
class SubJoin(Base):
__tablename__ = "sub_joins"
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
sub = Column(String(20), ForeignKey("subs.name"), primary_key=True)
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<SubJoin(user_id={self.user_id}, sub={self.sub})>"

View File

@ -1,10 +1,16 @@
from sqlalchemy import *
from files.__main__ import Base
import time
class SubSubscription(Base):
__tablename__ = "sub_subscriptions"
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
sub = Column(String(20), ForeignKey("subs.name"), primary_key=True)
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<SubSubscription(user_id={self.user_id}, sub={self.sub})>"

View File

@ -1,16 +1,19 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
import time
class Subscription(Base):
__tablename__ = "subscriptions"
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
submission_id = Column(Integer, ForeignKey("submissions.id"), primary_key=True)
created_utc = Column(Integer)
user = relationship("User", uselist=False)
post = relationship("Submission", uselist=False)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):

View File

@ -475,9 +475,6 @@ class User(Base):
def url(self):
return f"/@{self.username}"
def __repr__(self):
return f"<User(id={self.id})>"
@property
@lazy
def unban_string(self):

View File

@ -1,15 +1,21 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
import time
class UserBlock(Base):
__tablename__ = "userblocks"
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
target_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
created_utc = Column(Integer)
user = relationship("User", primaryjoin="User.id==UserBlock.user_id", back_populates="blocking")
target = relationship("User", primaryjoin="User.id==UserBlock.target_id", back_populates="blocked")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<UserBlock(user={self.user_id}, target={self.target_id})>"

View File

@ -11,14 +11,13 @@ class ViewerRelationship(Base):
user_id = Column(Integer, ForeignKey('users.id'), primary_key=True)
viewer_id = Column(Integer, ForeignKey('users.id'), primary_key=True)
last_view_utc = Column(Integer)
created_utc = Column(Integer)
viewer = relationship("User", primaryjoin="ViewerRelationship.viewer_id == User.id")
def __init__(self, **kwargs):
if 'last_view_utc' not in kwargs:
kwargs['last_view_utc'] = int(time.time())
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
if 'last_view_utc' not in kwargs: kwargs['last_view_utc'] = int(time.time())
super().__init__(**kwargs)
def __repr__(self):

View File

@ -182,6 +182,7 @@ BBBB_ID = 0
SCHIZO_ID = 0
KIPPY_ID = 0
MCCOX_ID = 0
CHIOBU_ID = 0
PIZZASHILL_ID = 0
GUMROAD_MESSY = ()
PIZZA_VOTERS = ()
@ -234,6 +235,7 @@ if SITE == 'rdrama.net':
SCHIZO_ID = 8494
KIPPY_ID = 7150
MCCOX_ID = 8239
CHIOBU_ID = 5214
PIZZASHILL_ID = 2424
GUMROAD_MESSY = (1230,1379)
PIZZA_VOTERS = (747,1963,9712)
@ -853,6 +855,7 @@ NOTIFIED_USERS = {
'kippy': KIPPY_ID,
'mccox': MCCOX_ID,
'chiobu': CHIOBU_ID,
'donger': DONGER_ID,
'soren': SOREN_ID,
}

View File

@ -194,7 +194,7 @@ def remove_admin(v, username):
@admin_level_required(3)
def distribute(v, option_id):
autojanny = get_account(AUTOJANNY_ID)
if autojanny.coins == 0: return {"error": "@AutoJanny has 0 coins"}
if autojanny.coins == 0: return {"error": "@AutoJanny has 0 coins"}, 400
try: option_id = int(option_id)
except: abort(400)
@ -310,7 +310,7 @@ def club_allow(v, username):
if not u: abort(404)
if u.admin_level >= v.admin_level: return {"error": "noob"}
if u.admin_level >= v.admin_level: return {"error": "noob"}, 400
u.club_allowed = True
g.db.add(u)
@ -337,7 +337,7 @@ def club_ban(v, username):
if not u: abort(404)
if u.admin_level >= v.admin_level: return {"error": "noob"}
if u.admin_level >= v.admin_level: return {"error": "noob"}, 400
u.club_allowed = False
@ -497,7 +497,7 @@ def purge_cache(v):
g.db.add(ma)
if response == "<Response [200]>": return {"message": "Cache purged!"}
return {"error": "Failed to purge cache."}
return {"error": "Failed to purge cache."}, 400
@app.post("/admin/under_attack")
@ -514,7 +514,7 @@ def under_attack(v):
response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data='{"value":"high"}', timeout=5))
if response == "<Response [200]>": return {"message": "Under attack mode disabled!"}
return {"error": "Failed to disable under attack mode."}
return {"error": "Failed to disable under attack mode."}, 400
else:
ma = ModAction(
kind="enable_under_attack",
@ -524,7 +524,7 @@ def under_attack(v):
response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data='{"value":"under_attack"}', timeout=5))
if response == "<Response [200]>": return {"message": "Under attack mode enabled!"}
return {"error": "Failed to enable under attack mode."}
return {"error": "Failed to enable under attack mode."}, 400
@app.get("/admin/badge_grant")
@admin_level_required(2)
@ -1156,7 +1156,7 @@ def approve_post(post_id, v):
post = get_post(post_id)
if post.author.id == v.id and post.author.agendaposter and AGENDAPOSTER_PHRASE not in post.body.lower() and post.sub != 'chudrama':
return {"error": "You can't bypass the chud award!"}
return {"error": "You can't bypass the chud award!"}, 400
if not post:
abort(400)
@ -1351,7 +1351,7 @@ def approve_comment(c_id, v):
if not comment: abort(404)
if comment.author.id == v.id and comment.author.agendaposter and AGENDAPOSTER_PHRASE not in comment.body.lower() and comment.post.sub != 'chudrama':
return {"error": "You can't bypass the chud award!"}
return {"error": "You can't bypass the chud award!"}, 400
if comment.is_banned:
ma=ModAction(

View File

@ -86,7 +86,7 @@ def submit_marsey(v):
filename = f'/asset_submissions/marseys/{name}.webp'
copyfile(highquality, filename)
process_image(filename, resize=300, trim=True)
process_image(filename, resize=250, trim=True)
marsey = Marsey(name=name, author_id=author.id, tags=tags, count=0, submitter_id=v.id)
g.db.add(marsey)

View File

@ -460,7 +460,7 @@ def admin_userawards_post(v):
for key, value in notify_awards.items():
note += f"{value} {AWARDS[key]['title']}, "
if len(note) > 500: return {"error": "You're giving too many awards at the same time!"}
if len(note) > 500: return {"error": "You're giving too many awards at the same time!"}, 400
ma=ModAction(
kind="grant_awards",

View File

@ -58,34 +58,34 @@ def casino_game_feed(v, game):
@limiter.limit("100/minute;2000/hour;12000/day")
@auth_required
def pull_slots(v):
if v.rehab: return {"error": "You are under Rehab award effect!"}
if v.rehab: return {"error": "You are under Rehab award effect!"}, 400
try:
wager = int(request.values.get("wager"))
except:
return {"error": "Invalid wager."}
return {"error": "Invalid wager."}, 400
try:
currency = request.values.get("currency")
except:
return {"error": "Invalid currency (expected 'dramacoin' or 'marseybux')."}
return {"error": "Invalid currency (expected 'dramacoin' or 'marseybux')."}, 400
if (currency == "dramacoin" and wager > v.coins) or (currency == "marseybux" and wager > v.procoins):
return {"error": f"Not enough {currency} to make that bet."}
return {"error": f"Not enough {currency} to make that bet."}, 400
success, game_state = casino_slot_pull(v, wager, currency)
if success:
return {"game_state": game_state, "gambler": {"coins": v.coins, "procoins": v.procoins}}
else:
return {"error": f"Wager must be more than 5 {currency}."}
return {"error": f"Wager must be more than 5 {currency}."}, 400
@app.post("/casino/twentyone/deal")
@limiter.limit("100/minute;2000/hour;12000/day")
@auth_required
def blackjack_deal_to_player(v):
if v.rehab: return {"error": "You are under Rehab award effect!"}
if v.rehab: return {"error": "You are under Rehab award effect!"}, 400
try:
wager = int(request.values.get("wager"))
@ -103,53 +103,53 @@ def blackjack_deal_to_player(v):
@limiter.limit("100/minute;2000/hour;12000/day")
@auth_required
def blackjack_player_hit(v):
if v.rehab: return {"error": "You are under Rehab award effect!"}
if v.rehab: return {"error": "You are under Rehab award effect!"}, 400
try:
state = dispatch_action(v, BlackjackAction.HIT)
feed = get_game_feed('blackjack')
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
except:
return {"error": "Unable to hit."}
return {"error": "Unable to hit."}, 400
@app.post("/casino/twentyone/stay")
@limiter.limit("100/minute;2000/hour;12000/day")
@auth_required
def blackjack_player_stay(v):
if v.rehab: return {"error": "You are under Rehab award effect!"}
if v.rehab: return {"error": "You are under Rehab award effect!"}, 400
try:
state = dispatch_action(v, BlackjackAction.STAY)
feed = get_game_feed('blackjack')
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
except:
return {"error": "Unable to stay."}
return {"error": "Unable to stay."}, 400
@app.post("/casino/twentyone/double-down")
@limiter.limit("100/minute;2000/hour;12000/day")
@auth_required
def blackjack_player_doubled_down(v):
if v.rehab: return {"error": "You are under Rehab award effect!"}
if v.rehab: return {"error": "You are under Rehab award effect!"}, 400
try:
state = dispatch_action(v, BlackjackAction.DOUBLE_DOWN)
feed = get_game_feed('blackjack')
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
except:
return {"error": "Unable to double down."}
return {"error": "Unable to double down."}, 400
@app.post("/casino/twentyone/buy-insurance")
@limiter.limit("100/minute;2000/hour;12000/day")
@auth_required
def blackjack_player_bought_insurance(v):
if v.rehab: return {"error": "You are under Rehab award effect!"}
if v.rehab: return {"error": "You are under Rehab award effect!"}, 400
try:
state = dispatch_action(v, BlackjackAction.BUY_INSURANCE)
feed = get_game_feed('blackjack')
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
except:
return {"error": "Unable to buy insurance."}
return {"error": "Unable to buy insurance."}, 400

View File

@ -69,7 +69,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
post = get_post(pid, v=v)
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
if request.headers.get("Authorization"): return {'error': 'This content is not suitable for some users and situations.'}
if request.headers.get("Authorization"): return {"error": 'This content is not suitable for some users and situations.'}, 403
else: return render_template("errors/nsfw.html", v=v)
try: context = min(int(request.values.get("context", 0)), 8)
@ -149,7 +149,7 @@ def comment(v):
if sub and v.exiled_from(sub): return {"error": f"You're exiled from /h/{sub}"}, 403
if sub in ('furry','vampire','racist','femboy') and not v.client and not v.house.lower().startswith(sub):
return {"error": f"You need to be a member of House {sub.capitalize()} to comment in /h/{sub}"}
return {"error": f"You need to be a member of House {sub.capitalize()} to comment in /h/{sub}"}, 400
if parent_post.club and not (v and (v.paid_dues or v.id == parent_post.author_id)): abort(403)
@ -196,7 +196,7 @@ def comment(v):
oldname = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(oldname)
image = process_image(oldname)
if image == "": return {"error":"Image upload failed"}
if image == "": return {"error":"Image upload failed"}, 400
if v.admin_level > 2 and level == 1:
if parent_post.id == SIDEBAR_THREAD:
li = sorted(os.listdir(f'files/assets/images/{SITE_NAME}/sidebar'),
@ -796,7 +796,7 @@ def unpin_comment(cid, v):
if v.id != comment.post.author_id: abort(403)
if not comment.stickied.endswith(" (OP)"):
return {"error": "You can only unpin comments you have pinned!"}
return {"error": "You can only unpin comments you have pinned!"}, 400
comment.stickied = None
g.db.add(comment)

View File

@ -9,7 +9,7 @@ import requests
@is_not_permabanned
def join_discord(v):
if v.shadowbanned: return {"error": "Internal server error"}
if v.shadowbanned: return {"error": "Internal server error"}, 400
now=int(time.time())

View File

@ -38,13 +38,13 @@ def buy_hat(v, hat_id):
if not FEATURES['HATS']: abort(404)
try: hat_id = int(hat_id)
except: return {"error": "Hat not found!"}
except: return {"error": "Hat not found!"}, 400
hat = g.db.query(HatDef).filter_by(submitter_id=None, id=hat_id).one_or_none()
if not hat: return {"error": "Hat not found!"}
if not hat: return {"error": "Hat not found!"}, 400
existing = g.db.query(Hat).filter_by(user_id=v.id, hat_id=hat.id).one_or_none()
if existing: return {"error": "You already own this hat!"}
if existing: return {"error": "You already own this hat!"}, 400
if request.values.get("mb"):
if v.procoins < hat.price: return {"error": "Not enough marseybux."}, 400
@ -85,10 +85,10 @@ def equip_hat(v, hat_id):
if not FEATURES['HATS']: abort(404)
try: hat_id = int(hat_id)
except: return {"error": "Hat not found!"}
except: return {"error": "Hat not found!"}, 400
hat = g.db.query(Hat).filter_by(hat_id=hat_id, user_id=v.id).one_or_none()
if not hat: return {"error": "You don't own this hat!"}
if not hat: return {"error": "You don't own this hat!"}, 400
hat.equipped = True
g.db.add(hat)
@ -101,10 +101,10 @@ def unequip_hat(v, hat_id):
if not FEATURES['HATS']: abort(404)
try: hat_id = int(hat_id)
except: return {"error": "Hat not found!"}
except: return {"error": "Hat not found!"}, 400
hat = g.db.query(Hat).filter_by(hat_id=hat_id, user_id=v.id).one_or_none()
if not hat: return {"error": "You don't own this hat!"}
if not hat: return {"error": "You don't own this hat!"}, 400
hat.equipped = False
g.db.add(hat)

View File

@ -29,7 +29,7 @@ def lottery_start(v):
@casino_required
def lottery_buy(v):
try: quantity = int(request.values.get("quantity"))
except: return {"error": "Invalid ticket quantity."}
except: return {"error": "Invalid ticket quantity."}, 400
success, message = purchase_lottery_tickets(v, quantity)
lottery, participants = get_active_lottery_stats()

View File

@ -19,10 +19,10 @@ def vote_option(option_id, v):
sub = option.post.sub
if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub):
return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"}
return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"}, 400
if option.exclusive == 2:
if v.coins < 200: return {"error": "You don't have 200 coins!"}
if v.coins < 200: return {"error": "You don't have 200 coins!"}, 400
v.coins -= 200
g.db.add(v)
autojanny = get_account(AUTOJANNY_ID)
@ -35,7 +35,7 @@ def vote_option(option_id, v):
SubmissionOptionVote.submission_id==option.submission_id,
SubmissionOption.exclusive==option.exclusive).one_or_none()
if vote:
if option.exclusive == 2: return {"error": "You already voted on this bet!"}
if option.exclusive == 2: return {"error": "You already voted on this bet!"}, 400
g.db.delete(vote)
existing = g.db.query(SubmissionOptionVote).filter_by(option_id=option_id, user_id=v.id).one_or_none()
@ -85,7 +85,7 @@ def vote_option_comment(option_id, v):
sub = option.comment.post.sub
if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub):
return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"}
return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"}, 400
if option.exclusive:
vote = g.db.query(CommentOptionVote).join(CommentOption).filter(

View File

@ -1241,7 +1241,7 @@ def pin_post(post_id, v):
post = get_post(post_id)
if post:
if v.id != post.author_id: return {"error": "Only the post author's can do that!"}
if v.id != post.author_id: return {"error": "Only the post author's can do that!"}, 400
post.is_pinned = not post.is_pinned
g.db.add(post)
@ -1249,7 +1249,7 @@ def pin_post(post_id, v):
if post.is_pinned: return {"message": "Post pinned!"}
else: return {"message": "Post unpinned!"}
return {"error": "Post not found!"}
return {"error": "Post not found!"}, 400
extensions = (

View File

@ -21,13 +21,13 @@ def flag_post(pid, v):
send_repeatable_notification(CARP_ID, f"reports on {post.permalink}")
if v.is_muted:
return {"error": "You are forbidden from making reports."}
return {"error": "You are forbidden from making reports."}, 400
reason = reason[:100]
reason = filter_emojis_only(reason)
if len(reason) > 350: return {"error": "Too long."}
if len(reason) > 350: return {"error": "Too long."}, 400
if reason.startswith('!') and (v.admin_level > 1 or post.sub and v.mods(post.sub)):
post.flair = reason[1:]
@ -47,16 +47,16 @@ def flag_post(pid, v):
sub_to = g.db.query(Sub).filter_by(name=sub_to).one_or_none()
sub_to = sub_to.name if sub_to else None
if sub_from == sub_to: abort(400)
if sub_from == sub_to: {"error": f"Post is already in /h/{sub_to}"}, 400
if post.author.exiled_from(sub_to):
return {"error": f"User is exiled from this {HOLE_NAME}!"}
return {"error": f"User is exiled from this {HOLE_NAME}!"}, 400
if sub_to in ('furry','vampire','racist','femboy') and not v.client and not post.author.house.lower().startswith(sub_to):
if v.id == post.author_id:
return {"error": f"You need to be a member of House {sub.capitalize()} to post in /h/{sub}"}
return {"error": f"You need to be a member of House {sub.capitalize()} to post in /h/{sub}"}, 403
else:
return {"error": f"@{post.author.username} needs to be a member of House {sub.capitalize()} for their post to be moved to /h/{sub}"}
return {"error": f"@{post.author.username} needs to be a member of House {sub.capitalize()} for their post to be moved to /h/{sub}"}, 400
post.sub = sub_to
g.db.add(post)
@ -77,7 +77,8 @@ def flag_post(pid, v):
return {"message": f"Post moved to /h/{post.sub}"}
else:
existing = g.db.query(Flag.post_id).filter_by(user_id=v.id, post_id=post.id).one_or_none()
if existing: return "", 409
if existing:
return {"error": "You already reported this post!"}, 409
flag = Flag(post_id=post.id, user_id=v.id, reason=reason)
g.db.add(flag)
@ -94,7 +95,8 @@ def flag_comment(cid, v):
comment = get_comment(cid)
existing = g.db.query(CommentFlag.comment_id).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
if existing: return "", 409
if existing:
return {"error": "You already reported this comment!"}, 409
reason = request.values.get("reason", "").strip()
@ -106,7 +108,7 @@ def flag_comment(cid, v):
reason = filter_emojis_only(reason)
if len(reason) > 350: return {"error": "Too long."}
if len(reason) > 350: return {"error": "Too long."}, 400
flag = CommentFlag(comment_id=comment.id, user_id=v.id, reason=reason)

View File

@ -72,10 +72,10 @@ def searchposts(v):
if 'author' in criteria:
posts = posts.filter(Submission.ghost == False)
author = get_user(criteria['author'])
if not author: return {"error": "User not found"}
if not author: return {"error": "User not found"}, 400
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
if request.headers.get("Authorization"):
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}, 400
return render_template("search.html",
v=v,
query=query,
@ -202,17 +202,17 @@ def searchcomments(v):
if 'post' in criteria:
try: post = int(criteria['post'])
except: return {"error": f"Post with id {post} does not exist."}
except: return {"error": f"Post with id {post} does not exist."}, 400
comments = comments.filter(Comment.parent_submission == post)
if 'author' in criteria:
comments = comments.filter(Comment.ghost == False)
author = get_user(criteria['author'])
if not author: return {"error": "User not found"}
if not author: return {"error": "User not found"}, 400
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
if request.headers.get("Authorization"):
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}, 400
return render_template("search_comments.html", v=v, query=query, total=0, page=page, comments=[], sort=sort, t=t, next_exists=False, error=f"@{author.username}'s profile is private; You can't use the 'author' syntax on them.")

View File

@ -258,7 +258,7 @@ def settings_profile_post(v):
if theme:
if theme in {"4chan","classic","classic_dark","coffee","dark","dramblr","light","midnight","transparent","tron","win98"}:
if theme == "transparent" and not v.background:
return {"error": "You need to set a background to use the transparent theme!"}
return {"error": "You need to set a background to use the transparent theme!"}, 400
v.theme = theme
if theme == "win98": v.themecolor = "30409f"
updated = True
@ -581,12 +581,12 @@ def settings_css_get(v):
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
@auth_required
def settings_css(v):
if v.agendaposter: return {"error": "Agendapostered users can't edit css!"}
if v.agendaposter: return {"error": "Agendapostered users can't edit css!"}, 400
css = request.values.get("css").strip().replace('\\', '').strip()[:4000]
if '</style' in css.lower():
return {"error": "Please message @Aevann if you get this error"}
return {"error": "Please message @Aevann if you get this error"}, 400
v.css = css
g.db.add(v)

View File

@ -247,7 +247,7 @@ def add_mod(v, sub):
user = get_user(user)
if sub in ('furry','vampire','racist','femboy') and not v.client and not user.house.lower().startswith(sub):
return {"error": f"@{user.username} needs to be a member of House {sub.capitalize()} to be added as a mod there!"}
return {"error": f"@{user.username} needs to be a member of House {sub.capitalize()} to be added as a mod there!"}, 400
existing = g.db.query(Mod).filter_by(user_id=user.id, sub=sub).one_or_none()

View File

@ -696,7 +696,7 @@ def message2(v, username):
message = request.values.get("message", "").strip()[:10000].strip()
if not message: return {"error": "Message is empty!"}
if not message: return {"error": "Message is empty!"}, 400
if 'linkedin.com' in message: return {"error": "This domain 'linkedin.com' is banned."}, 403
@ -761,18 +761,18 @@ def messagereply(v):
body = request.values.get("body", "").strip().replace('','')
body = body.replace('\r\n', '\n')[:10000]
if not body and not request.files.get("file"): return {"error": "Message is empty!"}
if not body and not request.files.get("file"): return {"error": "Message is empty!"}, 400
if 'linkedin.com' in body: return {"error": "this domain 'linkedin.com' is banned"}
if 'linkedin.com' in body: return {"error": "this domain 'linkedin.com' is banned"}, 400
id = int(request.values.get("parent_id"))
parent = get_comment(id, v=v)
user_id = parent.author.id
if v.is_suspended_permanently and parent.sentto != 2:
return {"error": "You are permabanned and may not reply to messages."}
return {"error": "You are permabanned and may not reply to messages."}, 400
elif v.is_muted and parent.sentto == 2:
return {"error": "You are forbidden from replying to modmail."}
return {"error": "You are forbidden from replying to modmail."}, 400
if parent.sentto == 2: user_id = None
elif v.id == user_id: user_id = parent.sentto
@ -1189,7 +1189,7 @@ def unfollow_user(username, v):
if target.fish:
if not v.shadowbanned:
send_notification(target.id, f"@{v.username} has tried to unfollow you and failed because of your fish award!")
return {"error": "You can't unfollow this user!"}
return {"error": "You can't unfollow this user!"}, 400
follow = g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).one_or_none()

View File

@ -795,17 +795,15 @@
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
</div>
<div class="" id="reportCommentFormBefore">
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_comment" class="form-control">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportCommentButton" class="btn btn-danger">Report comment</button>
</div>
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_comment" class="form-control">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportCommentButton" class="btn btn-danger" data-bs-dismiss="modal">Report comment</button>
</div>
</div>
</div>

View File

@ -17,12 +17,12 @@
<ul class="nav settings-nav" style="padding:0 0 0 20px" id="notifications--nav-list">
<li class="nav-item">
<a class="nav-link py-3{% if request.path == '/notifications' %} active{% endif %}" href="/notifications">
All {% if v.normal_notifications_count %}<span class="font-weight-bold" style="color:#ff0000">({{v.normal_notifications_count}})</span>{% endif %}
All {% if v.normal_notifications_count %}<span class="font-weight-bold" style="color:#dc3545">({{v.normal_notifications_count}})</span>{% endif %}
</a>
</li>
<li class="nav-item">
<a class="nav-link py-3{% if request.path == '/notifications/messages' %} active{% endif %}" href="/notifications/messages">
Messages {% if v.message_notifications_count %}<span class="font-weight-bold" style="color:#ff0000">({{v.message_notifications_count}})</span>{% endif %}
Messages {% if v.message_notifications_count %}<span class="font-weight-bold" style="color:#d8910d">({{v.message_notifications_count}})</span>{% endif %}
</a>
</li>
<li class="nav-item">
@ -33,7 +33,7 @@
{% if v.admin_level >= NOTIF_MODACTION_JL_MIN %}
<li class="nav-item">
<a class="nav-link py-3{% if request.path == '/notifications/modactions' %} active{% endif %}" href="/notifications/modactions">
Modactions {% if v.modaction_notifications_count %}<span class="font-weight-bold" style="color:#e5990d">({{v.modaction_notifications_count}})</span>{% endif %}
Modactions {% if v.modaction_notifications_count %}<span class="font-weight-bold" style="color:#1ad80d">({{v.modaction_notifications_count}})</span>{% endif %}
</a>
</li>
{% endif %}

View File

@ -7,20 +7,18 @@
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
</div>
<div id="reportPostFormBefore">
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_post" class="form-control b2">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportPostButton" class="btn btn-danger">Report post</button>
</div>
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_post" class="form-control b2">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportPostButton" class="btn btn-danger" data-bs-dismiss="modal">Report post</button>
</div>
</div>
</div>
</div>
<script defer src="/assets/js/report_post_modal.js?v=4001"></script>
<script defer src="/assets/js/report_post_modal.js?v=4002"></script>

View File

@ -19,7 +19,7 @@ set CACHE_VER = {
'js/bootstrap.js': 4004,
'js/category_modal.js': 4000,
'js/comments_admin.js': 4000,
'js/comments_v.js': 4001,
'js/comments_v.js': 4002,
'js/submission_listing.js': 4000,
'js/emoji_modal.js': 4004,
'js/formatting.js': 4000,

View File

@ -0,0 +1,23 @@
alter table alts add column created_utc int;
alter table award_relationships add column created_utc int;
alter table badge_defs add column created_utc int;
alter table category add column created_utc int;
alter table oauth_apps add column created_utc int;
alter table client_auths add column created_utc int;
alter table banneddomains add column created_utc int;
alter table exiles add column created_utc int;
alter table hat_defs add column created_utc int;
alter table hats add column created_utc int;
alter table lotteries add column created_utc int;
alter table marseys add column created_utc int;
alter table submission_options add column created_utc int;
alter table comment_options add column created_utc int;
alter table save_relationship add column created_utc int;
alter table comment_save_relationship add column created_utc int;
alter table sub_blocks add column created_utc int;
alter table sub_joins add column created_utc int;
alter table sub_subscriptions add column created_utc int;
alter table subs add column created_utc int;
alter table subscriptions add column created_utc int;
alter table userblocks add column created_utc int;
alter table viewers add column created_utc int;