from vona.config import the_funny_number import asyncio from flask import ( Blueprint, jsonify, ) apps = Blueprint("appservice", __name__) # This implements both being a homeserver and # being an appservice. Why? Maximum carnage. # Endpoints invoked by the homeserver are put # lower than ones invoked by the appservice. @apps.route("/_matrix/client/v1/appservice//ping", methods=["POST"]) async def homeserver_ping(app): # Sleeping here makes it more realistic await asyncio.sleep(the_funny_number / 1000) return jsonify({"duration_ms": the_funny_number}) @apps.route("/_matrix/client/v3/directory/list/appservice//", methods=["PUT"]) @apps.route("/_matrix/app/v1/ping", methods=["POST"]) @apps.route("/_matrix/app/v1/transactions/", methods=["PUT"]) @apps.route("/_matrix/app/v1/thirdparty/protocol/") @apps.route("/_matrix/app/v1/rooms/") @apps.route("/_matrix/app/v1/users/") async def empty_dict(**kwargs): return jsonify({}) @apps.route("/_matrix/app/v1/thirdparty/location") @apps.route("/_matrix/app/v1/thirdparty/location/") @apps.route("/_matrix/app/v1/thirdparty/user") @apps.route("/_matrix/app/v1/thirdparty/user/") async def empty_array(**kwargs): return jsonify([])