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

master
Aevann1 2022-10-05 23:11:54 +02:00
commit f77bab96eb
26 changed files with 86 additions and 88 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -330,6 +330,8 @@ class Comment(Base):
def realbody(self, v):
if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id] or (self.parent_comment and v.id == self.parent_comment.author_id))):
return f"<p>{CC} ONLY</p>"
if self.deleted_utc != 0 and not (v and (v.admin_level >= 2) or v.id == self.author.id): return "[Deleted by user]"
if self.is_banned and not (v and v.admin_level >= 2): return "[Removed by admins]";
body = self.body_html or ""
@ -395,6 +397,8 @@ class Comment(Base):
def plainbody(self, v):
if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id] or (self.parent_comment and v.id == self.parent_comment.author_id))):
return f"{CC} ONLY"
if self.deleted_utc != 0 and not (v and (v.admin_level >= 2 or v.id == self.author.id)): return "[Deleted by user]"
if self.is_banned and not (v and v.admin_level >= 2): return "[Removed by admins]";
body = self.body

View File

@ -334,6 +334,8 @@ class Submission(Base):
@lazy
def realbody(self, v, listing=False):
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
if self.deleted_utc != 0 and not (v and (v.admin_level >= 2) or v.id == self.author.id): return "[Deleted by user]"
if self.is_banned and not (v and v.admin_level >= 2): return "[Removed by admins]";
body = self.body_html or ""
@ -364,12 +366,12 @@ class Submission(Base):
if o.exclusive > 1:
body += f'''<div class="custom-control mt-2"><input name="option-{self.id}" autocomplete="off" class="custom-control-input bet" type="radio" id="{o.id}" onchange="bet_vote('{o.id}','{self.id}')"'''
if o.voted(v): body += " checked "
if not (v and v.coins >= 200) or self.total_bet_voted(v): body += " disabled "
if not (v and v.coins >= POLL_BET_COINS) or self.total_bet_voted(v): body += " disabled "
body += f'''><label class="custom-control-label" for="{o.id}">{o.body_html}<span class="presult-{self.id}'''
body += f'"> - <a href="/votes/post/option/{o.id}"><span id="option-{o.id}">{o.upvotes}</span> bets</a>'
if not self.total_bet_voted(v):
body += '''<span class="cost"> (cost of entry: 200 coins)</span>'''
body += f'''<span class="cost"> (cost of entry: {POLL_BET_COINS} coins)</span>'''
body += "</label>"
if o.exclusive == 3:
@ -401,6 +403,8 @@ class Submission(Base):
@lazy
def plainbody(self, v):
if self.deleted_utc != 0 and not (v and (v.admin_level >= 2 or v.id == self.author.id)): return "[Deleted by user]"
if self.is_banned and not (v and v.admin_level >= 2): return "[Removed by admins]"
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
body = self.body

View File

@ -193,6 +193,7 @@ DONGER_ID = 0
GEESE_ID = 0
POLL_THREAD = 0
POLL_BET_COINS = 200
WELCOME_MSG = f"Welcome to {SITE_NAME}!"
ROLES={}

View File

@ -298,6 +298,19 @@ def get_comments(cids, v=None, load_parent=False):
return sorted(output, key=lambda x: cids.index(x.id))
def get_sub_by_name(sub, v=None, graceful=False):
if not sub:
if graceful: return None
else: abort(404)
sub = sub.replace('/h/', '').strip().lower()
if not sub:
if graceful: return None
else: abort(404)
sub = g.db.get(Sub, sub)
if not sub:
if graceful: return None
else: abort(404)
return sub
def get_domain(s):

View File

@ -90,7 +90,7 @@ ascii_only_regex = re.compile("[ -~]+", flags=re.A)
reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|u)\/', flags=re.A)
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|new\.reddit.com|np\.reddit.com|www\.reddit.com|i\.reddit\.com|libredd\.it|teddit\.net)\/(r|u)\/", flags=re.A)
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2})(?:-[A-z]{2})" "?|beta|i|m|pay|ssl|www|new|alpha)\.reddit\.com|libredd\.it|teddit\.net)\/(r|u)\/", flags=re.A)
color_regex = re.compile("[a-z0-9]{6}", flags=re.A)

View File

@ -220,7 +220,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys
sanitized = strikethrough_regex.sub(r'\1<del>\2</del>', sanitized)
sanitized = sanitized.replace('','').replace('','').replace("\ufeff", "").replace("𒐪","").replace("։", ":")
sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("𒐪","").replace("\u0589", ":")
sanitized = reddit_regex.sub(r'\1<a href="https://old.reddit.com/\2" rel="nofollow noopener noreferrer" target="_blank">/\2</a>', sanitized)
sanitized = sub_regex.sub(r'\1<a href="/\2">/\2</a>', sanitized)

View File

@ -213,7 +213,7 @@ def distribute(v, option_id):
pool = 0
for o in post.options:
if o.exclusive >= 2: pool += o.upvotes
pool *= 200
pool *= POLL_BET_COINS
autojanny.coins -= pool
if autojanny.coins < 0: autojanny.coins = 0
@ -229,7 +229,7 @@ def distribute(v, option_id):
add_notif(cid, u.id)
cid = notif_comment(f"You lost the 200 coins you bet on [{post.title}]({post.shortlink}) :marseylaugh:")
cid = notif_comment(f"You lost the {POLL_BET_COINS} coins you bet on [{post.title}]({post.shortlink}) :marseylaugh:")
losing_voters = []
for o in post.options:
if o.exclusive == 2:

View File

@ -163,6 +163,8 @@ def comment(v):
level = parent.level + 1
if parent.author_id == v.id: rts = True
else: abort(400)
if parent.deleted_utc != 0: abort(404)
body = request.values.get("body", "").strip().replace('','')

View File

@ -22,7 +22,7 @@ def front_all(v, sub=None, subdomain=None):
if sub:
sub = sub.strip().lower()
if sub == 'chudrama' and not (v and v.can_see_chudrama): abort(403)
sub = g.db.get(Sub, sub)
sub = get_sub_by_name(sub, graceful=True)
if (request.path.startswith('/h/') or request.path.startswith('/s/')) and not sub: abort(404)

View File

@ -22,11 +22,11 @@ def vote_option(option_id, v):
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!"}, 400
v.coins -= 200
if v.coins < POLL_BET_COINS: return {"error": f"You don't have {POLL_BET_COINS} coins!"}, 400
v.coins -= POLL_BET_COINS
g.db.add(v)
autojanny = get_account(AUTOJANNY_ID)
autojanny.coins += 200
autojanny.coins += POLL_BET_COINS
g.db.add(autojanny)
if option.exclusive:

View File

@ -87,8 +87,7 @@ def publish(pid, v):
@app.get("/h/<sub>/submit")
@auth_required
def submit_get(v, sub=None):
if sub: sub = g.db.get(Sub, sub.strip().lower())
sub = get_sub_by_name(sub, graceful=True)
if request.path.startswith('/h/') and not sub: abort(404)
SUBS = [x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()]

View File

@ -109,10 +109,7 @@ def unexile(v, sub, uid):
@app.post("/h/<sub>/block")
@auth_required
def block_sub(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub.name
sub = get_sub_by_name(sub).name
existing = g.db.query(SubBlock).filter_by(user_id=v.id, sub=sub).one_or_none()
if not existing:
@ -126,10 +123,8 @@ def block_sub(v, sub):
@app.post("/h/<sub>/unblock")
@auth_required
def unblock_sub(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub.name
sub = get_sub_by_name(sub).name
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
block = g.db.query(SubBlock).filter_by(user_id=v.id, sub=sub).one_or_none()
if block:
@ -142,10 +137,7 @@ def unblock_sub(v, sub):
@app.post("/h/<sub>/subscribe")
@auth_required
def subscribe_sub(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub.name
sub = get_sub_by_name(sub).name
existing = g.db.query(SubJoin).filter_by(user_id=v.id, sub=sub).one_or_none()
if not existing:
@ -158,10 +150,7 @@ def subscribe_sub(v, sub):
@app.post("/h/<sub>/unsubscribe")
@auth_required
def unsubscribe_sub(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub.name
sub = get_sub_by_name(sub).name
subscribe = g.db.query(SubJoin).filter_by(user_id=v.id, sub=sub).one_or_none()
if subscribe:
@ -173,11 +162,9 @@ def unsubscribe_sub(v, sub):
@app.post("/h/<sub>/follow")
@auth_required
def follow_sub(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
existing = g.db.query(SubSubscription).filter_by(user_id=v.id, sub=sub.name).one_or_none()
if not existing:
subscription = SubSubscription(user_id=v.id, sub=sub.name)
g.db.add(subscription)
@ -188,11 +175,8 @@ def follow_sub(v, sub):
@app.post("/h/<sub>/unfollow")
@auth_required
def unfollow_sub(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
subscription = g.db.query(SubSubscription).filter_by(user_id=v.id, sub=sub.name).one_or_none()
if subscription:
g.db.delete(subscription)
cache.delete_memoized(frontlist)
@ -202,9 +186,8 @@ def unfollow_sub(v, sub):
@app.get("/h/<sub>/mods")
@auth_required
def mods(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
users = g.db.query(User, Mod).join(Mod).filter_by(sub=sub.name).order_by(Mod.created_utc).all()
return render_template("sub/mods.html", v=v, sub=sub, users=users)
@ -213,9 +196,8 @@ def mods(v, sub):
@app.get("/h/<sub>/exilees")
@auth_required
def sub_exilees(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
users = g.db.query(User, Exile).join(Exile, Exile.user_id==User.id) \
.filter_by(sub=sub.name) \
.order_by(nullslast(Exile.created_utc.desc()), User.username).all()
@ -226,9 +208,8 @@ def sub_exilees(v, sub):
@app.get("/h/<sub>/blockers")
@auth_required
def sub_blockers(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
users = g.db.query(User).join(SubBlock) \
.filter_by(sub=sub.name) \
.order_by(nullslast(SubBlock.created_utc.desc()), User.username).all()
@ -240,9 +221,8 @@ def sub_blockers(v, sub):
@app.get("/h/<sub>/followers")
@auth_required
def sub_followers(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
users = g.db.query(User).join(SubSubscription) \
.filter_by(sub=sub.name) \
.order_by(nullslast(SubSubscription.created_utc.desc()), User.username).all()
@ -257,11 +237,7 @@ def sub_followers(v, sub):
@is_not_permabanned
def add_mod(v, sub):
if SITE_NAME == 'WPD': abort(403)
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub.name
sub = get_sub_by_name(sub).name
if not v.mods(sub): abort(403)
if v.shadowbanned: return redirect(f'/h/{sub}/mods')
@ -297,10 +273,8 @@ def add_mod(v, sub):
@app.post("/h/<sub>/remove_mod")
@is_not_permabanned
def remove_mod(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub.name
sub = get_sub_by_name(sub).name
if not v.mods(sub): abort(403)
if v.shadowbanned: return redirect(f'/h/{sub}/mods')
@ -356,7 +330,7 @@ def create_sub2(v):
if not valid_sub_regex.fullmatch(name):
return render_template("sub/create_hole.html", v=v, cost=HOLE_COST, error=f"{HOLE_NAME.capitalize()} name not allowed."), 400
sub = g.db.get(Sub, name)
sub = get_sub_by_name(sub, graceful=True)
if not sub:
if v.coins < HOLE_COST:
return render_template("sub/create_hole.html", v=v, cost=HOLE_COST, error="You don't have enough coins!"), 403
@ -425,11 +399,8 @@ def kick(v, pid):
@app.get('/h/<sub>/settings')
@is_not_permabanned
def sub_settings(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if not v.mods(sub.name): abort(403)
return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub)
@ -438,9 +409,7 @@ def sub_settings(v, sub):
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
@is_not_permabanned
def post_sub_sidebar(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if not v.mods(sub.name): abort(403)
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
@ -465,7 +434,7 @@ def post_sub_sidebar(v, sub):
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
@is_not_permabanned
def post_sub_css(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
sub = get_sub_by_name(sub)
css = request.values.get('css', '').strip()
if not sub: abort(404)
@ -509,9 +478,7 @@ def get_sub_css(sub):
def sub_banner(v, sub):
if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403
sub = g.db.get(Sub, sub.lower().strip())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if not v.mods(sub.name): abort(403)
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
@ -544,9 +511,7 @@ def sub_banner(v, sub):
def sub_sidebar(v, sub):
if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403
sub = g.db.get(Sub, sub.lower().strip())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if not v.mods(sub.name): abort(403)
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
@ -578,9 +543,7 @@ def sub_sidebar(v, sub):
def sub_marsey(v, sub):
if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403
sub = g.db.get(Sub, sub.lower().strip())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if not v.mods(sub.name): abort(403)
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
@ -667,9 +630,7 @@ def hole_unpin(v, pid):
@app.post('/h/<sub>/stealth')
@is_not_permabanned
def sub_stealth(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = get_sub_by_name(sub)
if sub.name == 'braincels': abort(403)
if not v.mods(sub.name): abort(403)
@ -754,10 +715,8 @@ def mod_unpin(cid, v):
@app.get("/h/<sub>/modlog")
@auth_required
def hole_log(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub
sub = get_sub_by_name(sub)
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
try: page = max(int(request.values.get("page", 1)), 1)
except: page = 1
@ -796,10 +755,8 @@ def hole_log(v, sub):
@app.get("/h/<sub>/log/<id>")
@auth_required
def hole_log_item(id, v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub
sub = get_sub_by_name(sub)
if sub.name == "chudrama" and not v.can_see_chudrama: abort(403)
try: id = int(id)
except: abort(404)

View File

@ -259,6 +259,21 @@ INSERT INTO public.hat_defs VALUES (774, 'French Fries', 'Now your salty and tas
INSERT INTO public.hat_defs VALUES (775, 'Condiment Top', 'Now you can squirt out tasty condiments!', 2, 500, NULL, 1664658867);
INSERT INTO public.hat_defs VALUES (767, 'bleh', 'froggy go “bleh”', 2, 500, NULL, 1664646019);
INSERT INTO public.hat_defs VALUES (768, 'PLAYER 1', 'you only have 2 lives left oop', 2, 500, NULL, 1664646508);
INSERT INTO public.hat_defs VALUES (783, 'A Beautiful Mind', 'Or a euphemism for schizophrenia', 2, 1000, NULL, 1664825990);
INSERT INTO public.hat_defs VALUES (784, 'Yolo swag 420 rekt', 'Also known as the epilepsy inducer', 2, 1000, NULL, 1664826603);
INSERT INTO public.hat_defs VALUES (782, 'Fatass minecrap streamer mask', 'I suck his dick / for hours at a time / stare at his nutsack / while I hold back my cum tonite', 2, 500, NULL, 1664768706);
INSERT INTO public.hat_defs VALUES (777, 'Fat and Stinky Visor', 'Why would you put those pins on a visor?!', 2, 500, NULL, 1664683498);
INSERT INTO public.hat_defs VALUES (778, 'Coke Jail', 'You drank pepsi, to coke jail with you.-CocaColaMan', 2, 500, NULL, 1664727469);
INSERT INTO public.hat_defs VALUES (779, 'nemean lion hood', 'Like a true roman, wear a lion!-gudi', 2, 500, NULL, 1664728578);
INSERT INTO public.hat_defs VALUES (780, 'Winged Hussar', 'To battle with wings on your head!', 2, 500, NULL, 1664731432);
INSERT INTO public.hat_defs VALUES (786, 'Ricks hair', 'Wubba lubba dub dub', 2, 500, NULL, 1664930047);
INSERT INTO public.hat_defs VALUES (781, 'BTC', 'Only wear this if you''re worth billions.', 2, 500, NULL, 1664750970);
@ -923,7 +938,7 @@ INSERT INTO public.hat_defs VALUES (504, 'Iron Crown of Lombardy', 'This isn''t
-- Name: hat_defs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('public.hat_defs_id_seq', 785, true);
SELECT pg_catalog.setval('public.hat_defs_id_seq', 802, true);
--
@ -1462,6 +1477,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES
('marseydrawing1',2,'drawing artist canvas painting recursion recursive',1664490986),
('marseydream',2,'spirals trippy swirls rainbow',NULL),
('marseydrone',2,'obama rotors',NULL),
('marseydrowned',2,'drowned dead marsey',1664998341),
('marseydrunk',2,'drinking shitfaced alcoholic liquor happy beer dizzy',NULL),
('marseydrunk2',2,'drinking shitfaced alcoholic liquor happy beer dizzy',NULL),
('marseyduchamp',2,'art urinal duchamp modern abstract',NULL),

File diff suppressed because one or more lines are too long