master
Aevann1 2022-02-24 15:20:48 +02:00
parent e577154752
commit 4f7d207260
8 changed files with 34 additions and 40 deletions

View File

@ -224,17 +224,17 @@ class Comment(Base):
@property
@lazy
def shortlink(self):
return f"{self.post.permalink}/{self.id}#context"
@property
@lazy
def sl(self):
return f"{self.post.shortlink}/{self.id}?context=8#context"
@property
@lazy
def permalink(self):
return f"{SITE_FULL}{self.sl}"
return f"{SITE_FULL}{self.shortlink}"
@property
@lazy
def morecomments(self):
return f"{self.post.permalink}/{self.id}#context"
@property
@lazy

View File

@ -208,16 +208,10 @@ class Submission(Base):
@property
@lazy
def sl(self):
def shortlink(self):
link = f"/post/{self.id}"
if self.sub: link = f"/s/{self.sub}{link}"
return link
@property
@lazy
def shortlink(self):
link = self.sl
if self.club: return link
output = self.title.lower()

View File

@ -119,13 +119,13 @@ def distribute(v, comment):
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.sl}) :marseyparty:")
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.sl}) :marseylaugh:")
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()
@ -1296,7 +1296,7 @@ def sticky_comment(cid, v):
g.db.add(ma)
if v.id != comment.author_id:
message = f"@{v.username} has pinned your [comment]({comment.sl})!"
message = f"@{v.username} has pinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
@ -1323,7 +1323,7 @@ def unsticky_comment(cid, v):
g.db.add(ma)
if v.id != comment.author_id:
message = f"@{v.username} has unpinned your [comment]({comment.sl})!"
message = f"@{v.username} has unpinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()

View File

@ -228,7 +228,7 @@ def award_post(pid, v):
author = post.author
if v.id != author.id:
msg = f"@{v.username} has given your [post]({post.sl}) the {AWARDS[kind]['title']} Award!"
msg = f"@{v.username} has given your [post]({post.shortlink}) the {AWARDS[kind]['title']} Award!"
if note: msg += f"\n\n> {note}"
send_repeatable_notification(author.id, msg)
@ -236,7 +236,7 @@ def award_post(pid, v):
return {"error": "You can't use this award on yourself."}, 400
if kind == "ban":
link = f"[this post]({post.sl})"
link = f"[this post]({post.shortlink})"
if not author.is_suspended:
author.ban(reason=f"1-Day ban award used by @{v.username} on /post/{post.id}", days=1)
@ -259,7 +259,7 @@ def award_post(pid, v):
author.is_banned = AUTOJANNY_ID
author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}"
author.unban_utc = int(time.time()) + 30 * 86400
link = f"[this post]({post.sl})"
link = f"[this post]({post.shortlink})"
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
elif kind == "pin":
if post.stickied and post.stickied_utc:
@ -461,7 +461,7 @@ def award_comment(cid, v):
author = c.author
if v.id != author.id:
msg = f"@{v.username} has given your [comment]({c.sl}) the {AWARDS[kind]['title']} Award!"
msg = f"@{v.username} has given your [comment]({c.shortlink}) the {AWARDS[kind]['title']} Award!"
if note: msg += f"\n\n> {note}"
send_repeatable_notification(author.id, msg)
@ -469,7 +469,7 @@ def award_comment(cid, v):
return {"error": "You can't use this award on yourself."}, 400
if kind == "ban":
link = f"[this comment]({c.sl})"
link = f"[this comment]({c.shortlink})"
if not author.is_suspended:
author.ban(reason=f"1-Day ban award used by @{v.username} on /comment/{c.id}", days=1)
@ -492,7 +492,7 @@ def award_comment(cid, v):
author.is_banned = AUTOJANNY_ID
author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}"
author.unban_utc = int(time.time()) + 30 * 86400
link = f"[this comment]({c.sl})"
link = f"[this comment]({c.shortlink})"
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
elif kind == "pin":
if c.is_pinned and c.is_pinned_utc: c.is_pinned_utc += 3600

View File

@ -956,8 +956,8 @@ def pin_comment(cid, v):
g.db.add(comment)
if v.id != comment.author_id:
if comment.post.ghost: message = f"OP has pinned your [comment]({comment.sl})!"
else: message = f"@{v.username} (OP) has pinned your [comment]({comment.sl})!"
if comment.post.ghost: message = f"OP has pinned your [comment]({comment.shortlink})!"
else: message = f"@{v.username} (OP) has pinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
@ -980,7 +980,7 @@ def unpin_comment(cid, v):
g.db.add(comment)
if v.id != comment.author_id:
message = f"@{v.username} (OP) has unpinned your [comment]({comment.sl})!"
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!"}
@ -1000,7 +1000,7 @@ def mod_pin(cid, v):
g.db.add(comment)
if v.id != comment.author_id:
message = f"@{v.username} (Mod) has pinned your [comment]({comment.sl})!"
message = f"@{v.username} (Mod) has pinned your [comment]({comment.shortlink})!"
send_repeatable_notification(comment.author_id, message)
g.db.commit()
@ -1020,7 +1020,7 @@ def mod_unpin(cid, v):
g.db.add(comment)
if v.id != comment.author_id:
message = f"@{v.username} (Mod) has unpinned your [comment]({comment.sl})!"
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!"}

View File

@ -99,14 +99,14 @@ def publish(pid, v):
if not post.ghost:
notify_users = NOTIFY_USERS(post.body_html, v) | NOTIFY_USERS2(post.title, v)
text = f"@{v.username} has mentioned you: [{post.title}]({post.sl})"
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
cid = notif_comment(text)
for x in notify_users:
add_notif(cid, x)
text = f"@{v.username} has made a new post: [{post.title}]({post.sl})"
text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
cid = notif_comment(text, autojanny=True)
@ -610,7 +610,7 @@ def edit_post(pid, v):
if not p.private and not p.ghost:
notify_users = NOTIFY_USERS(body_html, v) | NOTIFY_USERS2(title, v)
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.sl})")
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.shortlink})")
for x in notify_users:
add_notif(cid, x)
@ -1219,14 +1219,14 @@ def submit_post(v, sub=None):
notify_users = NOTIFY_USERS(body_html, v) | NOTIFY_USERS2(title, v)
text = f"@{v.username} has mentioned you: [{post.title}]({post.sl})"
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
cid = notif_comment(text)
for x in notify_users:
add_notif(cid, x)
text = f"@{v.username} has made a new post: [{post.title}]({post.sl})"
text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
cid = notif_comment(text, autojanny=True)

View File

@ -29,7 +29,7 @@ def exile_post(v, pid):
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
g.db.add(exile)
send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{p.title}]({p.sl})")
send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{p.title}]({p.shortlink})")
g.db.commit()
@ -82,7 +82,7 @@ def exile_comment(v, cid):
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
g.db.add(exile)
send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{c.permalink}]({c.sl})")
send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{c.permalink}]({c.shortlink})")
g.db.commit()

View File

@ -93,12 +93,12 @@
{% endfor %}
</div>
<div id="morecomment-{{c.id}}" class="d-md-none mt-2 more-comments">
<a href="{{c.shortlink}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
<a href="{{c.morecomments}}">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">
<button id="btn-{{c.id}}" class="d-none d-md-block btn btn-primary" onclick="morecomments('{{c.id}}')">More comments</button>
<a class="d-md-none" href="{{c.shortlink}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
<a class="d-md-none" href="{{c.morecomments}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
</div>
{% endif %}
{% endif %}
@ -466,7 +466,7 @@
<a class="btn caction nobackground px-1 text-muted" href="{{c.permalink}}"><i class="fas fa-book-open"></i>Context</a>
<button class="btn caction py-0 nobackground px-1 text-muted copy-link" data-clipboard-text="{% if request.host == 'rdrama.net' %}https://rdrama.gay{{c.sl}}{% else %}{{c.permalink}}{% endif %}"><i class="fas fa-copy"></i>Copy link</button>
<button class="btn caction py-0 nobackground px-1 text-muted copy-link" data-clipboard-text="{% if request.host == 'rdrama.net' %}https://rdrama.gay{{c.shortlink}}{% else %}{{c.permalink}}{% endif %}"><i class="fas fa-copy"></i>Copy link</button>
{% if v %}
<button class="btn caction py-0 nobackground px-1 text-muted" role="button" onclick="openReplyBox('reply-to-{{c.id}}')"><i class="fas fa-reply" aria-hidden="true"></i>Reply</button>
@ -619,7 +619,7 @@
{% elif replies %}
<div id="morecomments-{{c.id}}" class="mt-2 more-comments">
<button id="btn-{{c.id}}" class="d-none d-md-block btn btn-primary" onclick="morecomments('{{c.id}}')">More comments</button>
<a class="d-md-none" href="{{c.shortlink}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
<a class="d-md-none" href="{{c.morecomments}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
</div>
{% endif %}
@ -664,7 +664,7 @@
<a class="list-group-item" href="{{c.permalink}}"><i class="fas fa-book-open"></i>Context</a>
<a role="button" class="list-group-item copy-link" data-bs-dismiss="modal" data-clipboard-text="{% if request.host == 'rdrama.net' %}https://rdrama.gay{{c.sl}}{% else %}{{c.permalink}}{% endif %}"><i class="fas fa-copy"></i>Copy link</a>
<a role="button" class="list-group-item copy-link" data-bs-dismiss="modal" data-clipboard-text="{% if request.host == 'rdrama.net' %}https://rdrama.gay{{c.shortlink}}{% else %}{{c.permalink}}{% endif %}"><i class="fas fa-copy"></i>Copy link</a>
{% if v %}
<a role="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#reportCommentModal" onclick="report_commentModal('{{c.id}}','{{c.author_name}}')" class="list-group-item"><i class="fas fa-flag"></i>Report</a>