add text_permalink property
parent
6383d53416
commit
923dd811f4
|
@ -315,6 +315,11 @@ class Comment(Base):
|
|||
def permalink(self):
|
||||
return f"{SITE_FULL}{self.shortlink}"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def text_permalink(self):
|
||||
return f"[your comment]({self.shortlink})"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def log_link(self):
|
||||
|
|
|
@ -48,7 +48,7 @@ def archive_url(url):
|
|||
def snappy_report(post, reason):
|
||||
report = Report(post_id=post.id, user_id=SNAPPY_ID, reason=reason)
|
||||
g.db.add(report)
|
||||
message = f'@Snappy reported [{post.title}]({post.shortlink})\n\n> {reason}'
|
||||
message = f'@Snappy reported {post.text_permalink})\n\n> {reason}'
|
||||
send_repeatable_notification(post.author_id, message)
|
||||
|
||||
def execute_snappy(post, v):
|
||||
|
@ -166,7 +166,7 @@ def execute_snappy(post, v):
|
|||
awarded_coins = int(AWARDS["glowie"]['price'] * COSMETIC_AWARD_COIN_AWARD_PCT)
|
||||
post.author.pay_account('coins', awarded_coins)
|
||||
|
||||
msg = f"@Snappy has given [{post.title}]({post.shortlink}) the Glowie Award and you have received {awarded_coins} coins as a result!"
|
||||
msg = f"@Snappy has given {post.text_permalink} the Glowie Award and you have received {awarded_coins} coins as a result!"
|
||||
send_repeatable_notification(post.author.id, msg)
|
||||
elif body.startswith("You're a chud, CHUD I tell you"):
|
||||
award_object = AwardRelationship(
|
||||
|
@ -178,7 +178,7 @@ def execute_snappy(post, v):
|
|||
)
|
||||
g.db.add(award_object)
|
||||
|
||||
msg = f"@Snappy has given [{post.title}]({post.shortlink}) the Chud Award\n\n**You now have to say this phrase in all posts and comments you make for 24 hours:**\n\n> Trans lives matter"
|
||||
msg = f"@Snappy has given {post.text_permalink} the Chud Award\n\n**You now have to say this phrase in all posts and comments you make for 24 hours:**\n\n> Trans lives matter"
|
||||
send_repeatable_notification(post.author.id, msg)
|
||||
|
||||
if v.chud != 1:
|
||||
|
|
|
@ -1466,7 +1466,7 @@ def pin_post(post_id, v):
|
|||
pin_time = 'for 1 hour'
|
||||
code = 200
|
||||
if v.id != post.author_id:
|
||||
send_repeatable_notification(post.author_id, f"@{v.username} (a site admin) has pinned [{post.title}]({post.shortlink})")
|
||||
send_repeatable_notification(post.author_id, f"@{v.username} (a site admin) has pinned {post.text_permalink}")
|
||||
else:
|
||||
if pins >= PIN_LIMIT + 1:
|
||||
abort(403, f"Can't exceed {PIN_LIMIT} pinned posts limit!")
|
||||
|
@ -1515,7 +1515,7 @@ def unpin_post(post_id, v):
|
|||
g.db.add(ma)
|
||||
|
||||
if v.id != post.author_id:
|
||||
send_repeatable_notification(post.author_id, f"@{v.username} (a site admin) has unpinned [{post.title}]({post.shortlink})")
|
||||
send_repeatable_notification(post.author_id, f"@{v.username} (a site admin) has unpinned {post.text_permalink}")
|
||||
|
||||
cache.delete_memoized(frontlist)
|
||||
return {"message": "Post unpinned!"}
|
||||
|
@ -1547,7 +1547,7 @@ def pin_comment_admin(cid, v):
|
|||
g.db.add(ma)
|
||||
|
||||
if v.id != comment.author_id:
|
||||
message = f"@{v.username} (a site admin) has pinned your [comment]({comment.shortlink})"
|
||||
message = f"@{v.username} (a site admin) has pinned {comment.text_permalink}"
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
|
||||
comment.pin_parents()
|
||||
|
@ -1580,7 +1580,7 @@ def unpin_comment_admin(cid, v):
|
|||
g.db.add(ma)
|
||||
|
||||
if v.id != comment.author_id:
|
||||
message = f"@{v.username} (a site admin) has unpinned your [comment]({comment.shortlink})"
|
||||
message = f"@{v.username} (a site admin) has unpinned {comment.text_permalink}"
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
|
||||
comment.unpin_parents()
|
||||
|
|
|
@ -222,7 +222,7 @@ def award_thing(v, thing_type, id):
|
|||
|
||||
if v.id != author.id:
|
||||
if author.deflector and v.deflector and AWARDS[kind]['deflectable']:
|
||||
msg = f"@{v.username} has tried to give your [{thing_type}]({obj.shortlink}) the {award_title} Award but it was deflected on them, they also had a deflector up, so it bounced back and forth until it vaporized!"
|
||||
msg = f"@{v.username} has tried to give {obj.text_permalink} the {award_title} Award but it was deflected on them, they also had a deflector up, so it bounced back and forth until it vaporized!"
|
||||
send_repeatable_notification(author.id, msg)
|
||||
|
||||
msg = f"{safe_username} under the effect of a deflector award; your {award_title} Award has been deflected back to you but your deflector protected you, the award bounced back and forth until it vaporized!"
|
||||
|
@ -253,37 +253,28 @@ def award_thing(v, thing_type, id):
|
|||
else:
|
||||
author.pay_account('coins', awarded_coins)
|
||||
|
||||
if isinstance(obj, Comment):
|
||||
link_text_in_notif = "your comment"
|
||||
else:
|
||||
link_text_in_notif = obj.title
|
||||
|
||||
if kind == 'marsify' and author.marsify == 1:
|
||||
abort(409, f"{safe_username} already permanently marsified!")
|
||||
|
||||
if kind == 'spider' and author.spider == 1:
|
||||
abort(409, f"{safe_username} already best friends with a spider!")
|
||||
|
||||
link = f"[this {thing_type}]({obj.shortlink})"
|
||||
|
||||
can_alter_body = not obj.author.deflector or v == obj.author
|
||||
|
||||
if kind == "ban":
|
||||
link = f"/{thing_type}/{obj.id}"
|
||||
if kind in {"ban", "grass"}:
|
||||
ban_reason_link = f"/{thing_type}/{obj.id}"
|
||||
if isinstance(obj, Comment):
|
||||
link += '#context'
|
||||
link_text_in_notif = link
|
||||
else:
|
||||
link_text_in_notif = obj.title
|
||||
ban_reason_link += '#context'
|
||||
author.ban_reason = f'{award_title} award used by @{v.username} on <a href="{ban_reason_link}">{ban_reason_link}</a>'
|
||||
|
||||
ban_reason = f'1-Day ban award used by <a href="/@{v.username}">@{v.username}</a> on <a href="{link}">{link}</a>'
|
||||
|
||||
if kind == "ban":
|
||||
if not author.is_suspended:
|
||||
author.ban(reason=ban_reason, days=1)
|
||||
send_repeatable_notification(author.id, f"Your account has been banned for **a day** for [{link_text_in_notif}]({link}). It sucked and you should feel bad.")
|
||||
send_repeatable_notification(author.id, f"Your account has been banned for **a day** for {obj.text_permalink}. It sucked and you should feel bad.")
|
||||
elif author.unban_utc:
|
||||
author.unban_utc += 86400
|
||||
author.ban_reason = ban_reason
|
||||
send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for [{link_text_in_notif}]({link}). Seriously man?")
|
||||
send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {obj.text_permalink}. Seriously man?")
|
||||
elif kind == "unban":
|
||||
if not author.is_suspended or not author.unban_utc:
|
||||
abort(403)
|
||||
|
@ -300,16 +291,9 @@ def award_thing(v, thing_type, id):
|
|||
author.ban_reason = None
|
||||
send_repeatable_notification(author.id, "You have been unbanned!")
|
||||
elif kind == "grass":
|
||||
link3 = f"/{thing_type}/{obj.id}"
|
||||
if isinstance(obj, Comment):
|
||||
link3 = f'<a href="{link3}#context">{link3}</a>'
|
||||
else:
|
||||
link3 = f'<a href="{link3}">{link3}</a>'
|
||||
|
||||
author.is_banned = AUTOJANNY_ID
|
||||
author.ban_reason = f"grass award used by @{v.username} on {link3}"
|
||||
author.unban_utc = int(time.time()) + 30 * 86400
|
||||
send_repeatable_notification(author.id, f"@{v.username} gave you the grass award on {link} and as a result you have been banned! You must [send the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned!")
|
||||
send_repeatable_notification(author.id, f"@{v.username} gave you the grass award on {obj.text_permalink} and as a result you have been banned! You must [send the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned!")
|
||||
elif kind == "pin":
|
||||
if not FEATURES['PINS']: abort(403)
|
||||
if obj.is_banned: abort(403)
|
||||
|
@ -613,7 +597,7 @@ def award_thing(v, thing_type, id):
|
|||
author = obj.author
|
||||
if v.id != author.id:
|
||||
if author.deflector and AWARDS[kind]['deflectable']:
|
||||
msg = f"@{v.username} has tried to give your [{thing_type}]({obj.shortlink}) the {award_title} Award but it was deflected and applied to them :marseytroll:"
|
||||
msg = f"@{v.username} has tried to give {obj.text_permalink} the {award_title} Award but it was deflected and applied to them :marseytroll:"
|
||||
n = send_repeatable_notification(author.id, msg)
|
||||
if n: n.created_utc -= 2
|
||||
|
||||
|
@ -621,7 +605,7 @@ def award_thing(v, thing_type, id):
|
|||
n = send_repeatable_notification(v.id, msg)
|
||||
if n: n.created_utc -= 2
|
||||
elif kind not in {'spider', 'jumpscare'}:
|
||||
msg = f"@{v.username} has given [{link_text_in_notif}]({obj.shortlink}) the {award_title} Award"
|
||||
msg = f"@{v.username} has given {obj.text_permalink} the {award_title} Award"
|
||||
|
||||
if kind == 'shit':
|
||||
msg += f" and has stolen from you {awarded_coins} coins as a result"
|
||||
|
|
|
@ -509,8 +509,8 @@ def pin_comment_op(cid, v):
|
|||
comment.pin_parents()
|
||||
|
||||
if v.id != comment.author_id:
|
||||
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})"
|
||||
if comment.post.ghost: message = f"OP has pinned {comment.text_permalink}"
|
||||
else: message = f"@{v.username} (OP) has pinned {comment.text_permalink}"
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
|
||||
return {"message": "Comment pinned!"}
|
||||
|
@ -539,7 +539,7 @@ def unpin_comment_op(cid, v):
|
|||
comment.unpin_parents()
|
||||
|
||||
if v.id != comment.author_id:
|
||||
message = f"@{v.username} (OP) has unpinned your [comment]({comment.shortlink})"
|
||||
message = f"@{v.username} (OP) has unpinned {comment.text_permalink}"
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
return {"message": "Comment unpinned!"}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ def exile_post(v, pid):
|
|||
exile = Exile(user_id=u.id, hole=hole, exiler_id=v.id)
|
||||
g.db.add(exile)
|
||||
|
||||
send_notification(u.id, f"@{v.username} has exiled you from /h/{hole} for [{p.title}]({p.shortlink})")
|
||||
send_notification(u.id, f"@{v.username} has exiled you from /h/{hole} for {p.text_permalink}")
|
||||
|
||||
ma = HoleAction(
|
||||
hole=hole,
|
||||
|
@ -73,7 +73,7 @@ def exile_comment(v, cid):
|
|||
exile = Exile(user_id=u.id, hole=hole, exiler_id=v.id)
|
||||
g.db.add(exile)
|
||||
|
||||
send_notification(u.id, f"@{v.username} has exiled you from /h/{hole} for [{c.permalink}]({c.shortlink})")
|
||||
send_notification(u.id, f"@{v.username} has exiled you from /h/{hole} for {c.text_permalink}")
|
||||
|
||||
ma = HoleAction(
|
||||
hole=hole,
|
||||
|
@ -435,7 +435,7 @@ def kick(v, pid):
|
|||
g.db.add(ma)
|
||||
|
||||
if v.id != post.author_id:
|
||||
message = f"@{v.username} (a /h/{old} mod) has moved [{post.title}]({post.shortlink}) from /h/{old} to the main feed!"
|
||||
message = f"@{v.username} (a /h/{old} mod) has moved {post.text_permalink} from /h/{old} to the main feed!"
|
||||
send_repeatable_notification(post.author_id, message)
|
||||
|
||||
g.db.add(post)
|
||||
|
@ -771,7 +771,7 @@ def hole_pin(v, pid):
|
|||
g.db.add(p)
|
||||
|
||||
if v.id != p.author_id:
|
||||
message = f"@{v.username} (a /h/{p.hole} mod) has pinned [{p.title}]({p.shortlink}) in /h/{p.hole}"
|
||||
message = f"@{v.username} (a /h/{p.hole} mod) has pinned {p.text_permalink} in /h/{p.hole}"
|
||||
send_repeatable_notification(p.author_id, message)
|
||||
|
||||
ma = HoleAction(
|
||||
|
@ -803,7 +803,7 @@ def hole_unpin(v, pid):
|
|||
g.db.add(p)
|
||||
|
||||
if v.id != p.author_id:
|
||||
message = f"@{v.username} (a /h/{p.hole} mod) has unpinned [{p.title}]({p.shortlink}) in /h/{p.hole}"
|
||||
message = f"@{v.username} (a /h/{p.hole} mod) has unpinned {p.text_permalink} in /h/{p.hole}"
|
||||
send_repeatable_notification(p.author_id, message)
|
||||
|
||||
ma = HoleAction(
|
||||
|
@ -918,7 +918,7 @@ def pin_comment_mod(cid, v):
|
|||
g.db.add(ma)
|
||||
|
||||
if v.id != comment.author_id:
|
||||
message = f"@{v.username} (a /h/{comment.post.hole} mod) has pinned your [comment]({comment.shortlink})"
|
||||
message = f"@{v.username} (a /h/{comment.post.hole} mod) has pinned {comment.text_permalink}"
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
|
||||
return {"message": "Comment pinned!"}
|
||||
|
@ -951,7 +951,7 @@ def unpin_comment_mod(cid, v):
|
|||
g.db.add(ma)
|
||||
|
||||
if v.id != comment.author_id:
|
||||
message = f"@{v.username} (a /h/{comment.post.hole} mod) has unpinned your [comment]({comment.shortlink})"
|
||||
message = f"@{v.username} (a /h/{comment.post.hole} mod) has unpinned {comment.text_permalink}"
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
return {"message": "Comment unpinned!"}
|
||||
|
||||
|
@ -1139,7 +1139,7 @@ def change_hole(pid, v):
|
|||
else:
|
||||
hole_from_in_notif = f'/h/{hole_from}'
|
||||
|
||||
message = f"@{v.username} ({position}) has moved [{post.title}]({post.shortlink}) from {hole_from_in_notif} to {hole_to_in_notif}"
|
||||
message = f"@{v.username} ({position}) has moved {post.text_permalink} from {hole_from_in_notif} to {hole_to_in_notif}"
|
||||
send_repeatable_notification(post.author_id, message)
|
||||
|
||||
cache.delete_memoized(frontlist)
|
||||
|
|
|
@ -55,7 +55,7 @@ def report_post(pid, v):
|
|||
position = f'a /h/{post.hole} mod'
|
||||
|
||||
if v.id != post.author_id:
|
||||
message = f'@{v.username} ({position}) has flaired [{post.title}]({post.shortlink}) with the flair: `"{og_flair}"`'
|
||||
message = f'@{v.username} ({position}) has flaired {post.text_permalink} with the flair: `"{og_flair}"`'
|
||||
send_repeatable_notification(post.author_id, message)
|
||||
|
||||
return {"message": "Post flaired successfully!"}
|
||||
|
@ -68,7 +68,7 @@ def report_post(pid, v):
|
|||
g.db.add(report)
|
||||
|
||||
if v.id != post.author_id and not post.author.has_blocked(v) and not post.author.has_muted(v):
|
||||
message = f'@{v.username} reported [{post.title}]({post.shortlink})\n\n> {reason}'
|
||||
message = f'@{v.username} reported {post.text_permalink}\n\n> {reason}'
|
||||
send_repeatable_notification(post.author_id, message)
|
||||
|
||||
return {"message": "Post reported!"}
|
||||
|
@ -103,7 +103,7 @@ def report_comment(cid, v):
|
|||
g.db.add(report)
|
||||
|
||||
if v.id != comment.author_id and not comment.author.has_blocked(v) and not comment.author.has_muted(v):
|
||||
message = f'@{v.username} reported your [comment]({comment.shortlink})\n\n> {reason}'
|
||||
message = f'@{v.username} reported {comment.text_permalink}\n\n> {reason}'
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
|
||||
return {"message": "Comment reported!"}
|
||||
|
|
Loading…
Reference in New Issue