remotes/1693045480750635534/spooky-22
Aevann1 2021-11-16 01:13:29 +02:00
parent 27a88357eb
commit 1f28d5b81d
7 changed files with 77 additions and 29 deletions

View File

@ -212,10 +212,10 @@ class Comment(Base):
@property
@lazy
def permalink(self):
if self.post and self.post.club: return f"/comment/{self.id}/"
if self.post and self.post.club: return f"/comment/{self.id}?context=9#context"
if self.post: return f"{self.post.permalink}/{self.id}/"
else: return f"/comment/{self.id}/"
if self.post: return f"{self.post.permalink}/{self.id}?context=9#context"
else: return f"/comment/{self.id}?context=9#context"
@property
@lazy

View File

@ -993,9 +993,18 @@ def api_sticky_post(post_id, v):
cache.delete_memoized(frontlist)
g.db.commit()
if post.stickied: return {"message": "Post pinned!"}
else: return {"message": "Post unpinned!"}
if post.stickied:
message = f"@{v.username} has pinned your [post](/post/{post_id})!"
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
if not existing: send_notification(post.author_id, message)
g.db.commit()
return {"message": "Post pinned!"}
else:
message = f"@{v.username} has unpinned your [post](/post/{post_id})!"
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
if not existing: send_notification(post.author_id, message)
g.db.commit()
return {"message": "Post unpinned!"}
@app.post("/ban_comment/<c_id>")
@limiter.limit("1/second")

View File

@ -861,8 +861,18 @@ def toggle_pin_comment(cid, v):
g.db.commit()
if comment.is_pinned: return {"message": "Comment pinned!"}
else: return {"message": "Comment unpinned!"}
if comment.is_pinned:
message = f"@{v.username} has pinned your [comment]({comment.permalink})!"
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
if not existing: send_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment pinned!"}
else:
message = f"@{v.username} has unpinned your [comment]({comment.permalink})!"
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
if not existing: send_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment unpinned!"}
@app.post("/save_comment/<cid>")
@ -879,10 +889,6 @@ def save_comment(cid, v):
new_save=SaveRelationship(user_id=v.id, comment_id=comment.id, type=2)
g.db.add(new_save)
# message = f"@{v.username} has saved your [comment](/comment/{cid})!"
# existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
# if not existing: send_notification(comment.author_id, message)
try: g.db.commit()
except: g.db.rollback()
@ -900,11 +906,6 @@ def unsave_comment(cid, v):
if save:
g.db.delete(save)
# message = f"@{v.username} has unsaved your [comment](/comment/{cid})!"
# existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
# if not existing: send_notification(comment.author_id, message)
g.db.commit()
return {"message": "Comment unsaved!"}

View File

@ -34,7 +34,7 @@ def upvoters(v, username):
users = sorted(users2, key=lambda x: x[1], reverse=True)[:25]
return render_template("upvoters.html", v=v, users=users, username=username, name='Up', name2='simps')
return render_template("voters.html", v=v, users=users, username=username, name='Up', name2='@{v.username} biggest simps')
@app.get("/@<username>/downvoters")
@auth_desired
@ -53,7 +53,45 @@ def downvoters(v, username):
users = sorted(users2, key=lambda x: x[1], reverse=True)[:25]
return render_template("upvoters.html", v=v, users=users, username=username, name='Down', name2='haters')
return render_template("voters.html", v=v, users=users, username=username, name='Down', name2='@{v.username} biggest haters')
@app.get("/@<username>/upvoting")
@auth_desired
def upvoting(v, username):
id = get_user(username).id
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).limit(25).all()
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).limit(25).all()
votes = Counter(dict(votes)) + Counter(dict(votes2))
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
users2 = []
for user in users: users2.append((user, votes[user.id]))
users = sorted(users2, key=lambda x: x[1], reverse=True)[:25]
return render_template("voters.html", v=v, users=users, username=username, name='Up', name2=f'Who @{v.username} simps for')
@app.get("/@<username>/downvoting")
@auth_desired
def downvoting(v, username):
id = get_user(username).id
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).limit(25).all()
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).limit(25).all()
votes = Counter(dict(votes)) + Counter(dict(votes2))
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
users2 = []
for user in users: users2.append((user, votes[user.id]))
users = sorted(users2, key=lambda x: x[1], reverse=True)[:25]
return render_template("voters.html", v=v, users=users, username=username, name='Down', name2=f'Who @{v.username} hates')
@app.post("/pay_rent")
@limiter.limit("1/second")

View File

@ -215,11 +215,11 @@
{% endfor %}
</div>
<div id="morecomment-{{c.id}}" class="d-md-none mt-2 more-comments text-small">
<a {% if v %}href="{{c.permalink}}?context=9#context"{% else %}href="/logged_out{{c.permalink}}?context=9#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
<a {% if v %}href="{{c.permalink}}"{% else %}href="/logged_out{{c.permalink}}"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
</div>
{% elif replies %}
<div id="morecomment-{{c.id}}" class="mt-2 more-comments text-small">
<a {% if v %}href="{{c.permalink}}?context=9#context"{% else %}href="/logged_out{{c.permalink}}?context=9#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
<a {% if v %}href="{{c.permalink}}"{% else %}href="/logged_out{{c.permalink}}"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
</div>
{% endif %}
{% endif %}
@ -443,8 +443,8 @@
<a class="list-inline-item text-muted" href="javascript:void(0)" onclick="openReplyBox('{{c.id}}')"><i class="fas fa-reply" aria-hidden="true"></i><span class="d-none d-md-inline-block">Reply</span></a>
{% endif %}
<a class="list-inline-item text-muted d-none d-md-inline-block" {% if v %}href="{{c.permalink}}?context=9#context"{% else %}href="/logged_out{{c.permalink}}?context=9#context"{% endif %}><i class="fas fa-book-open"></i>Context</a>
<a class="list-inline-item text-muted d-none d-md-inline-block copy-link" href="javascript:void(0);" role="button" data-clipboard-text="{% if 'rama' in request.host %}https://freeghettohoes.biz{{c.permalink}}{% else %}{{c.permalink | full_link}}{% endif %}?context=9#context"><i class="fas fa-copy"></i>Copy link</a>
<a class="list-inline-item text-muted d-none d-md-inline-block" {% if v %}href="{{c.permalink}}"{% else %}href="/logged_out{{c.permalink}}"{% endif %}><i class="fas fa-book-open"></i>Context</a>
<a class="list-inline-item text-muted d-none d-md-inline-block copy-link" href="javascript:void(0);" role="button" data-clipboard-text="{% if 'rama' in request.host %}https://freeghettohoes.biz{{c.permalink}}{% else %}{{c.permalink | full_link}}{% endif %}"><i class="fas fa-copy"></i>Copy link</a>
{% if v %}
<a class="list-inline-item text-muted d-none d-md-inline-block" href="javascript:void(0)" data-bs-toggle="modal" data-bs-target="#reportCommentModal" onclick="report_commentModal('{{c.id}}','{{c.author.username}}',)"><i class="fas fa-flag fa-fw"></i>Report</a>
{% endif %}
@ -575,7 +575,7 @@
{% endfor %}
</div>
<div id="morecomment-{{c.id}}" class="d-md-none mt-2 more-comments text-small">
<a {% if v %}href="{{c.permalink}}?context=9#context"{% else %}href="/logged_out{{c.permalink}}?context=9#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
<a {% if v %}href="{{c.permalink}}"{% else %}href="/logged_out{{c.permalink}}"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
</div>
{% elif replies %}
<div id="morecomment-{{c.id}}" class="mt-2 more-comments text-small">
@ -608,9 +608,9 @@
<a id="unsave2-{{c.id}}" class="list-group-item {% if c.id not in v.saved_comment_idlist() %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast2('/unsave_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-save"></i>Unsave</a>
{% endif %}
<a href="javascript:void(0);" role="button" class="list-group-item copy-link" data-bs-dismiss="modal" data-clipboard-text="{% if 'rama' in request.host %}https://freeghettohoes.biz{{c.permalink}}{% else %}{{c.permalink | full_link}}{% endif %}?context=9#context"><i class="fas fa-copy"></i>Copy link</a>
<a href="javascript:void(0);" role="button" class="list-group-item copy-link" data-bs-dismiss="modal" data-clipboard-text="{% if 'rama' in request.host %}https://freeghettohoes.biz{{c.permalink}}{% else %}{{c.permalink | full_link}}{% endif %}"><i class="fas fa-copy"></i>Copy link</a>
<a class="list-group-item" {% if v %} href="{{c.permalink}}?context=9#context" {% else %} href="/logged_out{{c.permalink}}?context=9#context" {% endif %}><i class="fas fa-dna"></i>Context</a>
<a class="list-group-item" {% if v %} href="{{c.permalink}}" {% else %} href="/logged_out{{c.permalink}}" {% endif %}><i class="fas fa-dna"></i>Context</a>
<a href="javascript:void(0)" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#reportCommentModal" onclick="report_commentModal('{{c.id}}','{{c.author.username}}')" class="list-group-item"><i class="fas fa-flag"></i>Report</a>

View File

@ -159,7 +159,7 @@
{% else %}<pre></pre>
{% endif %}
<div class="font-weight-bolder mb-2"><a class="mr-1" href="/@{{u.username}}/upvoters">Simps</a> | <a class="ml-1" href="/@{{u.username}}/downvoters">Haters</a></div>
<div class="font-weight-bolder mb-2"><a class="mr-1" href="/@{{u.username}}/upvoters">Simps</a> | <a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> | <a class="mx-1" href="/@{{u.username}}/upvoting">Simps for</a> | <a class="ml-1" href="/@{{u.username}}/downvoting">Hates</a></div>
<div class="font-weight-bolder">
<span id="profile-coins-amount">{{u.coins}}</span>
@ -441,7 +441,7 @@
<pre></pre>
{% endif %}
<div class="font-weight-bolder mb-2"><a class="mr-1" href="/@{{u.username}}/upvoters">Simps</a> | <a class="ml-1" href="/@{{u.username}}/downvoters">Haters</a></div>
<div class="font-weight-bolder mb-2"><a class="mr-1" href="/@{{u.username}}/upvoters">Simps</a> | <a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> | <a class="mx-1" href="/@{{u.username}}/upvoting">Simps for</a> | <a class="ml-1" href="/@{{u.username}}/downvoting">Hates</a></div>
<div class="font-weight-normal">
<span id="profile-coins-amount-mobile" class="font-weight-bold">{{u.coins}}</span>

View File

@ -4,7 +4,7 @@
</pre>
<h5 style="text-align: center">@{{username}}'s biggest {{name2}}</h5>
<h5 style="text-align: center">{{name2}}</h5>
<pre></pre>
<table class="table table-striped mb-5">
<thead class="bg-primary text-white">