diff --git a/files/assets/js/comments+submission_listing.js b/files/assets/js/comments+submission_listing.js
index 5cd9446fd..684fc201d 100644
--- a/files/assets/js/comments+submission_listing.js
+++ b/files/assets/js/comments+submission_listing.js
@@ -149,52 +149,6 @@ function post(url) {
xhr.send(form);
};
-function poll_vote(cid, parentid) {
- for(let el of document.getElementsByClassName('presult-'+parentid)) {
- el.classList.remove('d-none');
- }
- var type = document.getElementById(cid).checked;
- var scoretext = document.getElementById('poll-' + cid);
- var score = Number(scoretext.textContent);
- if (type == true) scoretext.textContent = score + 1;
- else scoretext.textContent = score - 1;
- post('/vote/poll/' + cid + '?vote=' + type);
-}
-
-function choice_vote(cid, parentid) {
- for(let el of document.getElementsByClassName('presult-'+parentid)) {
- el.classList.remove('d-none');
- }
-
- let curr = document.getElementById(`current-${parentid}`)
- if (curr && curr.value)
- {
- var scoretext = document.getElementById('choice-' + curr.value);
- var score = Number(scoretext.textContent);
- scoretext.textContent = score - 1;
- }
-
- var scoretext = document.getElementById('choice-' + cid);
- var score = Number(scoretext.textContent);
- scoretext.textContent = score + 1;
- post('/vote/choice/' + cid);
- curr.value = cid
-}
-
-function bet_vote(cid) {
- for(let el of document.getElementsByClassName('bet')) {
- el.disabled = true;
- }
- for(let el of document.getElementsByClassName('cost')) {
- el.classList.add('d-none')
- }
- var scoretext = document.getElementById('bet-' + cid);
- var score = Number(scoretext.textContent);
- scoretext.textContent = score + 1;
- post('/bet/' + cid);
- document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200;
-}
-
function vote(type, id, dir, vid) {
const upvotes = document.getElementsByClassName(type + '-' + id + '-up');
const downvotes = document.getElementsByClassName(type + '-' + id + '-down');
diff --git a/files/assets/js/comments.js b/files/assets/js/comments.js
index ee05b4e7d..e518b4090 100644
--- a/files/assets/js/comments.js
+++ b/files/assets/js/comments.js
@@ -12,11 +12,6 @@ function collapse_comment(id, element) {
if (flags) flags.classList.add('d-none')
};
-function poll_vote_no_v() {
- document.getElementById('toast-post-error-text').innerText = "Only logged-in users can vote!";
- bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show();
-}
-
function expandMarkdown(t,id) {
let ta = document.getElementById('markdown-'+id);
ta.classList.toggle('d-none');
diff --git a/files/classes/comment.py b/files/classes/comment.py
index 6e29b7a41..ea3e7a4bd 100644
--- a/files/classes/comment.py
+++ b/files/classes/comment.py
@@ -90,38 +90,6 @@ class Comment(Base):
flags.remove(flag)
return flags
- @lazy
- def poll_voted(self, v):
- if v:
- vote = g.db.query(CommentVote.vote_type).filter_by(user_id=v.id, comment_id=self.id).one_or_none()
- if vote: return vote[0]
- return None
-
- @property
- @lazy
- def options(self):
- li = [x for x in self.child_comments if x.author_id == AUTOPOLLER_ID]
- return sorted(li, key=lambda x: x.id)
-
-
- @property
- @lazy
- def choices(self):
- li = [x for x in self.child_comments if x.author_id == AUTOCHOICE_ID]
- return sorted(li, key=lambda x: x.id)
-
-
- def total_poll_voted(self, v):
- if v:
- for option in self.options:
- if option.poll_voted(v): return True
- return False
-
- 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 False
-
@property
@lazy
def controversial(self):
@@ -240,8 +208,7 @@ class Comment(Base):
return sorted((x for x in self.child_comments
if x.author
and not x.author.shadowbanned
- and (x.filter_state not in ('filtered', 'removed') or x.author_id == author_id)
- and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)),
+ and (x.filter_state not in ('filtered', 'removed') or x.author_id == author_id)),
key=lambda x: x.realupvotes, reverse=True)
@property
@@ -249,9 +216,7 @@ class Comment(Base):
if self.replies2 != None: return self.replies2
if not self.parent_submission:
return sorted(self.child_comments, key=lambda x: x.created_utc)
- return sorted((x for x in self.child_comments
- if x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)),
- key=lambda x: x.realupvotes, reverse=True)
+ return sorted(self.child_comments, key=lambda x: x.realupvotes, reverse=True)
@property
def replies2(self):
@@ -403,27 +368,6 @@ class Comment(Base):
g.db.add(self)
g.db.commit()
- for c in self.options:
- body += f'
'
-
- curr = self.total_choice_voted(v)
- if curr: curr = " value=" + str(curr[0].comment_id)
- else: curr = ''
- body += f''
-
- for c in self.choices:
- body += f''''
-
if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))):
body += f"
{self.author.sig_html}"
diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py
index f22dfcb27..a9e1d9db9 100644
--- a/files/classes/mod_logs.py
+++ b/files/classes/mod_logs.py
@@ -224,11 +224,6 @@ ACTIONTYPES = {
"icon": 'fa-crown',
"color": 'bg-success'
},
- 'distribute': {
- "str": 'distributed bet winnings to voters on {self.target_link}',
- "icon": 'fa-dollar-sign',
- "color": 'bg-success'
- },
'dump_cache': {
"str": 'dumped cache',
"icon": 'fa-trash-alt',
diff --git a/files/classes/submission.py b/files/classes/submission.py
index d5bd4e69b..5fb387339 100644
--- a/files/classes/submission.py
+++ b/files/classes/submission.py
@@ -98,41 +98,6 @@ class Submission(Base):
if flag.user.shadowbanned:
flags.remove(flag)
return flags
-
- @property
- @lazy
- def options(self):
- return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOPOLLER_ID, level=1).order_by(Comment.id).all()
-
-
- @property
- @lazy
- def choices(self):
- return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOCHOICE_ID, level=1).order_by(Comment.id).all()
-
-
- @property
- @lazy
- def bet_options(self):
- return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOBETTER_ID, level=1).all()
-
- def total_poll_voted(self, v):
- if v:
- for option in self.options:
- if option.poll_voted(v): return True
- return False
-
- 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 False
-
- def total_bet_voted(self, v):
- if "closed" in self.body.lower(): return True
- if v:
- for option in self.bet_options:
- if option.poll_voted(v): return True
- return False
@property
@lazy
@@ -405,41 +370,6 @@ class Submission(Base):
g.db.add(self)
g.db.commit()
- for c in self.options:
- body += f''
-
- if self.choices:
- curr = self.total_choice_voted(v)
- if curr: curr = " value=" + str(curr[0].comment_id)
- else: curr = ''
- body += f''
-
- for c in self.choices:
- body += f''''
-
- for c in self.bet_options:
- body += f''' 200) or self.total_bet_voted(v): body += " disabled "
- body += f'''>
"
- if v and v.admin_level > 2:
- body += f'''
'''
- body += "
"
-
-
if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))):
body += f"
{self.author.sig_html}"
diff --git a/files/helpers/const.py b/files/helpers/const.py
index 7878132f2..cbca4712a 100644
--- a/files/helpers/const.py
+++ b/files/helpers/const.py
@@ -493,10 +493,6 @@ valid_sub_regex = re.compile("^[a-zA-Z0-9_\-]{3,20}$", flags=re.A)
query_regex = re.compile("(\w+):(\S+)", flags=re.A)
-poll_regex = re.compile("\s*\$\$([^\$\n]+)\$\$\s*", flags=re.A)
-bet_regex = re.compile("\s*\$\$\$([^\$\n]+)\$\$\$\s*", flags=re.A)
-choice_regex = re.compile("\s*&&([^\$\n]+)&&\s*", flags=re.A)
-
title_regex = re.compile("[^\w ]", flags=re.A)
based_regex = re.compile("based and (.{1,20}?)(-| )pilled", flags=re.I|re.A)
diff --git a/files/routes/admin.py b/files/routes/admin.py
index b0ed86d51..b29495706 100644
--- a/files/routes/admin.py
+++ b/files/routes/admin.py
@@ -166,54 +166,6 @@ def remove_admin(v, username):
g.db.commit()
return {"message": "Admin removed!"}
-@app.post("/distribute/")
-@limiter.limit("1/second;30/minute;200/hour;1000/day")
-@admin_level_required(3)
-def distribute(v, comment):
- autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).one_or_none()
- if autobetter.coins == 0: return {"error": "@AutoBetter has 0 coins"}
-
- try: comment = int(comment)
- except: abort(400)
- post = g.db.query(Comment.parent_submission).filter_by(id=comment).one_or_none()[0]
- post = g.db.query(Submission).filter_by(id=post).one_or_none()
-
- pool = 0
- for option in post.bet_options: pool += option.upvotes
- pool *= 200
-
- autobetter.coins -= pool
- if autobetter.coins < 0: autobetter.coins = 0
- g.db.add(autobetter)
-
- votes = g.db.query(CommentVote).filter_by(comment_id=comment)
- coinsperperson = int(pool / votes.count())
-
- cid = notif_comment(f"You won {coinsperperson} coins betting on [{post.title}]({post.shortlink}) :marseyparty:")
- for vote in votes:
- u = vote.user
- u.coins += coinsperperson
- add_notif(cid, u.id)
-
- cid = notif_comment(f"You lost the 200 coins you bet on [{post.title}]({post.shortlink}) :marseylaugh:")
- cids = [x.id for x in post.bet_options]
- cids.remove(comment)
- votes = g.db.query(CommentVote).filter(CommentVote.comment_id.in_(cids)).all()
- for vote in votes: add_notif(cid, vote.user.id)
-
- post.body += '\n\nclosed'
- g.db.add(post)
-
- ma = ModAction(
- kind="distribute",
- user_id=v.id,
- target_comment_id=comment
- )
- g.db.add(ma)
-
- g.db.commit()
- return {"message": f"Each winner has received {coinsperperson} coins!"}
-
@app.post("/@/delete_note/")
@admin_level_required(3)
def delete_note(v,username,id):
diff --git a/files/routes/comments.py b/files/routes/comments.py
index 024aef328..19675bc61 100644
--- a/files/routes/comments.py
+++ b/files/routes/comments.py
@@ -123,8 +123,7 @@ 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.parent_submission == post.id
).join(
votes,
votes.c.comment_id == Comment.id,
@@ -340,7 +339,7 @@ def api_comment(v):
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0])
- if parent.author.id not in (v.id, BASEDBOT_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, AUTOPOLLER_ID, AUTOCHOICE_ID):
+ if parent.author.id not in (v.id, BASEDBOT_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID):
notify_users.add(parent.author.id)
for x in notify_users:
diff --git a/files/routes/posts.py b/files/routes/posts.py
index abca2a506..f99b51512 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -172,7 +172,7 @@ def post_id(pid, anything=None, v=None, sub=None):
filter_clause = filter_clause | (Comment.author_id == v.id)
comments = comments.filter(filter_clause)
- 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).join(
votes,
votes.c.comment_id == Comment.id,
isouter=True
@@ -215,7 +215,7 @@ def post_id(pid, anything=None, v=None, sub=None):
else:
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != 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.is_pinned == None)
+ comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.level == 1, Comment.is_pinned == None)
if sort == "new":
comments = comments.order_by(Comment.created_utc.desc())
@@ -298,7 +298,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.is_pinned == None, Comment.id.notin_(ids))
+ ).filter(Comment.parent_submission == pid, Comment.is_pinned == 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)
@@ -348,7 +348,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.is_pinned == 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.level == 1, Comment.is_pinned == None, Comment.id.notin_(ids))
if sort == "new":
comments = comments.order_by(Comment.created_utc.desc())
@@ -894,22 +894,6 @@ def submit_post(v, sub=None):
g.db.add(ma)
return redirect("/notifications")
- if v and v.admin_level > 2:
- bet_options = []
- for i in bet_regex.finditer(body):
- bet_options.append(i.group(1))
- body = body.replace(i.group(0), "")
-
- options = []
- for i in poll_regex.finditer(body):
- options.append(i.group(1))
- body = body.replace(i.group(0), "")
-
- choices = []
- for i in choice_regex.finditer(body):
- choices.append(i.group(1))
- body = body.replace(i.group(0), "")
-
if request.files.get("file2") and request.headers.get("cf-ipcountry") != "T1":
files = request.files.getlist('file2')[:4]
for file in files:
diff --git a/files/routes/votes.py b/files/routes/votes.py
index 4f728614f..87323cde8 100644
--- a/files/routes/votes.py
+++ b/files/routes/votes.py
@@ -69,9 +69,6 @@ def api_vote_post(post_id, new, v):
except: abort(404)
post = get_post(post_id)
- # verify that the post is allowed to be voted on
- if post.author_id in {AUTOPOLLER_ID,AUTOBETTER_ID,AUTOCHOICE_ID}: return {"error": "forbidden."}, 403
-
# get the old vote, if we have one
vote = g.db.query(Vote).filter_by(user_id=v.id, submission_id=post.id).one_or_none()
@@ -142,9 +139,6 @@ def api_vote_comment(comment_id, new, v):
except: abort(404)
comment = get_comment(comment_id)
- # verify that the comment is allowed to be voted on
- if comment.author.id in {AUTOPOLLER_ID,AUTOBETTER_ID,AUTOCHOICE_ID}: return {"error": "forbidden."}, 403
-
# get the old vote, if we have one
vote = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
@@ -196,97 +190,3 @@ def api_vote_comment(comment_id, new, v):
g.db.add(comment)
g.db.commit()
return "", 204
-
-
-@app.post("/vote/poll/")
-@is_not_permabanned
-def api_vote_poll(comment_id, v):
-
- vote = request.values.get("vote")
- if vote == "true": new = 1
- elif vote == "false": new = 0
- else: abort(400)
-
- comment_id = int(comment_id)
- comment = get_comment(comment_id)
-
- existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
-
- if existing and existing.vote_type == new: return "", 204
-
- if existing:
- if new == 1:
- existing.vote_type = new
- g.db.add(existing)
- else: g.db.delete(existing)
- elif new == 1:
- vote = CommentVote(user_id=v.id, vote_type=new, comment_id=comment.id)
- g.db.add(vote)
-
- g.db.flush()
- comment.upvotes = g.db.query(CommentVote.comment_id).filter_by(comment_id=comment.id, vote_type=1).count()
- g.db.add(comment)
- g.db.commit()
- return "", 204
-
-
-@app.post("/bet/")
-@limiter.limit("1/second;30/minute;200/hour;1000/day")
-@is_not_permabanned
-def bet(comment_id, v):
-
- if v.coins < 200: return {"error": "You don't have 200 coins!"}
-
- vote = request.values.get("vote")
- comment_id = int(comment_id)
- comment = get_comment(comment_id)
-
- existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
- if existing: return "", 204
-
- vote = CommentVote(user_id=v.id, vote_type=1, comment_id=comment.id)
- g.db.add(vote)
-
- comment.upvotes += 1
- g.db.add(comment)
-
- v.coins -= 200
- g.db.add(v)
- autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).one_or_none()
- autobetter.coins += 200
- g.db.add(autobetter)
-
- g.db.commit()
- return "", 204
-
-@app.post("/vote/choice/")
-@is_not_permabanned
-def api_vote_choice(comment_id, v):
-
- comment_id = int(comment_id)
- comment = get_comment(comment_id)
-
- existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
-
- if existing and existing.vote_type == 1: return "", 204
-
- if existing:
- existing.vote_type = 1
- g.db.add(existing)
- else:
- vote = CommentVote(user_id=v.id, vote_type=1, comment_id=comment.id)
- g.db.add(vote)
-
- if comment.parent_comment: parent = comment.parent_comment
- else: parent = comment.post
-
- for vote in parent.total_choice_voted(v):
- vote.comment.upvotes = g.db.query(CommentVote.comment_id).filter_by(comment_id=vote.comment.id, vote_type=1).count() - 1
- g.db.add(vote.comment)
- g.db.delete(vote)
-
- g.db.flush()
- comment.upvotes = g.db.query(CommentVote.comment_id).filter_by(comment_id=comment.id, vote_type=1).count()
- g.db.add(comment)
- g.db.commit()
- return "", 204