mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
public_url on posts too #194
This commit is contained in:
parent
e4ea5de665
commit
a5583dc37e
3 changed files with 11 additions and 8 deletions
|
@ -1017,6 +1017,9 @@ class Post(db.Model):
|
|||
else:
|
||||
return f"https://{current_app.config['SERVER_NAME']}/post/{self.id}"
|
||||
|
||||
def public_url(self):
|
||||
return self.profile_id()
|
||||
|
||||
def blocked_by_content_filter(self, content_filters):
|
||||
lowercase_title = self.title.lower()
|
||||
for name, keywords in content_filters.items() if content_filters else {}:
|
||||
|
|
|
@ -154,7 +154,7 @@ def show_post(post_id: int):
|
|||
community.public_url(), post.author.public_url()
|
||||
],
|
||||
'content': reply.body_html,
|
||||
'inReplyTo': post.public_url(),
|
||||
'inReplyTo': post.profile_id(),
|
||||
'mediaType': 'text/html',
|
||||
'published': ap_datetime(utcnow()),
|
||||
'distinguished': False,
|
||||
|
@ -403,7 +403,7 @@ def post_vote(post_id: int, vote_direction):
|
|||
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
||||
action_json = {
|
||||
'actor': current_user.public_url(),
|
||||
'object': post.public_url(),
|
||||
'object': post.profile_id(),
|
||||
'type': action_type,
|
||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
||||
'audience': post.community.public_url()
|
||||
|
@ -592,7 +592,7 @@ def poll_vote(post_id):
|
|||
'object': {
|
||||
'attributedTo': current_user.public_url(),
|
||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/vote/{gibberish(15)}",
|
||||
'inReplyTo': post.public_url(),
|
||||
'inReplyTo': post.profile_id(),
|
||||
'name': pv.choice_text,
|
||||
'to': post.author.public_url(),
|
||||
'type': 'Note'
|
||||
|
@ -751,8 +751,8 @@ def add_reply(post_id: int, comment_id: int):
|
|||
in_reply_to.author.public_url()
|
||||
],
|
||||
'content': reply.body_html,
|
||||
'inReplyTo': in_reply_to.public_url(),
|
||||
'url': reply.public_url(),
|
||||
'inReplyTo': in_reply_to.profile_id(),
|
||||
'url': reply.profile_id(),
|
||||
'mediaType': 'text/html',
|
||||
'published': ap_datetime(utcnow()),
|
||||
'distinguished': False,
|
||||
|
@ -1862,7 +1862,7 @@ def post_reply_edit(post_id: int, comment_id: int):
|
|||
in_reply_to.author.public_url()
|
||||
],
|
||||
'content': post_reply.body_html,
|
||||
'inReplyTo': in_reply_to.public_url(),
|
||||
'inReplyTo': in_reply_to.profile_id(),
|
||||
'url': post_reply.public_url(),
|
||||
'mediaType': 'text/html',
|
||||
'published': ap_datetime(post_reply.posted_at),
|
||||
|
|
|
@ -606,11 +606,11 @@ def can_create_post_reply(user, content: Community) -> bool:
|
|||
def reply_already_exists(user_id, post_id, parent_id, body) -> bool:
|
||||
if parent_id is None:
|
||||
num_matching_replies = db.session.execute(text(
|
||||
'SELECT COUNT(id) as c FROM "post_reply" WHERE user_id = :user_id AND post_id = :post_id AND parent_id is null AND body = :body'),
|
||||
'SELECT COUNT(id) as c FROM "post_reply" WHERE deleted is false and user_id = :user_id AND post_id = :post_id AND parent_id is null AND body = :body'),
|
||||
{'user_id': user_id, 'post_id': post_id, 'body': body}).scalar()
|
||||
else:
|
||||
num_matching_replies = db.session.execute(text(
|
||||
'SELECT COUNT(id) as c FROM "post_reply" WHERE user_id = :user_id AND post_id = :post_id AND parent_id = :parent_id AND body = :body'),
|
||||
'SELECT COUNT(id) as c FROM "post_reply" WHERE deleted is false and user_id = :user_id AND post_id = :post_id AND parent_id = :parent_id AND body = :body'),
|
||||
{'user_id': user_id, 'post_id': post_id, 'parent_id': parent_id, 'body': body}).scalar()
|
||||
return num_matching_replies != 0
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue