diff --git a/app/main.py b/app/main.py index 6fabb6c..d65cee9 100644 --- a/app/main.py +++ b/app/main.py @@ -74,8 +74,8 @@ def is_ap_requested(req: Request) -> bool: @app.get("/") async def index( - request: Request, - db_session: AsyncSession = Depends(get_db_session), + request: Request, + db_session: AsyncSession = Depends(get_db_session), ): """Return index page.""" if is_ap_requested(request): @@ -83,10 +83,12 @@ async def index( statues = ( await db_session.scalars( - select(models.OutboxObject).where( + select(models.OutboxObject) + .where( models.OutboxObject.ap_type == "Note", models.OutboxObject.is_deleted.is_(False), - ).order_by(models.OutboxObject.created_at.desc()) + ) + .order_by(models.OutboxObject.created_at.desc()) ) ).all() @@ -95,30 +97,24 @@ async def index( { "request": request, "statues": statues, - } + }, ) @app.post("/inbox") async def inbox( - request: Request, - db_session: AsyncSession = Depends(get_db_session), - httpsig_checker=Depends(precheck.inbox_prechecker), + request: Request, + db_session: AsyncSession = Depends(get_db_session), + httpsig_checker=Depends(precheck.inbox_prechecker), ) -> Response: """ActivityPub inbox endpoint.""" payload = await request.json() if not httpsig_checker: - return Response( - status_code=406, - content="invalid http-sig" - ) + return Response(status_code=406, content="invalid http-sig") if not await save_incoming(db_session, payload): - return Response( - status_code=406, - content="invalid activitypub object" - ) + return Response(status_code=406, content="invalid activitypub object") return Response(status_code=202) @@ -185,7 +181,7 @@ async def wellknown_webfinger(resource: str) -> JSONResponse: logger.info(f"Got invalid req for {resource}") raise HTTPException(status_code=404) - out = { + response = { "subject": f"acct:{USERNAME}@{DOMAIN}", "aliases": [ID], "links": [ @@ -203,7 +199,7 @@ async def wellknown_webfinger(resource: str) -> JSONResponse: } return JSONResponse( - out, + response, media_type="application/jrd+json; charset=utf-8", headers={"Access-Control-Allow-Origin": "*"}, )