From e6066cb21255dd4190215d82d4f15e1e6f38c96e Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Tue, 5 Jul 2022 08:14:50 +0200 Subject: [PATCH] Various bugfixes --- app/boxes.py | 27 +++++++++++++++++++-------- app/main.py | 3 ++- app/outgoing_activities.py | 5 +++-- app/scss/main.scss | 2 +- app/templates/utils.html | 2 -- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/boxes.py b/app/boxes.py index f00d04a..bced23a 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -883,30 +883,41 @@ async def get_replies_tree( tree_nodes.extend( ( await db_session.scalars( - select(models.InboxObject).where( + select(models.InboxObject) + .where( models.InboxObject.ap_context == requested_object.ap_context, ) + .options(joinedload(models.InboxObject.actor)) ) - ).all() + ) + .unique() + .all() ) tree_nodes.extend( ( await db_session.scalars( - select(models.OutboxObject).where( + select(models.OutboxObject) + .where( models.OutboxObject.ap_context == requested_object.ap_context, models.OutboxObject.is_deleted.is_(False), ) + .options( + joinedload(models.OutboxObject.outbox_object_attachments).options( + joinedload(models.OutboxObjectAttachment.upload) + ) + ) ) - ).all() + ) + .unique() + .all() ) nodes_by_in_reply_to = defaultdict(list) for node in tree_nodes: nodes_by_in_reply_to[node.in_reply_to].append(node) logger.info(nodes_by_in_reply_to) - # TODO: get oldest if we cannot get to root? - if len(nodes_by_in_reply_to.get(None, [])) != 1: - raise ValueError("Failed to compute replies tree") + if len(nodes_by_in_reply_to.get(None, [])) > 1: + raise ValueError("Invalid replies tree") def _get_reply_node_children( node: ReplyTreeNode, @@ -932,7 +943,7 @@ async def get_replies_tree( else: root_ap_object = sorted( tree_nodes, - lambda ap_obj: ap_obj.ap_published_at, # type: ignore + key=lambda ap_obj: ap_obj.ap_published_at, # type: ignore )[0] root_node = ReplyTreeNode( diff --git a/app/main.py b/app/main.py index f1faab5..d413345 100644 --- a/app/main.py +++ b/app/main.py @@ -739,7 +739,7 @@ async def nodeinfo( ) -proxy_client = httpx.AsyncClient() +proxy_client = httpx.AsyncClient(follow_redirects=True) @app.get("/proxy/media/{encoded_url}") @@ -820,6 +820,7 @@ async def serve_proxy_media_resized( ] ] + [(b"user-agent", USER_AGENT.encode())], + follow_redirects=True, ) if proxy_resp.status_code != 200: return PlainTextResponse( diff --git a/app/outgoing_activities.py b/app/outgoing_activities.py index 24f4d2a..e83e85e 100644 --- a/app/outgoing_activities.py +++ b/app/outgoing_activities.py @@ -83,9 +83,10 @@ def process_next_outgoing_activity(db: Session) -> bool: models.OutgoingActivity.is_sent.is_(False), ] q_count = db.scalar(select(func.count(models.OutgoingActivity.id)).where(*where)) - logger.info(f"{q_count} outgoing activities ready to process") + if q_count > 0: + logger.info(f"{q_count} outgoing activities ready to process") if not q_count: - logger.info("No activities to process") + # logger.debug("No activities to process") return False next_activity = db.execute( diff --git a/app/scss/main.scss b/app/scss/main.scss index d1a2340..634067c 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -127,7 +127,7 @@ footer { padding: 0; } li { - display: inline-block; + display: block; } } diff --git a/app/templates/utils.html b/app/templates/utils.html index ebb0f51..ba1b2a2 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -294,8 +294,6 @@ - - {% endmacro %} {% macro display_object(object) %}