[refactor] format code & rename var

This commit is contained in:
SouthFox 2023-08-01 22:25:02 +08:00
parent 600d8d2032
commit 652db0ca20

View file

@ -83,10 +83,12 @@ async def index(
statues = ( statues = (
await db_session.scalars( await db_session.scalars(
select(models.OutboxObject).where( select(models.OutboxObject)
.where(
models.OutboxObject.ap_type == "Note", models.OutboxObject.ap_type == "Note",
models.OutboxObject.is_deleted.is_(False), models.OutboxObject.is_deleted.is_(False),
).order_by(models.OutboxObject.created_at.desc()) )
.order_by(models.OutboxObject.created_at.desc())
) )
).all() ).all()
@ -95,7 +97,7 @@ async def index(
{ {
"request": request, "request": request,
"statues": statues, "statues": statues,
} },
) )
@ -109,16 +111,10 @@ async def inbox(
payload = await request.json() payload = await request.json()
if not httpsig_checker: if not httpsig_checker:
return Response( return Response(status_code=406, content="invalid http-sig")
status_code=406,
content="invalid http-sig"
)
if not await save_incoming(db_session, payload): if not await save_incoming(db_session, payload):
return Response( return Response(status_code=406, content="invalid activitypub object")
status_code=406,
content="invalid activitypub object"
)
return Response(status_code=202) return Response(status_code=202)
@ -185,7 +181,7 @@ async def wellknown_webfinger(resource: str) -> JSONResponse:
logger.info(f"Got invalid req for {resource}") logger.info(f"Got invalid req for {resource}")
raise HTTPException(status_code=404) raise HTTPException(status_code=404)
out = { response = {
"subject": f"acct:{USERNAME}@{DOMAIN}", "subject": f"acct:{USERNAME}@{DOMAIN}",
"aliases": [ID], "aliases": [ID],
"links": [ "links": [
@ -203,7 +199,7 @@ async def wellknown_webfinger(resource: str) -> JSONResponse:
} }
return JSONResponse( return JSONResponse(
out, response,
media_type="application/jrd+json; charset=utf-8", media_type="application/jrd+json; charset=utf-8",
headers={"Access-Control-Allow-Origin": "*"}, headers={"Access-Control-Allow-Origin": "*"},
) )