feat/show nodeinfo

close #4
This commit is contained in:
SouthFox 2023-03-18 12:56:54 +08:00
parent 1378ac993d
commit 3e677afebc

View file

@ -12,6 +12,7 @@ from fastapi import Response
from fastapi.exceptions import HTTPException from fastapi.exceptions import HTTPException
from sqlalchemy.util import monkeypatch_proxied_specials from sqlalchemy.util import monkeypatch_proxied_specials
from starlette.responses import JSONResponse from starlette.responses import JSONResponse
from typing import Any
from loguru import logger from loguru import logger
@ -86,3 +87,34 @@ async def wellknown_webfinger(resource: str) -> JSONResponse:
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": "*"},
) )
@app.get("/.well-known/nodeinfo")
async def well_known_nodeinfo() -> dict[str, Any]:
return {
"links": [
{
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
"href": f"{BASE_URL}/nodeinfo/2.0",
}
]
}
@app.get("/nodeinfo/2.0")
async def nodeinfo(
db_session: AsyncSession = Depends(get_db_session),
):
return JSONResponse(
{
"version": "2.0",
"software": {
"name": "foxhole",
"version": "0.0.1",
},
"protocols": ["activitypub"],
"services": {"inbound": [], "outbound": []},
"usage": {"users": {"total": 1}, "localPosts": 0}, #TODO
"openRegistrations": False,
"metadata": {},
},
)