forked from rDrama/rDrama
1
0
Fork 0

fsdMerge branch 'frost' of https://github.com/Aevann1/Drama into frost

master
Aevann1 2022-06-26 06:18:09 +00:00
commit 2b1215c5ff
39 changed files with 125 additions and 307 deletions

View File

@ -27,7 +27,7 @@ services:
postgres:
image: postgres:12.3
# command: ["postgres", "-c", "log_statement=all"]
command: ["postgres", "-c", "log_statement=all"]
# uncomment this if u wanna output all SQL queries to the console
volumes:
- "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql"

View File

@ -94,13 +94,19 @@ def before_request():
@app.teardown_appcontext
def teardown_request(error):
if hasattr(g, 'db') and g.db:
g.db.rollback()
g.db.close()
del g.db
stdout.flush()
@app.after_request
def after_request(response):
response.headers.add("Strict-Transport-Security", "max-age=31536000")
response.headers.add("X-Frame-Options", "deny")
if response.status_code == 200:
g.db.commit()
g.db.close()
del g.db
return response
if app.config["SERVER_NAME"] == 'localhost':

View File

@ -12,8 +12,9 @@ from files.helpers.regex import *
from files.helpers.regex import *
from files.helpers.lazy import lazy
from .flags import CommentFlag
from random import randint
from .votes import CommentVote
from .saves import CommentSaveRelationship
from random import randint
from math import floor
@ -35,7 +36,7 @@ def sort_comments(sort, comments):
elif sort == 'controversial':
return comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc(), Comment.id.desc())
elif sort == "bottom":
return comments.order_by(Comment.realupvotes, Comment.id.desc())
return comments.order_by(Comment.upvotes - Comment.downvotes)
else:
return comments.order_by(Comment.realupvotes.desc(), Comment.id.desc())
@ -134,7 +135,7 @@ class Comment(Base):
@lazy
def total_choice_voted(self, v):
if v:
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).all()
return g.db.query(CommentVote.comment_id).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first()
return False
@property
@ -247,7 +248,7 @@ class Comment(Base):
if not self.parent_submission:
return [x for x in self.child_comments.order_by(Comment.id) if not x.author.shadowbanned]
comments = self.child_comments.filter(Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)))
comments = self.child_comments.filter(Comment.author_id.notin_(poll_bots))
comments = sort_comments(sort, comments)
return [x for x in comments if not x.author.shadowbanned]
@ -258,7 +259,7 @@ class Comment(Base):
if not self.parent_submission:
return self.child_comments.order_by(Comment.id).all()
comments = self.child_comments.filter(Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)))
comments = self.child_comments.filter(Comment.author_id.notin_(poll_bots))
return sort_comments(sort, comments).all()
@ -411,7 +412,6 @@ class Comment(Base):
if amount == 1:
self.upvotes += amount
g.db.add(self)
g.db.commit()
for c in self.options:
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
@ -424,7 +424,7 @@ class Comment(Base):
if self.choices:
curr = self.total_choice_voted(v)
if curr: curr = " value=" + str(curr[0].comment_id)
if curr: curr = " value=" + str(curr.comment_id)
else: curr = ''
body += f'<input class="d-none" id="current-{self.id}"{curr}>'
@ -562,4 +562,4 @@ class Comment(Base):
body += f" <em class='text-success'>Insured.</em>"
body += '</span>'
return body
return body

View File

@ -12,10 +12,11 @@ from files.helpers.regex import *
from files.helpers.lazy import lazy
from .flags import Flag
from .comment import Comment, normalize_urls_runtime
from flask import g
from .saves import SaveRelationship
from .sub import *
from .subscriptions import *
from .votes import CommentVote
from flask import g
def sort_posts(sort, posts):
if sort == "new":
@ -25,11 +26,11 @@ def sort_posts(sort, posts):
elif sort == "controversial":
return posts.order_by((Submission.upvotes+1)/(Submission.downvotes+1) + (Submission.downvotes+1)/(Submission.upvotes+1), Submission.downvotes.desc(), Submission.created_utc.desc())
elif sort == "bottom":
return posts.order_by(Submission.realupvotes, Submission.created_utc.desc())
return posts.order_by(Submission.upvotes - Submission.downvotes, Submission.created_utc.desc())
elif sort == "comments":
return posts.order_by(Submission.comment_count.desc(), Submission.created_utc.desc())
else:
return posts.order_by(Submission.realupvotes.desc(), Submission.created_utc.desc())
return posts.order_by(Submission.downvotes - Submission.upvotes, Submission.created_utc.desc())
class Submission(Base):
__tablename__ = "submissions"
@ -74,7 +75,6 @@ class Submission(Base):
approved_by = relationship("User", uselist=False, primaryjoin="Submission.is_approved==User.id", viewonly=True)
awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", viewonly=True)
reports = relationship("Flag", viewonly=True)
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id")
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)", viewonly=True)
bump_utc = deferred(Column(Integer, server_default=FetchedValue()))
@ -128,7 +128,7 @@ class Submission(Base):
@lazy
def total_choice_voted(self, v):
if v and self.choices:
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).all()
return g.db.query(CommentVote.comment_id).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first()
return False
@lazy
@ -387,7 +387,7 @@ class Submission(Base):
return url
@lazy
def realbody(self, v):
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>"
body = self.body_html or ""
@ -406,45 +406,45 @@ class Submission(Base):
self.views += amount*random.randint(3, 5)
self.upvotes += amount
g.db.add(self)
g.db.commit()
for c in self.options:
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
if c.poll_voted(v): body += " checked"
if v: body += f''' onchange="poll_vote('{c.id}', '{self.id}')"'''
else: body += f''' onchange="poll_vote_no_v('{c.id}', '{self.id}')"'''
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
if not self.total_poll_voted(v): body += ' d-none'
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="poll-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
if not listing:
for c in self.options:
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
if c.poll_voted(v): body += " checked"
if v: body += f''' onchange="poll_vote('{c.id}', '{self.id}')"'''
else: body += f''' onchange="poll_vote_no_v('{c.id}', '{self.id}')"'''
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
if not self.total_poll_voted(v): body += ' d-none'
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="poll-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
if self.choices:
curr = self.total_choice_voted(v)
if curr: curr = " value=" + str(curr[0].comment_id)
else: curr = ''
body += f'<input class="d-none" id="current-{self.id}"{curr}>'
if self.choices:
curr = self.total_choice_voted(v)
if curr: curr = " value=" + str(curr.comment_id)
else: curr = ''
body += f'<input class="d-none" id="current-{self.id}"{curr}>'
for c in self.choices:
body += f'''<div class="custom-control"><input name="choice-{self.id}" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''
if c.poll_voted(v): body += " checked "
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
if not self.total_choice_voted(v): body += ' d-none'
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="choice-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
for c in self.choices:
body += f'''<div class="custom-control"><input name="choice-{self.id}" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''
if c.poll_voted(v): body += " checked "
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
if not self.total_choice_voted(v): body += ' d-none'
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="choice-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
for c in self.bet_options:
body += f'''<div class="custom-control mt-3"><input autocomplete="off" class="custom-control-input bet" type="radio" id="{c.id}" onchange="bet_vote('{c.id}')"'''
if c.poll_voted(v): body += " checked "
if not (v and v.coins > 200) or self.total_bet_voted(v) or not v.can_gamble: body += " disabled "
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html} - <a href="/votes?link=t3_{c.id}"><span id="bet-{c.id}">{c.upvotes}</span> bets</a>'''
if not self.total_bet_voted(v):
body += '''<span class="cost"> (cost of entry: 200 coins)</span>'''
body += "</label>"
if v and v.admin_level > 2:
body += f'''<button class="btn btn-primary px-2 mx-2" style="font-size:10px;padding:2px" onclick="post_toast(this,'/distribute/{c.id}')">Declare winner</button>'''
body += "</div>"
for c in self.bet_options:
body += f'''<div class="custom-control mt-3"><input autocomplete="off" class="custom-control-input bet" type="radio" id="{c.id}" onchange="bet_vote('{c.id}')"'''
if c.poll_voted(v): body += " checked "
if not (v and v.coins > 200) or self.total_bet_voted(v) or not v.can_gamble: body += " disabled "
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html} - <a href="/votes?link=t3_{c.id}"><span id="bet-{c.id}">{c.upvotes}</span> bets</a>'''
if not self.total_bet_voted(v):
body += '''<span class="cost"> (cost of entry: 200 coins)</span>'''
body += "</label>"
if v and v.admin_level > 2:
body += f'''<button class="btn btn-primary px-2 mx-2" style="font-size:10px;padding:2px" onclick="post_toast(this,'/distribute/{c.id}')">Declare winner</button>'''
body += "</div>"
if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))):
body += f"<hr>{self.author.sig_html}"
if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))):
body += f"<hr>{self.author.sig_html}"
return body
@ -503,4 +503,5 @@ class Submission(Base):
return False
@lazy
def active_flags(self, v): return len(self.flags(v))
def active_flags(self, v):
return len(self.flags(v))

View File

@ -64,7 +64,7 @@ class User(Base):
unblockable = Column(Boolean)
bird = Column(Integer)
email = deferred(Column(String))
css = deferred(Column(String))
css = Column(String)
profilecss = deferred(Column(String))
passhash = deferred(Column(String))
post_count = Column(Integer, default=0)
@ -218,7 +218,6 @@ class User(Base):
if not self.has_badge(134):
new_badge = Badge(badge_id=134, user_id=self.id)
g.db.add(new_badge)
g.db.commit()
return True
return False
@ -234,8 +233,10 @@ class User(Base):
elif self.patron == 7: discount = 0.60
else: discount = 1
owned_badges = [x.badge_id for x in self.badges]
for badge in discounts:
if self.has_badge(badge): discount -= discounts[badge]
if badge in owned_badges: discount -= discounts[badge]
return discount
@ -481,6 +482,7 @@ class User(Base):
@property
@lazy
def modaction_notifications_count(self):
if not self.admin_level: return 0
return g.db.query(Notification).join(Comment).filter(
Notification.user_id == self.id, Notification.read == False,
Comment.is_banned == False, Comment.deleted_utc == 0,
@ -490,6 +492,7 @@ class User(Base):
@property
@lazy
def reddit_notifications_count(self):
if not self.can_view_offsitementions: return 0
return g.db.query(Notification).join(Comment).filter(
Notification.user_id == self.id, Notification.read == False,
Comment.is_banned == False, Comment.deleted_utc == 0,
@ -704,6 +707,9 @@ class User(Base):
def saved_idlist(self, page=1):
saved = [x[0] for x in g.db.query(SaveRelationship.submission_id).filter_by(user_id=self.id).all()]
if not saved: return []
posts = g.db.query(Submission.id).filter(Submission.id.in_(saved), Submission.is_banned == False, Submission.deleted_utc == 0)
if self.admin_level < 2:
@ -715,6 +721,9 @@ class User(Base):
def saved_comment_idlist(self, page=1):
saved = [x[0] for x in g.db.query(CommentSaveRelationship.comment_id).filter_by(user_id=self.id).all()]
if not saved: return []
comments = g.db.query(Comment.id).filter(Comment.id.in_(saved), Comment.is_banned == False, Comment.deleted_utc == 0)
if self.admin_level < 2:

View File

@ -75,7 +75,6 @@ def award_timers(v, bot=False):
if dirty:
g.db.add(v)
g.db.commit()
def award_timers_bots_task():
accs = g.db.query(User).filter(User.id.in_(bots))

View File

@ -21,6 +21,7 @@ def cron(every_5m, every_1h, every_1d, every_1mo):
if every_5m:
lottery.check_if_end_lottery_task()
offsitementions.offsite_mentions_task()
g.db.commit()
if every_1h:
pass
@ -30,6 +31,10 @@ def cron(every_5m, every_1h, every_1d, every_1mo):
route_static.stats_cached()
awards.award_timers_bots_task()
sub_inactive_purge_task()
g.db.commit()
if every_1mo:
give_monthly_marseybux_task()
give_monthly_marseybux_task()
g.db.commit()
g.db.close()

View File

@ -120,8 +120,7 @@ def get_post(i, v=None, graceful=False):
else: abort(404)
if v:
vt = g.db.query(Vote).filter_by(
user_id=v.id, submission_id=i).subquery()
vt = g.db.query(Vote).filter_by(user_id=v.id, submission_id=i).subquery()
blocking = v.blocking.subquery()
post = g.db.query(
@ -166,7 +165,7 @@ def get_posts(pids, v=None):
return []
if v:
vt = g.db.query(Vote).filter(
vt = g.db.query(Vote.vote_type, Vote.submission_id).filter(
Vote.submission_id.in_(pids),
Vote.user_id==v.id
).subquery()
@ -228,8 +227,7 @@ def get_comment(i, v=None, graceful=False):
)
).first()
vts = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id)
vt = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
vt = g.db.query(CommentVote.vote_type).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
comment.is_blocking = block and block.user_id == v.id
comment.is_blocked = block and block.target_id == v.id
comment.voted = vt.vote_type if vt else 0
@ -242,7 +240,7 @@ def get_comments(cids, v=None, load_parent=False):
if not cids: return []
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
blocking = v.blocking.subquery()
@ -286,8 +284,6 @@ def get_comments(cids, v=None, load_parent=False):
if load_parent:
parents = [x.parent_comment_id for x in output if x.parent_comment_id]
parents = get_comments(parents, v=v)
parents = {x.id: x for x in parents}
for c in output: c.sex = parents.get(c.parent_comment_id)
return sorted(output, key=lambda x: cids.index(x.id))

View File

@ -58,7 +58,6 @@ def end_lottery_session():
active_lottery.is_active = False
g.db.commit()
return True, f'{winning_user.username} won {active_lottery.prize} coins!'
@ -75,7 +74,6 @@ def start_new_lottery_session():
lottery.is_active = True
g.db.add(lottery)
g.db.commit()
def check_if_end_lottery_task():
@ -110,7 +108,6 @@ def purchase_lottery_tickets(v, quantity=1):
most_recent_lottery.prize += net_ticket_value
most_recent_lottery.tickets_sold += quantity
g.db.commit()
if quantity == 1: return True, f'Successfully purchased {quantity} lottery ticket!'
return True, f'Successfully purchased {quantity} lottery tickets!'
@ -126,4 +123,3 @@ def grant_lottery_tickets_to_user(v, quantity):
active_lottery.prize += prize_value
active_lottery.tickets_sold += quantity
g.db.commit()

View File

@ -84,5 +84,4 @@ def notify_mentions(send_to, mentions, mention_str='site mention'):
notif = Notification(comment_id=new_comment.id, user_id=user_id)
g.db.add(notif)
g.db.commit()

View File

@ -59,7 +59,6 @@ def get_logged_in_user():
if (v.last_active + LOGGEDIN_ACTIVE_TIME) < timestamp:
v.last_active = timestamp
g.db.add(v)
g.db.commit()
else:
ua = str(user_agents.parse(g.agent))
if not ua.startswith('Spider') and 'bot' not in ua.lower():
@ -79,7 +78,6 @@ def check_ban_evade(v):
if v and not v.patron and v.admin_level < 2 and v.ban_evade and not v.unban_utc:
v.shadowbanned = "AutoJanny"
g.db.add(v)
g.db.commit()
def auth_desired(f):
def wrapper(*args, **kwargs):

View File

@ -84,6 +84,5 @@ def activate(v):
badge_grant(user=user, badge_id=2)
g.db.add(user)
g.db.commit()
return render_template("message_success.html", v=v, title="Email verified.", message=f"Your email {email} has been verified. Thank you.")

View File

@ -46,7 +46,6 @@ def give_monthly_marseybux_task():
)
g.db.add(ma)
g.db.commit()
return True
@ -57,7 +56,6 @@ def kippy(v):
kippy = get_account(KIPPY_ID)
kippy.procoins += 10000
g.db.add(kippy)
g.db.commit()
return '10k marseycoins printed!'
@app.get('/admin/loggedin')
@ -127,7 +125,6 @@ def merge(v, id1, id2):
g.db.add(user1)
g.db.add(user2)
g.db.commit()
cache.clear()
return redirect(user1.url)
@ -174,7 +171,6 @@ def merge_all(v, id):
g.db.add(alt)
g.db.add(user)
g.db.commit()
cache.clear()
return redirect(user.url)
@ -210,7 +206,6 @@ if SITE_NAME == 'PCM':
)
g.db.add(ma)
g.db.commit()
return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!')
@ -232,7 +227,6 @@ def make_admin(v, username):
)
g.db.add(ma)
g.db.commit()
return {"message": "User has been made admin!"}
@ -251,7 +245,6 @@ def remove_admin(v, username):
)
g.db.add(ma)
g.db.commit()
return {"message": "Admin removed!"}
@app.post("/distribute/<comment>")
@ -299,7 +292,6 @@ def distribute(v, comment):
)
g.db.add(ma)
g.db.commit()
return {"message": f"Each winner has received {coinsperperson} coins!"}
@app.post("/@<username>/revert_actions")
@ -347,7 +339,6 @@ def revert_actions(v, username):
send_repeatable_notification(u.id, f"@{v.username} has unbanned you!")
g.db.add(u)
g.db.commit()
return {"message": "Admin actions reverted!"}
@app.post("/@<username>/club_allow")
@ -375,7 +366,6 @@ def club_allow(v, username):
)
g.db.add(ma)
g.db.commit()
return {"message": f"@{username} has been allowed into the {CC_TITLE}!"}
@app.post("/@<username>/club_ban")
@ -402,7 +392,6 @@ def club_ban(v, username):
)
g.db.add(ma)
g.db.commit()
return {"message": f"@{username} has been kicked from the {CC_TITLE}. Deserved."}
@ -527,7 +516,6 @@ def change_settings(v, setting):
)
g.db.add(ma)
g.db.commit()
return {'message': f"{setting} {word}d successfully!"}
@ -559,7 +547,6 @@ def under_attack(v):
user_id=v.id,
)
g.db.add(ma)
g.db.commit()
response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data='{"value":"medium"}', timeout=5))
if response == "<Response [200]>": return {"message": "Under attack mode disabled!"}
@ -570,7 +557,6 @@ def under_attack(v):
user_id=v.id,
)
g.db.add(ma)
g.db.commit()
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!"}
@ -627,7 +613,6 @@ def badge_grant_post(v):
)
g.db.add(ma)
g.db.commit()
return render_template("admin/badge_grant.html", v=v, badge_types=badges, msg="Badge granted!")
@ -667,7 +652,6 @@ def badge_remove_post(v):
g.db.delete(badge)
g.db.commit()
return render_template("admin/badge_remove.html", v=v, badge_types=badges, msg="Badge removed!")
@ -845,7 +829,6 @@ def admin_link_accounts(v):
)
g.db.add(ma)
g.db.commit()
return redirect(f"/admin/alt_votes?u1={get_account(u1).username}&u2={get_account(u2).username}")
@ -930,7 +913,6 @@ def agendaposter(user_id, v):
send_repeatable_notification(user.id, f"@{v.username} has marked you as a chud ({note}).")
g.db.commit()
return redirect(user.url)
@ -961,7 +943,6 @@ def unagendaposter(user_id, v):
send_repeatable_notification(user.id, f"@{v.username} has unmarked you as a chud.")
g.db.commit()
return {"message": "Chud theme disabled!"}
@ -988,7 +969,6 @@ def shadowban(user_id, v):
cache.delete_memoized(frontlist)
notify_mod_action(v.id, f"@{v.username} has shadowbanned @{user.username}")
g.db.commit()
return {"message": "User shadowbanned!"}
@ -1015,7 +995,6 @@ def unshadowban(user_id, v):
cache.delete_memoized(frontlist)
notify_mod_action(v.id, f"@{v.username} has unshadowbanned @{user.username}")
g.db.commit()
return {"message": "User unshadowbanned!"}
@ -1054,7 +1033,6 @@ def admin_title_change(user_id, v):
_note=f'"{user.customtitleplain}"'
)
g.db.add(ma)
g.db.commit()
return redirect(user.url)
@ -1121,7 +1099,6 @@ def ban_user(user_id, v):
g.db.add(comment)
notify_mod_action(v.id, f"@{v.username} has banned @{user.username} ({note})")
g.db.commit()
if 'redir' in request.values: return redirect(user.url)
else: return {"message": f"@{user.username} was banned!"}
@ -1159,7 +1136,6 @@ def unban_user(user_id, v):
g.db.add(ma)
notify_mod_action(v.id, f"@{v.username} has unbanned @{user.username}")
g.db.commit()
if "@" in request.referrer: return redirect(user.url)
else: return {"message": f"@{user.username} was unbanned!"}
@ -1201,7 +1177,6 @@ def ban_post(post_id, v):
requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache',
headers=CF_HEADERS, json={'files': [f"{SITE_FULL}/logged_out/"]}, timeout=5)
g.db.commit()
return {"message": "Post removed!"}
@ -1241,7 +1216,6 @@ def unban_post(post_id, v):
if v.id != post.author_id:
notify_mod_action(v.id, f"@{v.username} has approved [{post.title}]({post.shortlink}) by @{post.author.username}")
g.db.commit()
return {"message": "Post approved!"}
@ -1272,7 +1246,6 @@ def api_distinguish_post(post_id, v):
)
g.db.add(ma)
g.db.commit()
if post.distinguish_level: return {"message": "Post distinguished!"}
else: return {"message": "Post undistinguished!"}
@ -1304,7 +1277,6 @@ def sticky_post(post_id, v):
send_repeatable_notification(post.author_id, f"@{v.username} has pinned your [post](/post/{post_id})!")
cache.delete_memoized(frontlist)
g.db.commit()
return {"message": "Post pinned!"}
@app.post("/unsticky/<post_id>")
@ -1330,7 +1302,6 @@ def unsticky_post(post_id, v):
send_repeatable_notification(post.author_id, f"@{v.username} has unpinned your [post](/post/{post_id})!")
cache.delete_memoized(frontlist)
g.db.commit()
return {"message": "Post unpinned!"}
@app.post("/sticky_comment/<cid>")
@ -1354,7 +1325,6 @@ def sticky_comment(cid, v):
message = f"@{v.username} has pinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment pinned!"}
@ -1381,7 +1351,6 @@ def unsticky_comment(cid, v):
message = f"@{v.username} has unpinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment unpinned!"}
@ -1408,7 +1377,6 @@ def api_ban_comment(c_id, v):
if v.id != comment.author_id:
notify_mod_action(v.id, f"@{v.username} has removed [comment]({comment.shortlink}) by @{comment.author.username}")
g.db.commit()
return {"message": "Comment removed!"}
@ -1440,7 +1408,6 @@ def api_unban_comment(c_id, v):
if v.id != comment.author_id:
notify_mod_action(v.id, f"@{v.username} has approved [comment]({comment.shortlink}) by @{comment.author.username}")
g.db.commit()
return {"message": "Comment approved!"}
@ -1470,7 +1437,6 @@ def admin_distinguish_comment(c_id, v):
)
g.db.add(ma)
g.db.commit()
if comment.distinguish_level: return {"message": "Comment distinguished!"}
else: return {"message": "Comment undistinguished!"}
@ -1526,7 +1492,6 @@ def admin_toggle_ban_domain(v):
)
g.db.add(ma)
g.db.commit()
return redirect("/admin/banned_domains/")
@ -1563,7 +1528,6 @@ def admin_nuke_user(v):
notify_mod_action(v.id, f"@{v.username} has nuked @{user.username}")
g.db.commit()
return redirect(user.url)
@ -1600,6 +1564,5 @@ def admin_nunuke_user(v):
notify_mod_action(v.id, f"@{v.username} has un-nuked @{user.username}")
g.db.commit()
return redirect(user.url)

View File

@ -97,7 +97,6 @@ def buy(v, award):
if CARP_ID and v.id != CARP_ID and og_price >= 10000:
send_repeatable_notification(CARP_ID, f"@{v.username} has bought a `{award}` award!")
g.db.commit()
return {"message": "Award bought!"}
@ -298,7 +297,6 @@ def award_thing(v, thing_type, id):
else: author.received_award_count = 1
g.db.add(author)
g.db.commit()
if request.referrer and len(request.referrer) > 1:
if request.referrer == f'{SITE_FULL}/submit': return redirect(thing.permalink)
elif request.referrer.startswith(f'{SITE_FULL}/'): return redirect(request.referrer)
@ -371,7 +369,6 @@ def admin_userawards_post(v):
)
g.db.add(ma)
g.db.commit()
if v.admin_level != 3: return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)

View File

@ -66,7 +66,6 @@ def speak(data, v):
emit('speak', data)
v.shadowbanned = 'AutoJanny'
g.db.add(v)
g.db.commit()
else:
emit('speak', data, broadcast=True)
messages.append(data)

View File

@ -83,7 +83,6 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
if notif:
notif.read = True
g.db.add(notif)
g.db.commit()
if comment.post and comment.post.club and not (v and (v.paid_dues or v.id in [comment.author_id, comment.post.author_id])): abort(403)
@ -118,7 +117,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
sort=request.values.get("sort", defaultsortingcomments)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
blocking = v.blocking.subquery()
@ -135,8 +134,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
comments=comments.filter(
Comment.parent_submission == post.id,
Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID))
Comment.top_comment_id == c.top_comment_id,
Comment.author_id.notin_(poll_bots)
).join(
votes,
votes.c.comment_id == Comment.id,
@ -645,7 +644,6 @@ def api_comment(v):
parent_post.comment_count += 1
g.db.add(parent_post)
g.db.commit()
if request.headers.get("Authorization"): return c.json
return {"comment": render_template("comments.html", v=v, comments=[c], ajax=True)}
@ -807,7 +805,6 @@ def edit_comment(cid, v):
n = Notification(comment_id=c.id, user_id=x)
g.db.add(n)
g.db.commit()
return {"comment": c.realbody(v)}
@ -830,7 +827,6 @@ def delete_comment(cid, v):
cache.delete_memoized(comment_idlist)
g.db.commit()
return {"message": "Comment deleted!"}
@ -851,7 +847,6 @@ def undelete_comment(cid, v):
cache.delete_memoized(comment_idlist)
g.db.commit()
return {"message": "Comment undeleted!"}
@ -875,7 +870,6 @@ def pin_comment(cid, v):
else: message = f"@{v.username} (OP) has pinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment pinned!"}
@ -897,7 +891,6 @@ def unpin_comment(cid, v):
if v.id != comment.author_id:
message = f"@{v.username} (OP) has unpinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment unpinned!"}
@ -918,7 +911,6 @@ def mod_pin(cid, v):
message = f"@{v.username} (Mod) has pinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment pinned!"}
@ -937,7 +929,6 @@ def mod_unpin(cid, v):
if v.id != comment.author_id:
message = f"@{v.username} (Mod) has unpinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment unpinned!"}
@ -955,7 +946,6 @@ def save_comment(cid, v):
new_save=CommentSaveRelationship(user_id=v.id, comment_id=comment.id)
g.db.add(new_save)
g.db.commit()
return {"message": "Comment saved!"}
@ -971,7 +961,6 @@ def unsave_comment(cid, v):
if save:
g.db.delete(save)
g.db.commit()
return {"message": "Comment unsaved!"}
@ -992,7 +981,6 @@ def handle_blackjack_action(cid, v):
g.db.add(comment)
g.db.add(v)
g.db.commit()
return {"response" : comment.blackjack_html(v)}
@ -1043,6 +1031,5 @@ def handle_wordle_action(cid, v):
comment.wordle_result = f'{guesses}_{status}_{answer}'
g.db.add(comment)
g.db.commit()
return {"response" : comment.wordle_html(v)}

View File

@ -140,6 +140,5 @@ def discord_redirect(v):
requests.patch(url, headers=headers, json=data, timeout=5)
g.db.commit()
return redirect(f"https://discord.com/channels/{SERVER_ID}/{WELCOME_CHANNEL}")

View File

@ -14,7 +14,6 @@ def clear(v):
for n in notifs:
n.read = True
g.db.add(n)
g.db.commit()
return {"message": "Notifications cleared!"}
@app.get("/unread")
@ -31,7 +30,6 @@ def unread(v):
for n, c in listing:
n.read = True
g.db.add(n)
g.db.commit()
return {"data":[x[1].json for x in listing]}
@ -162,7 +160,6 @@ def notifications(v):
if c not in listing: listing.append(c)
g.db.commit()
if request.headers.get("Authorization"): return {"data":[x.json for x in listing]}
@ -334,7 +331,6 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
if ids_only: posts = [x.id for x in posts]
g.db.commit()
return posts, next_exists

View File

@ -148,7 +148,6 @@ def login_post():
check_for_alts(account.id)
g.db.commit()
redir = request.values.get("redirect")
if redir:
@ -349,19 +348,15 @@ def sign_up_post(v):
try: send_verification_email(new_user)
except Exception as e: print(e)
existing_account = get_user(username, graceful=True)
if existing_account:
return signup_error("An account with that username already exists.")
g.db.commit()
check_for_alts(new_user.id)
g.db.flush()
send_notification(new_user.id, WELCOME_MSG)
session["lo_user"] = new_user.id
g.db.commit()
return redirect(SITE_FULL)
@ -479,7 +474,6 @@ def post_reset(v):
user.passhash = hash_password(password)
g.db.add(user)
g.db.commit()
return render_template("message_success.html",
title="Password reset successful!",
@ -558,7 +552,6 @@ def reset_2fa():
g.db.add(user)
g.db.commit()
return render_template("message_success.html",
title="Two-factor authentication removed.",

View File

@ -30,7 +30,6 @@ def authorize(v):
try:
new_auth = ClientAuth(oauth_client = application.id, user_id = v.id, access_token=access_token)
g.db.add(new_auth)
g.db.commit()
except sqlalchemy.exc.IntegrityError:
g.db.rollback()
old_auth = g.db.query(ClientAuth).filter_by(oauth_client = application.id, user_id = v.id).one()
@ -76,7 +75,6 @@ def request_api_keys(v):
g.db.add(notif)
g.db.commit()
return redirect('/settings/apps')
@ -97,7 +95,6 @@ def delete_oauth_app(v, aid):
g.db.delete(app)
g.db.commit()
return redirect('/apps')
@ -119,7 +116,6 @@ def edit_oauth_app(v, aid):
g.db.add(app)
g.db.commit()
return redirect('/settings/apps')
@ -153,7 +149,6 @@ def admin_app_approve(v, aid):
)
g.db.add(ma)
g.db.commit()
return {"message": "Application approved"}
@ -178,7 +173,6 @@ def admin_app_revoke(v, aid):
)
g.db.add(ma)
g.db.commit()
return {"message": "App revoked"}
@ -204,7 +198,6 @@ def admin_app_reject(v, aid):
)
g.db.add(ma)
g.db.commit()
return {"message": "App rejected"}
@ -281,6 +274,5 @@ def reroll_oauth_tokens(aid, v):
a.client_id = secrets.token_urlsafe(64)[:64]
g.db.add(a)
g.db.commit()
return {"message": "Client ID Rerolled", "id": a.client_id}

View File

@ -30,14 +30,6 @@ if path.exists(f'snappy_{SITE_NAME}.txt'):
with open(f'snappy_{SITE_NAME}.txt', "r", encoding="utf-8") as f:
snappyquotes += f.read().split("\n{[para]}\n")
discounts = {
69: 0.02,
70: 0.04,
71: 0.06,
72: 0.08,
73: 0.10,
}
titleheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"}
@ -51,7 +43,6 @@ def toggle_club(pid, v):
post.club = not post.club
g.db.add(post)
g.db.commit()
if post.club: return {"message": "Post has been marked as club-only!"}
else: return {"message": "Post has been unmarked as club-only!"}
@ -91,7 +82,6 @@ def publish(pid, v):
if post.sub:
on_post_hole_entered(post)
g.db.commit()
cache.delete_memoized(frontlist)
cache.delete_memoized(User.userpagelisting)
@ -149,7 +139,7 @@ def post_id(pid, anything=None, v=None, sub=None):
if post.club and not (v and (v.paid_dues or v.id == post.author_id)): abort(403)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
blocking = v.blocking.subquery()
@ -165,7 +155,7 @@ def post_id(pid, anything=None, v=None, sub=None):
if not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID))).join(
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id.notin_(poll_bots)).join(
votes,
votes.c.comment_id == Comment.id,
isouter=True
@ -199,7 +189,7 @@ def post_id(pid, anything=None, v=None, sub=None):
else:
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.stickied != None).all()
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.stickied == None)
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id.notin_(poll_bots), Comment.level == 1, Comment.stickied == None)
comments = sort_comments(sort, comments)
@ -241,7 +231,6 @@ def post_id(pid, anything=None, v=None, sub=None):
post.views += 1
g.db.add(post)
g.db.commit()
if request.headers.get("Authorization"): return post.json
else:
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
@ -262,7 +251,7 @@ def viewmore(v, pid, sort, offset):
except: abort(400)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
blocking = v.blocking.subquery()
@ -273,7 +262,7 @@ def viewmore(v, pid, sort, offset):
votes.c.vote_type,
blocking.c.target_id,
blocked.c.target_id,
).filter(Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.stickied == None, Comment.id.notin_(ids))
).filter(Comment.parent_submission == pid, Comment.author_id.notin_(poll_bots), Comment.stickied == None, Comment.id.notin_(ids))
if not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
@ -308,7 +297,7 @@ def viewmore(v, pid, sort, offset):
second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body_html) <= 100).all()]
comments = first + second
else:
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.stickied == None, Comment.id.notin_(ids))
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_(poll_bots), Comment.level == 1, Comment.stickied == None, Comment.id.notin_(ids))
comments = sort_comments(sort, comments)
@ -349,7 +338,7 @@ def morecomments(v, cid):
tcid = g.db.query(Comment.top_comment_id).filter_by(id=cid).one_or_none()[0]
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
blocking = v.blocking.subquery()
@ -521,7 +510,6 @@ def edit_post(pid, v):
)
g.db.add(ma)
g.db.commit()
return redirect(p.permalink)
@ -1214,7 +1202,6 @@ def submit_post(v, sub=None):
post.upvotes += 3
g.db.add(post)
g.db.commit()
cache.delete_memoized(frontlist)
cache.delete_memoized(User.userpagelisting)
@ -1250,7 +1237,6 @@ def delete_post_pid(pid, v):
cache.delete_memoized(frontlist)
cache.delete_memoized(User.userpagelisting)
g.db.commit()
return {"message": "Post deleted!"}
@ -1267,7 +1253,6 @@ def undelete_post_pid(pid, v):
cache.delete_memoized(frontlist)
cache.delete_memoized(User.userpagelisting)
g.db.commit()
return {"message": "Post undeleted!"}
@ -1290,7 +1275,6 @@ def toggle_comment_nsfw(cid, v):
target_comment_id = comment.id,
)
g.db.add(ma)
g.db.commit()
if comment.over_18: return {"message": "Comment has been marked as +18!"}
else: return {"message": "Comment has been unmarked as +18!"}
@ -1313,7 +1297,6 @@ def toggle_post_nsfw(pid, v):
target_submission_id = post.id,
)
g.db.add(ma)
g.db.commit()
if post.over_18: return {"message": "Post has been marked as +18!"}
else: return {"message": "Post has been unmarked as +18!"}
@ -1331,7 +1314,6 @@ def save_post(pid, v):
if not save:
new_save=SaveRelationship(user_id=v.id, submission_id=post.id)
g.db.add(new_save)
g.db.commit()
return {"message": "Post saved!"}
@ -1347,7 +1329,6 @@ def unsave_post(pid, v):
if save:
g.db.delete(save)
g.db.commit()
return {"message": "Post unsaved!"}
@ -1363,7 +1344,6 @@ def api_pin_post(post_id, v):
cache.delete_memoized(User.userpagelisting)
g.db.commit()
if post.is_pinned: return {"message": "Post pinned!"}
else: return {"message": "Post unpinned!"}
return {"error": "Post not found!"}

View File

@ -46,7 +46,6 @@ def api_flag_post(pid, v):
flag = Flag(post_id=post.id, user_id=v.id, reason=reason)
g.db.add(flag)
g.db.commit()
return {"message": "Post reported!"}
@ -77,7 +76,6 @@ def api_flag_comment(cid, v):
flag = CommentFlag(comment_id=comment.id, user_id=v.id, reason=reason)
g.db.add(flag)
g.db.commit()
return {"message": "Comment reported!"}
@ -105,7 +103,6 @@ def remove_report_post(v, pid, uid):
g.db.add(ma)
g.db.commit()
return {"message": "Report removed successfully!"}
@ -131,6 +128,5 @@ def remove_report_comment(v, cid, uid):
g.db.add(ma)
g.db.commit()
return {"message": "Report removed successfully!"}

View File

@ -38,7 +38,6 @@ tiers={
def removebackground(v):
v.background = None
g.db.add(v)
g.db.commit()
return {"message": "Background removed!"}
@app.post("/settings/profile")
@ -118,28 +117,24 @@ def settings_profile_post(v):
v.bio = None
v.bio_html = None
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v, msg="Your bio has been updated.")
elif request.values.get("sig") == "":
v.sig = None
v.sig_html = None
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v, msg="Your sig has been updated.")
elif request.values.get("friends") == "":
v.friends = None
v.friends_html = None
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v, msg="Your friends list has been updated.")
elif request.values.get("enemies") == "":
v.enemies = None
v.enemies_html = None
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v, msg="Your enemies list has been updated.")
elif (v.patron or v.id == MOOSE_ID) and request.values.get("sig"):
@ -155,7 +150,6 @@ def settings_profile_post(v):
v.sig = sig[:200]
v.sig_html=sig_html
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html",
v=v,
msg="Your sig has been updated.")
@ -184,7 +178,6 @@ def settings_profile_post(v):
v.friends = friends[:500]
v.friends_html=friends_html
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html",
v=v,
msg="Your friends list has been updated.")
@ -211,7 +204,6 @@ def settings_profile_post(v):
v.enemies = enemies[:500]
v.enemies_html=enemies_html
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html",
v=v,
msg="Your enemies list has been updated.")
@ -236,7 +228,6 @@ def settings_profile_post(v):
v.bio = bio[:1500]
v.bio_html=bio_html
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html",
v=v,
msg="Your bio has been updated.")
@ -300,7 +291,6 @@ def settings_profile_post(v):
if updated:
g.db.add(v)
g.db.commit()
return {"message": "Your settings have been updated."}
@ -318,7 +308,6 @@ def filters(v):
v.custom_filter_list=filters
g.db.add(v)
g.db.commit()
return render_template("settings_filters.html", v=v, msg="Your custom filters have been updated.")
@app.post("/changelogsub")
@ -329,7 +318,6 @@ def changelogsub(v):
cache.delete_memoized(frontlist)
g.db.commit()
if v.changelogsub: return {"message": "You have subscribed to the changelog!"}
else: return {"message": "You have unsubscribed from the changelog!"}
@ -347,7 +335,6 @@ def namecolor(v):
v.namecolor = color
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@app.post("/settings/themecolor")
@ -364,7 +351,6 @@ def themecolor(v):
v.themecolor = themecolor
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@app.post("/settings/gumroad")
@ -401,7 +387,6 @@ def gumroad(v):
badge_grant(badge_id=20+tier, user=v)
g.db.commit()
return {"message": f"{patron} rewards claimed!"}
@ -418,7 +403,6 @@ def titlecolor(v):
return render_template("settings_profile.html", v=v, error="Invalid color code")
v.titlecolor = titlecolor
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@app.post("/settings/verifiedcolor")
@ -431,7 +415,6 @@ def verifiedcolor(v):
if len(verifiedcolor) != 6: return render_template("settings_profile.html", v=v, error="Invalid color code")
v.verifiedcolor = verifiedcolor
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@app.post("/settings/security")
@ -453,7 +436,6 @@ def settings_security_post(v):
g.db.add(v)
g.db.commit()
return render_template("settings_security.html", v=v, msg="Your password has been changed.")
@ -497,7 +479,6 @@ def settings_security_post(v):
v.mfa_secret = secret
g.db.add(v)
g.db.commit()
return render_template("settings_security.html", v=v, msg="Two-factor authentication enabled.")
@ -514,7 +495,6 @@ def settings_security_post(v):
v.mfa_secret = None
g.db.add(v)
g.db.commit()
return render_template("settings_security.html", v=v, msg="Two-factor authentication disabled.")
@ -535,7 +515,6 @@ def settings_log_out_others(v):
g.db.add(v)
g.db.commit()
return render_template("settings_security.html", v=v, msg="All other devices have been logged out")
@ -571,7 +550,6 @@ def settings_images_profile(v):
v.profileurl = imageurl
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v, msg="Profile picture successfully updated.")
@ -595,7 +573,6 @@ def settings_images_banner(v):
if path.isfile(fpath): os.remove(fpath)
v.bannerurl = bannerurl
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v, msg="Banner successfully updated.")
@ -622,7 +599,6 @@ def settings_css(v):
css = request.values.get("css").strip().replace('\\', '').strip()[:4000]
v.css = css
g.db.add(v)
g.db.commit()
return render_template("settings_css.html", v=v)
@ -649,7 +625,6 @@ def settings_profilecss(v):
v.profilecss = profilecss
g.db.add(v)
g.db.commit()
return render_template("settings_profilecss.html", v=v)
@app.post("/settings/block")
@ -665,7 +640,6 @@ def settings_block_user(v):
if user.unblockable:
if not v.shadowbanned:
send_notification(user.id, f"@{v.username} has tried to block you and failed because of your unblockable status!")
g.db.commit()
return {"error": "This user is unblockable."}, 403
if user.id == v.id:
@ -686,7 +660,6 @@ def settings_block_user(v):
cache.delete_memoized(frontlist)
g.db.commit()
return {"message": f"@{user.username} blocked."}
@ -710,7 +683,6 @@ def settings_unblock_user(v):
cache.delete_memoized(frontlist)
g.db.commit()
return {"message": f"@{user.username} unblocked."}
@ -733,7 +705,6 @@ def settings_remove_discord(v):
v.discord_id=None
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@ -784,7 +755,6 @@ def settings_name_change(v):
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@ -810,7 +780,6 @@ def settings_song_change_mp3(v):
v.song = v.id
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@ -828,7 +797,6 @@ def settings_song_change(v):
os.remove(f"/songs/{v.song}.mp3")
v.song = None
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
song = song.replace("https://music.youtube.com", "https://youtube.com")
@ -845,7 +813,6 @@ def settings_song_change(v):
if path.isfile(f'/songs/{id}.mp3'):
v.song = id
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@ -892,7 +859,6 @@ def settings_song_change(v):
v.song = id
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@ -914,7 +880,6 @@ def settings_title_change(v):
if len(v.customtitle) < 1000:
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")
@ -935,7 +900,6 @@ def settings_checkmark_text(v):
v.verified = new_name
g.db.add(v)
g.db.commit()
return redirect("/settings/profile")

View File

@ -219,7 +219,6 @@ def submit_contact(v):
g.db.commit()
return render_template("contact.html", v=v, msg="Your message has been sent.")
@app.get('/archives')

View File

@ -29,7 +29,6 @@ def exile_post(v, pid):
send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{p.title}]({p.shortlink})")
g.db.commit()
return {"message": "User exiled successfully!"}
@ -57,7 +56,6 @@ def exile_comment(v, cid):
send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{c.permalink}]({c.shortlink})")
g.db.commit()
return {"message": "User exiled successfully!"}
@ -75,7 +73,6 @@ def unexile(v, sub, uid):
send_notification(u.id, f"@{v.username} has revoked your exile from /h/{sub}")
g.db.commit()
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"message": "User unexiled successfully!"}
@ -101,7 +98,6 @@ def block_sub(v, sub):
if not existing:
block = SubBlock(user_id=v.id, sub=sub)
g.db.add(block)
g.db.commit()
cache.delete_memoized(frontlist)
return {"message": "Sub blocked successfully!"}
@ -118,7 +114,6 @@ def unblock_sub(v, sub):
if block:
g.db.delete(block)
g.db.commit()
cache.delete_memoized(frontlist)
return {"message": "Sub unblocked successfully!"}
@ -134,7 +129,6 @@ def follow_sub(v, sub):
if not existing:
subscription = SubSubscription(user_id=v.id, sub=sub.name)
g.db.add(subscription)
g.db.commit()
return {"message": "Sub followed successfully!"}
@ -148,7 +142,6 @@ def unfollow_sub(v, sub):
.filter_by(user_id=v.id, sub=sub.name).one_or_none()
if subscription:
g.db.delete(subscription)
g.db.commit()
return {"message": "Sub unfollowed successfully!"}
@ -225,7 +218,6 @@ def add_mod(v, sub):
if v.id != user.id:
send_repeatable_notification(user.id, f"@{v.username} has added you as a mod to /h/{sub}")
g.db.commit()
return redirect(f'/h/{sub}/mods')
@ -260,7 +252,6 @@ def remove_mod(v, sub):
if v.id != user.id:
send_repeatable_notification(user.id, f"@{v.username} has removed you as a mod from /h/{sub}")
g.db.commit()
return redirect(f'/h/{sub}/mods')
@ -299,7 +290,6 @@ def create_sub2(v):
g.db.flush()
mod = Mod(user_id=v.id, sub=sub.name)
g.db.add(mod)
g.db.commit()
return redirect(f'/h/{sub.name}')
@ -316,7 +306,6 @@ def kick(v, pid):
post.sub = None
g.db.add(post)
g.db.commit()
cache.delete_memoized(frontlist)
@ -351,7 +340,6 @@ def rehole_post(v, pid, hole):
g.db.add(ma)
on_post_hole_entered(post)
g.db.commit()
return {"message": f"Post moved to {sub_to_str}!"}
@ -397,7 +385,6 @@ def post_sub_sidebar(v, sub):
g.db.add(sub)
g.db.commit()
return redirect(f'/h/{sub.name}/settings')
@ -426,14 +413,13 @@ def post_sub_css(v, sub):
sub.css = css
g.db.add(sub)
g.db.commit()
return redirect(f'/h/{sub.name}/settings')
@app.get("/h/<sub>/css")
def get_sub_css(sub):
sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none()
sub = g.db.query(Sub.css).filter_by(name=sub.strip().lower()).one_or_none()
if not sub: abort(404)
resp=make_response(sub.css or "")
resp.headers.add("Content-Type", "text/css")
@ -464,7 +450,6 @@ def sub_banner(v, sub):
if path.isfile(fpath): os.remove(fpath)
sub.bannerurl = bannerurl
g.db.add(sub)
g.db.commit()
return redirect(f'/h/{sub.name}/settings')
@ -491,7 +476,6 @@ def sub_sidebar(v, sub):
if path.isfile(fpath): os.remove(fpath)
sub.sidebarurl = sidebarurl
g.db.add(sub)
g.db.commit()
return redirect(f'/h/{sub.name}/settings')
@ -538,5 +522,4 @@ def sub_inactive_purge_task():
for x in dead_holes:
g.db.delete(x)
g.db.commit()
return True

View File

@ -401,7 +401,6 @@ def suicide(v, username):
suicide = f"Hi there,\n\nA [concerned user](/id/{v.id}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\nIf you don't see a resource in your area above, the moderators keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow users care about you and there are people who want to help."
if not v.shadowbanned:
send_notification(user.id, suicide)
g.db.commit()
return {"message": "Help message sent!"}
@ -451,7 +450,6 @@ def transfer_coins(v, username):
g.db.add(receiver)
g.db.add(v)
g.db.commit()
return {"message": f"{amount-tax} coins transferred!"}, 200
@ -491,7 +489,6 @@ def transfer_bux(v, username):
g.db.add(receiver)
g.db.add(v)
g.db.commit()
return {"message": f"{amount} marseybux transferred!"}, 200
return {"message": "You can't transfer marseybux to yourself!"}, 400
@ -587,32 +584,28 @@ def leaderboard(v):
users13=users13_25, pos13=pos13, users14=users14, pos14=pos14, users15=users15, pos15=pos15,
usersBlk=usersBlk)
@app.get("/@<username>/css")
def get_css(username):
user = get_user(username)
resp = make_response(user.css or "")
@app.get("/<id>/css")
def get_css(id):
try: id = int(id)
except: abort(404)
css = g.db.query(User.css).filter_by(id=id).one_or_none()
if not css: abort(404)
resp = make_response(css[0] or "")
resp.headers["Content-Type"] = "text/css"
resp.headers["Referrer-Policy"] = "no-referrer"
return resp
@app.get("/@<username>/profilecss")
def get_profilecss(username):
user = get_user(username)
if user.profilecss: profilecss = user.profilecss
else: profilecss = ""
resp = make_response(profilecss)
resp.headers["Content-Type"] = "text/css"
resp.headers["Referrer-Policy"] = "no-referrer"
return resp
@app.get("/<id>/profilecss")
def get_profilecss(id):
try: id = int(id)
except: abort(404)
@app.get("/id/<id>/profilecss")
def get_profilecss_id(id):
user = get_account(id)
if user.profilecss: profilecss = user.profilecss
else: profilecss = ""
resp = make_response(profilecss)
css = g.db.query(User.profilecss).filter_by(id=id).one_or_none()
if not css: abort(404)
resp = make_response(css[0] or "")
resp.headers["Content-Type"] = "text/css"
resp.headers["Referrer-Policy"] = "no-referrer"
return resp
@app.get("/@<username>/song")
@ -636,7 +629,6 @@ def song(song):
def subscribe(v, post_id):
new_sub = Subscription(user_id=v.id, submission_id=post_id)
g.db.add(new_sub)
g.db.commit()
return {"message": "Post subscribed!"}
@app.post("/unsubscribe/<post_id>")
@ -647,7 +639,6 @@ def unsubscribe(v, post_id):
sub=g.db.query(Subscription).filter_by(user_id=v.id, submission_id=post_id).one_or_none()
if sub:
g.db.delete(sub)
g.db.commit()
return {"message": "Post unsubscribed!"}
@app.get("/report_bugs")
@ -709,7 +700,6 @@ def message2(v, username):
notif = Notification(comment_id=c.id, user_id=user.id)
g.db.add(notif)
g.db.commit()
if PUSHER_ID != 'blahblahblah' and not v.shadowbanned:
if len(message) > 500: notifbody = message[:500] + '...'
@ -817,7 +807,6 @@ def messagereply(v):
for n in notifications:
g.db.delete(n)
g.db.commit()
return {"comment": render_template("comments.html", v=v, comments=[c], ajax=True)}
@ -930,7 +919,6 @@ def u_username(username, v=None):
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
g.db.add(view)
g.db.commit()
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)):
@ -1122,7 +1110,6 @@ def follow_user(username, v):
if not v.shadowbanned:
send_notification(target.id, f"@{v.username} has followed you!")
g.db.commit()
return {"message": "User followed!"}
@ -1137,7 +1124,6 @@ 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!")
g.db.commit()
return {"error": "You can't unfollow this user!"}
follow = g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).one_or_none()
@ -1152,7 +1138,6 @@ def unfollow_user(username, v):
if not v.shadowbanned:
send_notification(target.id, f"@{v.username} has unfollowed you!")
g.db.commit()
return {"message": "User unfollowed!"}
@ -1175,7 +1160,6 @@ def remove_follow(username, v):
send_repeatable_notification(target.id, f"@{v.username} has removed your follow!")
g.db.commit()
return {"message": "Follower removed!"}
@ -1272,5 +1256,4 @@ def fp(v, fp):
g.db.flush()
print(v.username + ' + ' + u.username, flush=True)
g.db.add(v)
g.db.commit()
return '', 204

View File

@ -117,7 +117,6 @@ def api_vote_post(post_id, new, v):
post.realupvotes = g.db.query(Vote).filter_by(submission_id=post.id, real=True).count()
if post.author.progressivestack: post.realupvotes *= 2
g.db.add(post)
g.db.commit()
return "", 204
@app.post("/vote/comment/<comment_id>/<new>")
@ -194,7 +193,6 @@ def api_vote_comment(comment_id, new, v):
comment.realupvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, real=True).count()
if comment.author.progressivestack: comment.realupvotes *= 2
g.db.add(comment)
g.db.commit()
return "", 204
@ -226,7 +224,6 @@ def api_vote_poll(comment_id, v):
g.db.flush()
comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count()
g.db.add(comment)
g.db.commit()
return "", 204
@ -258,7 +255,6 @@ def bet(comment_id, v):
autobetter.coins += 200
g.db.add(autobetter)
g.db.commit()
return "", 204
@app.post("/vote/choice/<comment_id>")
@ -290,5 +286,4 @@ def api_vote_choice(comment_id, v):
g.db.flush()
comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count()
g.db.add(comment)
g.db.commit()
return "", 204

View File

@ -40,7 +40,7 @@
}
</style>
{% elif v.css %}
<link rel="stylesheet" href="/@{{v.username}}/css">
<link rel="stylesheet" href="/{{v.id}}/css">
{% endif %}
{% else %}
<style>:root{--primary:#{{DEFAULT_COLOR}}</style>

View File

@ -19,7 +19,7 @@
<link rel="stylesheet" href="{{asset('css/main.css')}}">
<link rel="stylesheet" href="{{asset('css/' + v.theme + '.css')}}">
{% if v.css %}
<link rel="stylesheet" href="/@{{v.username}}/css">
<link rel="stylesheet" href="/{{v.id}}/css">
{% endif %}
<style>

View File

@ -207,9 +207,7 @@
{% if c.author.verified %}<i class="fas fa-badge-check align-middle ml-1 {% if c.author.verified=='Glowiefied' %}glow{% endif %}" style="color:{% if c.author.verifiedcolor %}#{{c.author.verifiedcolor}}{% else %}#1DA1F2{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{c.author.verified}}"></i>
{% endif %}
{% if not c.author %}
{{c.print()}}
{% endif %}
<a class="user-name text-decoration-none" href="{{c.author.url}}" data-pop-info='{{c.author.json_popover(v) | tojson}}' onclick='popclick(event)' data-bs-placement="bottom" data-bs-toggle="popover" data-bs-trigger="click" data-content-id="popover" role="button" tabindex="0" style="color:#{{c.author.namecolor}}; font-size:12px; font-weight:bold;">
<img loading="lazy" src="{{c.author.profile_url}}" class="profile-pic-25 mr-2">
{% if c.author.is_cakeday %}
@ -877,7 +875,7 @@
lastCount = comments['{{p.id}}']
if (lastCount)
{
{% for c in p.comments %}
{% for c in p.replies %}
{% if not (v and v.id==c.author_id) and not c.voted %}
if ({{c.created_utc*1000}} > lastCount.t)
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
@ -908,7 +906,7 @@
lastCount = comments['{{p.id}}']
if (lastCount)
{
{% for c in p.comments %}
{% for c in p.replies %}
{% if not (v and v.id==c.author_id) and not c.voted %}
if ({{c.created_utc*1000}} > lastCount.t)
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}

View File

@ -47,7 +47,7 @@
}
</style>
{% elif v.css %}
<link rel="stylesheet" href="/@{{v.username}}/css">
<link rel="stylesheet" href="/{{v.id}}/css">
{% endif %}
{% else %}
<style>:root{--primary:#{{DEFAULT_COLOR}}</style>

View File

@ -27,7 +27,7 @@
}
</style>
{% elif v.css %}
<link rel="stylesheet" href="/@{{v.username}}/css">
<link rel="stylesheet" href="/{{v.id}}/css">
{% endif %}
{% else %}
<style>:root{--primary:#{{DEFAULT_COLOR}}</style>

View File

@ -56,7 +56,7 @@
}
</style>
{% elif v.css and not request.path.startswith('/settings/css') %}
<link rel="stylesheet" href="/@{{v.username}}/css">
<link rel="stylesheet" href="/{{v.id}}/css">
{% endif %}
</head>

View File

@ -732,10 +732,6 @@
{% if p.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
{% if p.active_flags(v) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags(v)}} Report{{ help.plural(p.active_flags(v)) }}</a>{% endif %}
{% if not p.author %}
{{p.print()}}
{% endif %}
{% if p.ghost %}
<span {% if p.distinguish_level %}class="mod"{% endif %}>👻</span>
@ -1127,7 +1123,7 @@
lastCount = comments['{{p.id}}']
if (lastCount)
{
{% for c in p.comments %}
{% for c in p.replies %}
{% if not (v and v.id==c.author_id) and not c.voted %}
if ({{c.created_utc*1000}} > lastCount.t)
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}

View File

@ -94,7 +94,7 @@
lastCount = comments['{{p.id}}']
if (lastCount)
{
{% for c in p.comments %}
{% for c in p.replies %}
{% if not (v and v.id==c.author_id) and not c.voted %}
if ({{c.created_utc*1000}} > lastCount.t)
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}

View File

@ -180,10 +180,6 @@
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
{% if p.active_flags(v) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags(v)}} Report{{ help.plural(p.active_flags(v)) }}</a>{% endif %}
{% if not p.author %}
{{p.print()}}
{% endif %}
{% if p.ghost %}
<span {% if p.distinguish_level %}class="mod"{% endif %}>👻</span>
{% else %}
@ -222,7 +218,7 @@
<div class="post-actions mt-2 d-none d-md-block">
<ul class="list-inline text-right d-flex">
{% if p.realbody(v) %}
{% if p.realbody(v, True) %}
<a class="list-inline-item" role="button" onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mr-0 text-expand-icon-{{p.id}}"></i></a>
{% endif %}
<li class="list-inline-item">
@ -254,7 +250,7 @@
</li>
{% if p.realbody(v) and request.path != "/changelog"%}
{% if p.realbody(v, True) and request.path != "/changelog"%}
<a class="list-inline-item" role="button" onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mr-0 text-expand-icon-{{p.id}}"></i></a>
{% endif %}
@ -336,9 +332,9 @@
{% if (not p.club or v and (v.paid_dues or v.id == p.author_id)) and not v_forbid_deleted %}
{% if p.realbody(v) %}
{% if p.realbody(v, True) %}
<div class="d-none card rounded border pt-3 pb-2 my-2 {% if p.author.agendaposter %}agendaposter{% endif %}" id="post-text-{{p.id}}">
{{p.realbody(v) | safe}}
{{p.realbody(v, True) | safe}}
</div>
{% endif %}

View File

@ -49,7 +49,7 @@
}
</style>
{% elif v.css %}
<link rel="stylesheet" href="/@{{v.username}}/css">
<link rel="stylesheet" href="/{{v.id}}/css">
{% endif %}
{% else %}
<style>:root{--primary:#{{DEFAULT_COLOR}}</style>

View File

@ -6,7 +6,7 @@
{% block title %}
{% if u and u.profilecss and not request.values.get('nocss') %}
<link rel="stylesheet" href="/@{{u.username}}/profilecss">
<link rel="stylesheet" href="/{{u.id}}/profilecss">
{% endif %}
<title>{{u.username}}'s profile - {{SITE_NAME}}</title>

View File

@ -1653,12 +1653,6 @@ Every slur for a gay man I can muster
Anal assassin anal astronaut Arse bandit Ass bandit Backgammon player Bear Bent bentshot bender Bone smuggler Brownie king brown piper Bufter bufty booty buffer Bugger Bum boy bum chum Bum robber Bum-driller Bumhole engineer Butt pirate butt boy butt rider butt pilot butt rustler Chi chi man Cockstruction worker Cockpipe cosmonaut Crafty butcher Daffodil daffy Donut puncher/muncher Faggot Fag Fairy Finocchio Flamer Flit Flower Friend of Dorothy Fruit fruit loop fruit packer Fudge packer Gaysian Gym Bunny Light in the loafers Light in the pants or Light in the fedora Limp wristed Meat Masseuse Muscle Mary Oklahomo Pansy Payaso Peterpuffer Bean queen Brownie queen Chicken queen Grey queen, Potato queen Rice queen Queer Ring raider Sissy Sod Twink woolie woofter poofter
{[para]}
Jesus Christ died for our sin if we turn from sin we'll be saved
The 10 Commandments
I am the Lord your God: you shall have no other gods but me. You shall not make for yourself any idol. You shall not dishonour the name of the Lord your God. Remember the Sabbath and keep it holy. Honour your father and mother. You shall not commit murder. You shall not commit adultery. You shall not steal. You shall not be a false witness. You shall not covet anything which belongs to your neighbour
{[para]}
My dudes. Everyone talks about it, everyone makes memes about their 13.6 TB of hentai and stuff. But imo I just cant get off to it anymore at all. I legit set a timer to see when I nut (dont judge or ask) to prove its no longer doing it for me. It came to around like 30 seconds or soemthing. And I didnt even but. I got too tired and bored. They are actually quite annoying too. Like how does this girl whos getting screwed somehow yelling all this word vomit. “Oh my gosh its inside me, oh my gosh its so big waaaaaa” everyone has their preferences. But me personally its just not very good anymore, dont get me wrong theres some good ones out there, but Ive come to the point where I havent wanted to hentai in around 9 minutes. So yeah.
{[para]}
If you or someone you know is contemplating suicide, please reach out. You can find help at a National Suicide Prevention Lifeline