From 93c52b2a8607c5c30be20a7907ac24d7ebd97ce7 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Fri, 23 Feb 2024 20:23:59 +1300 Subject: [PATCH] debug issues found in production log --- app/activitypub/routes.py | 2 +- app/activitypub/util.py | 2 +- app/domain/routes.py | 2 +- app/main/routes.py | 4 ++-- app/post/routes.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index b13c0cd9..c0981c23 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -1013,7 +1013,7 @@ def comment_ap(comment_id): resp.content_type = 'application/activity+json' return resp else: - reply = PostReply.query.get(comment_id) + reply = PostReply.query.get_or_404(comment_id) return continue_discussion(reply.post.id, comment_id) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 1af84b90..173df0db 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -168,7 +168,7 @@ def post_to_activity(post: Post, community: Community): if post.type == POST_TYPE_LINK and post.url is not None: activity_data["object"]["object"]["attachment"] = {"href": post.url, "type": "Link"} if post.image_id is not None: - activity_data["object"]["object"]["image"] = {"href": post.image.view_url(), "type": "Image"} + activity_data["object"]["object"]["image"] = {"url": post.image.view_url(), "type": "Image"} if post.image.alt_text: activity_data["object"]["object"]["image"]['altText'] = post.image.alt_text return activity_data diff --git a/app/domain/routes.py b/app/domain/routes.py index 2bf2ad3b..db00d930 100644 --- a/app/domain/routes.py +++ b/app/domain/routes.py @@ -27,7 +27,7 @@ def show_domain(domain_id): if current_user.is_anonymous or current_user.ignore_bots: posts = Post.query.join(Community, Community.id == Post.community_id).\ filter(Post.from_bot == False, Post.domain_id == domain.id, Community.banned == False).\ - order_by(desc(Post.posted_at)).all() + order_by(desc(Post.posted_at)) else: posts = Post.query.join(Community).filter(Post.domain_id == domain.id, Community.banned == False).order_by(desc(Post.posted_at)) diff --git a/app/main/routes.py b/app/main/routes.py index f565b7be..7812b42b 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -197,10 +197,10 @@ def list_subscribed_communities(): verification_warning() sort_by = text('community.' + request.args.get('sort_by') if request.args.get('sort_by') else 'community.post_reply_count desc') if current_user.is_authenticated: - communities = Community.query.filter_by(banned=False).join(CommunityMember).filter(CommunityMember.user_id == current_user.id) + communities = Community.query.filter_by(banned=False).join(CommunityMember).filter(CommunityMember.user_id == current_user.id).order_by(sort_by).all() else: communities = [] - return render_template('list_communities.html', communities=communities.order_by(sort_by).all(), title=_('Joined communities'), + return render_template('list_communities.html', communities=communities, title=_('Joined communities'), SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER, sort_by=sort_by, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1', moderating_communities=moderating_communities(current_user.get_id()), diff --git a/app/post/routes.py b/app/post/routes.py index 98e421e0..f5c1e014 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -756,7 +756,7 @@ def post_report(post_id: int): url=f"https://{current_app.config['SERVER_NAME']}/post/{post.id}", author_id=current_user.id) db.session.add(notification) - already_notified.add(mod.id) + already_notified.add(mod.user_id) post.reports += 1 # todo: only notify admins for certain types of report for admin in Site.admins():