diff --git a/app/main.py b/app/main.py index 285260d..ee9e700 100644 --- a/app/main.py +++ b/app/main.py @@ -159,6 +159,30 @@ async def api_revoke_key(name: str, request: Request): return JSONResponse({"error": e.detail}, status_code=e.status_code) +@app.get("/api/matrix-mxid") +async def api_get_matrix_mxid(request: Request): + identity = get_user_identity(request) + if not identity: + return JSONResponse({"error": "unauthenticated"}, status_code=401) + try: + return await broker_get(identity, "/broker/matrix-mxid") + except HTTPException as e: + return JSONResponse({"error": e.detail}, status_code=e.status_code) + + +@app.post("/api/matrix-mxid") +async def api_set_matrix_mxid(request: Request): + identity = get_user_identity(request) + if not identity: + return JSONResponse({"error": "unauthenticated"}, status_code=401) + body = await request.json() + mxid = (body.get("matrix_mxid") or "").strip() + try: + return await broker_post(identity, "/broker/matrix-mxid", {"matrix_mxid": mxid}) + except HTTPException as e: + return JSONResponse({"error": e.detail}, status_code=e.status_code) + + # --------------------------------------------------------------------------- # OIDC routes — authorization-code flow against Cloudron's OIDC provider. # Active only when the `oidc` addon is configured (CLOUDRON_OIDC_* present). @@ -532,6 +556,16 @@ PAGE_HTML = """ + +
You're invited to the co-op's Matrix space at your co-op account (@you:inference.coop). Prefer to use an existing account on another server instead? Add it below (one account).