60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
import vona.globals as globals
|
|
import vona.config as config
|
|
|
|
from flask import (
|
|
Blueprint,
|
|
jsonify,
|
|
request,
|
|
)
|
|
|
|
admin = Blueprint("admin", __name__)
|
|
|
|
# This implements misc standard admin APIs.
|
|
|
|
|
|
@admin.route("/_matrix/client/v3/admin/whois/<user>")
|
|
@admin.route("/_matrix/client/r0/admin/whois/<user>")
|
|
async def whois(user):
|
|
if user.startswith("@"):
|
|
return jsonify({
|
|
"devices": {
|
|
"": {
|
|
"sessions": [{
|
|
"connections": [{
|
|
"ip": "127.0.0.1",
|
|
"last_seen": config.the_funny_number,
|
|
"user_agent": f"Vona/{globals.version}"
|
|
}]
|
|
}]
|
|
}
|
|
},
|
|
"user_id": user
|
|
})
|
|
|
|
return jsonify({
|
|
"errcode": "M_INVALID_PARAM",
|
|
"error": "Expected UserID string to start with '@'"
|
|
})
|
|
|
|
|
|
@admin.route("/_matrix/client/unstable/uk.timedout.msc4323/admin/suspend/<user>", methods=["GET", "PUT"])
|
|
@admin.route("/_matrix/client/v1/admin/suspend/<user>", methods=["GET", "PUT"])
|
|
async def suspend(user):
|
|
if request.method == "PUT":
|
|
req = request.get_json()
|
|
if req and "suspended" in req:
|
|
return jsonify({"suspended": req["suspended"]})
|
|
|
|
return jsonify({"suspended": True})
|
|
|
|
|
|
@admin.route("/_matrix/client/unstable/uk.timedout.msc4323/admin/lock/<user>", methods=["GET", "PUT"])
|
|
@admin.route("/_matrix/client/v1/admin/lock/<user>", methods=["GET", "PUT"])
|
|
async def lock(user):
|
|
if request.method == "PUT":
|
|
req = request.get_json()
|
|
if req and "locked" in req:
|
|
return jsonify({"locked": req["locked"]})
|
|
|
|
return jsonify({"locked": True})
|