From 24385ad6185caec14f45687d4ba417c422600cec Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 25 Oct 2021 15:55:56 +0200 Subject: [PATCH] misc --- files/routes/posts.py | 33 +++++++++++++++++++++------------ files/templates/comments.html | 2 +- snappy.txt | 4 +++- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index d1ea43416..564c258db 100755 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -59,12 +59,21 @@ def publish(pid, v): post.private = False g.db.add(post) - cache.delete_memoized(frontlist) + notify_users = set() + soup = BeautifulSoup(post.body_html, features="html.parser") + for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): + username = mention["href"].split("@")[1] + user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first() + if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user) + + for x in notify_users: send_notification(x.id, f"@{v.username} has mentioned you: http://{site}{new_post.permalink}") for follow in v.followers: user = get_account(follow.user_id) send_notification(user.id, f"@{v.username} has made a new post: [{post.title}](http://{site}{post.permalink})", True) + cache.delete_memoized(frontlist) + g.db.commit() return {"message": "Post published!"} @@ -101,7 +110,7 @@ def post_id(pid, anything=None, v=None): post = get_post(pid, v=v) - if post.club and not (v and v.paid_dues): abort(403) + if post.club and not (v and v.paid_dues) or post.is_private and not (v and v.id == post.author_id): abort(403) if v: votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery() @@ -725,17 +734,17 @@ def submit_post(v): if (new_post.url or request.files.get('file')) and (v.is_activated or request.headers.get('cf-ipcountry')!="T1"): gevent.spawn( thumbnail_thread, new_post.id) - notify_users = set() - - soup = BeautifulSoup(body_html, features="html.parser") - for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): - username = mention["href"].split("@")[1] - user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first() - if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user) - - for x in notify_users: send_notification(x.id, f"@{v.username} has mentioned you: http://{site}{new_post.permalink}") - if not new_post.private: + + notify_users = set() + soup = BeautifulSoup(body_html, features="html.parser") + for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): + username = mention["href"].split("@")[1] + user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first() + if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user) + + for x in notify_users: send_notification(x.id, f"@{v.username} has mentioned you: http://{site}{new_post.permalink}") + for follow in v.followers: user = get_account(follow.user_id) send_notification(user.id, f"@{v.username} has made a new post: [{title}](http://{site}{new_post.permalink})", True) diff --git a/files/templates/comments.html b/files/templates/comments.html index 0e0e3b68f..bbac51c78 100755 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -126,7 +126,7 @@
{{c.author.username}}
- .replace(/data-src/g, 'src') +
{% if c.author.bio_html %}{{c.author.bio_html_eager | safe}}{% endif %}
diff --git a/snappy.txt b/snappy.txt index 45bec7da2..a6818fab2 100755 --- a/snappy.txt +++ b/snappy.txt @@ -2725,4 +2725,6 @@ Aaaaand unsubed. Really a lack of empathy from all these assholes. We knew this {[para]} Oh man...do U even realize,the substance of the question U were asking?If U do ,then U will realize why,U failed 2 receive a reply. I mean really,what dimension are U from?Did the Stargate U materialized from suffer an incomplete transmission,leaving some essential particles scattered about,in the wormhole?🤔 {[para]} -Really wish we could speed up this timeline and get to the part where you get thrown in prison for child porn. \ No newline at end of file +Really wish we could speed up this timeline and get to the part where you get thrown in prison for child porn. +{[para]} +I don’t know what to make of any of this, waiting for the Contrapoints rebuttal video. \ No newline at end of file