From 8a2bae706e7b4d3e4746c20f1fc161e1e2926ba7 Mon Sep 17 00:00:00 2001 From: Kierre Date: Sun, 12 Oct 2025 18:43:01 -0400 Subject: [PATCH] Implement Telodendria admin API --- TODO.md | 2 +- vona/custom/__init__.py | 2 + vona/custom/telodendria.py | 86 ++++++++++++++++++++++++++++++++++++++ vona/globals/__init__.py | 2 +- 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 vona/custom/telodendria.py diff --git a/TODO.md b/TODO.md index a3a4181..569dcc8 100644 --- a/TODO.md +++ b/TODO.md @@ -1 +1 @@ -- Implement Telodendria [admin API](https://git.telodendria.org/Telodendria/Telodendria/src/branch/master/docs/user/admin/README.md) +Nothing yet... diff --git a/vona/custom/__init__.py b/vona/custom/__init__.py index 43a8560..a543ddc 100644 --- a/vona/custom/__init__.py +++ b/vona/custom/__init__.py @@ -10,8 +10,10 @@ custom = Blueprint("custom", __name__) from .conduwuit import conduwuit from .dendrite import dendrite +from .telodendria import telo from .synapse import synapse custom.register_blueprint(conduwuit) custom.register_blueprint(dendrite) custom.register_blueprint(synapse) +custom.register_blueprint(telo) diff --git a/vona/custom/telodendria.py b/vona/custom/telodendria.py new file mode 100644 index 0000000..1199202 --- /dev/null +++ b/vona/custom/telodendria.py @@ -0,0 +1,86 @@ +from flask import Blueprint, request, jsonify +from vona.globals import version +import vona.config as config + +telo = Blueprint("telodendria", __name__) + +# The telodendria admin API as specified by +# https://git.telodendria.org/Telodendria/Telodendria/src/branch/master/docs/user/admin/README.md + + +@telo.route("/_telodendria/admin/v1/restart", methods=["POST"]) +@telo.route("/_telodendria/admin/v1/shutdown", methods=["POST"]) +async def process_management(**kwargs): + return jsonify({}) + + + +@telo.route("/_telodendria/admin/v1/privileges/", methods=["GET", "PUT", "POST", "DELETE"]) +@telo.route("/_telodendria/admin/v1/privileges/", methods=["GET", "POST"]) +async def privileges(lp=None): + return jsonify({ + "privileges": [ + "GRANT_PRIVILEGES", + "PROC_CONTROL", + "ISSUE_TOKENS", + "DEACTIVATE", + "CONFIG", + "ALIAS", + "ALL" + ] + }) + + +@telo.route("/_telodendria/admin/v1/config", methods=["GET", "PUT", "POST"]) +async def configuration(): + if request.method == "GET": + return jsonify({ + "listen": [ + { + "tls": None, + "port": config.port, + "threads": 1, + "maxConnections": 32 + } + ], + "serverName": config.server_name, + "pid": "/dev/null", + "baseUrl": f"https://{config.server_name}/", + "identityServer": f"https://{config.server_name}/", + "runAs": None, + "federation": True, + "registration": config.users_can_register, + "log": { + "output": "stdout", + "level": "message", + "timestampFormat": "default", + "color": True + }, + "maxCache": config.the_funny_number + }) + + return jsonify({"restart_required": True}) + + +@telo.route("/_telodendria/admin/v1/stats") +async def stats(): + return jsonify({ + "memory_allocated": config.the_funny_number, + "version": version + }) + + +@telo.route("/_telodendria/admin/v1/tokens/", methods=["GET", "DELETE"]) +@telo.route("/_telodendria/admin/v1/tokens", methods=["GET", "POST"]) +async def tokens(name=None): + if request.method == "DELETE": + return jsonify({}) + + return jsonify({ + "name": "vona", + "created_by": "vona", + "created_on": config.the_funny_number, + "expires_on": config.the_funny_number, + "used": config.the_funny_number, + "uses": config.the_funny_number + }) diff --git a/vona/globals/__init__.py b/vona/globals/__init__.py index fa50899..112c1ad 100644 --- a/vona/globals/__init__.py +++ b/vona/globals/__init__.py @@ -9,7 +9,7 @@ import copy import json import re -version = "1.4.2" +version = "1.4.3" http_client = httpx.Client(headers={"User-Agent": f"Vona/{version}"})