mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
Include check for post.deleted when looking for cross posts
This commit is contained in:
parent
8542963ac2
commit
a14a41c18e
4 changed files with 13 additions and 14 deletions
|
@ -1866,7 +1866,7 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
|
|||
|
||||
# Update list of cross posts
|
||||
if post.url:
|
||||
other_posts = Post.query.filter(Post.id != post.id, Post.url == post.url,
|
||||
other_posts = Post.query.filter(Post.id != post.id, Post.url == post.url, Post.deleted == False,
|
||||
Post.posted_at > post.posted_at - timedelta(days=6)).all()
|
||||
for op in other_posts:
|
||||
if op.cross_posts is None:
|
||||
|
@ -2072,8 +2072,15 @@ def update_post_from_activity(post: Post, request_json: dict):
|
|||
else:
|
||||
post.url = old_url # don't change if url changed from non-banned domain to banned domain
|
||||
|
||||
# Posts which link to the same url as other posts
|
||||
new_cross_posts = Post.query.filter(Post.id != post.id, Post.url == post.url,
|
||||
# Fix-up cross posts (Posts which link to the same url as other posts)
|
||||
if post.cross_posts is not None:
|
||||
old_cross_posts = Post.query.filter(Post.id.in_(post.cross_posts)).all()
|
||||
post.cross_posts.clear()
|
||||
for ocp in old_cross_posts:
|
||||
if ocp.cross_posts is not None and post.id in ocp.cross_posts:
|
||||
ocp.cross_posts.remove(post.id)
|
||||
|
||||
new_cross_posts = Post.query.filter(Post.id != post.id, Post.url == post.url, Post.deleted == False,
|
||||
Post.posted_at > utcnow() - timedelta(days=6)).all()
|
||||
for ncp in new_cross_posts:
|
||||
if ncp.cross_posts is None:
|
||||
|
@ -2085,14 +2092,6 @@ def update_post_from_activity(post: Post, request_json: dict):
|
|||
else:
|
||||
post.cross_posts.append(ncp.id)
|
||||
|
||||
if post.url != old_url:
|
||||
if post.cross_posts is not None:
|
||||
old_cross_posts = Post.query.filter(Post.id.in_(post.cross_posts)).all()
|
||||
post.cross_posts.clear()
|
||||
for ocp in old_cross_posts:
|
||||
if ocp.cross_posts is not None and post.id in ocp.cross_posts:
|
||||
ocp.cross_posts.remove(post.id)
|
||||
|
||||
if post is not None:
|
||||
if 'image' in request_json['object'] and post.image is None:
|
||||
image = File(source_url=request_json['object']['image']['url'])
|
||||
|
|
|
@ -634,7 +634,7 @@ def add_post(actor, type):
|
|||
|
||||
# Update list of cross posts
|
||||
if post.url:
|
||||
other_posts = Post.query.filter(Post.id != post.id, Post.url == post.url,
|
||||
other_posts = Post.query.filter(Post.id != post.id, Post.url == post.url, Post.deleted == False,
|
||||
Post.posted_at > post.posted_at - timedelta(days=6)).all()
|
||||
for op in other_posts:
|
||||
if op.cross_posts is None:
|
||||
|
|
|
@ -199,7 +199,7 @@ def retrieve_mods_and_backfill(community_id: int):
|
|||
post.ap_announce_id = activity['id']
|
||||
post.ranking = post_ranking(post.score, post.posted_at)
|
||||
if post.url:
|
||||
other_posts = Post.query.filter(Post.id != post.id, Post.url == post.url,
|
||||
other_posts = Post.query.filter(Post.id != post.id, Post.url == post.url, Post.deleted == False,
|
||||
Post.posted_at > post.posted_at - timedelta(days=3),
|
||||
Post.posted_at < post.posted_at + timedelta(days=3)).all()
|
||||
for op in other_posts:
|
||||
|
|
|
@ -839,7 +839,7 @@ def post_edit(post_id: int):
|
|||
if ocp.cross_posts is not None:
|
||||
ocp.cross_posts.remove(post.id)
|
||||
|
||||
new_cross_posts = Post.query.filter(Post.id != post.id, Post.url == post.url,
|
||||
new_cross_posts = Post.query.filter(Post.id != post.id, Post.url == post.url, Post.deleted == False,
|
||||
Post.posted_at > post.edited_at - timedelta(days=6)).all()
|
||||
for ncp in new_cross_posts:
|
||||
if ncp.cross_posts is None:
|
||||
|
|
Loading…
Add table
Reference in a new issue