some Citadel endpoints
This commit is contained in:
@@ -2,10 +2,9 @@ from flask import Blueprint
|
||||
|
||||
custom = Blueprint("custom", __name__)
|
||||
|
||||
# This implements custom endpoints
|
||||
# used by other homeserver
|
||||
# implementations. They do not start
|
||||
# with /_matrix/
|
||||
# This implements non-standard
|
||||
# endpoints created by other
|
||||
# homeserver implementations.
|
||||
|
||||
|
||||
from .hammerhead import hammerhead
|
||||
@@ -13,9 +12,11 @@ from .conduwuit import conduwuit
|
||||
from .dendrite import dendrite
|
||||
from .telodendria import telo
|
||||
from .synapse import synapse
|
||||
from .citadel import citadel
|
||||
|
||||
custom.register_blueprint(hammerhead)
|
||||
custom.register_blueprint(conduwuit)
|
||||
custom.register_blueprint(dendrite)
|
||||
custom.register_blueprint(synapse)
|
||||
custom.register_blueprint(citadel)
|
||||
custom.register_blueprint(telo)
|
||||
|
||||
61
vona/custom/citadel.py
Normal file
61
vona/custom/citadel.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from flask import Blueprint, jsonify, request
|
||||
import vona.config as config
|
||||
import base64
|
||||
import os
|
||||
|
||||
citadel = Blueprint("citadel", __name__)
|
||||
|
||||
# These are endpoints made by Thales Citadel
|
||||
|
||||
# TODO: Add more endpoints, this likely
|
||||
# isn't all of them
|
||||
|
||||
|
||||
@citadel.route("/_matrix/client/r0/citadel/stats/m.news/<event>", methods=["GET", "PUT"])
|
||||
async def news_stats(event):
|
||||
if request.method == "PUT":
|
||||
return jsonify({"success": True})
|
||||
|
||||
return jsonify({
|
||||
"total_clicks": config.the_funny_number,
|
||||
"user_readings": config.the_funny_number
|
||||
})
|
||||
|
||||
|
||||
@citadel.route("/_matrix/client/r0/citadel/rooms/<room>/closeRoom", methods=["POST"])
|
||||
async def close_room(room):
|
||||
store_response = request.json.get("store_response", True)
|
||||
|
||||
operation_id = base64.b64encode(
|
||||
bytes(
|
||||
os.urandom(8).hex(),
|
||||
"utf-8"
|
||||
)
|
||||
).decode("utf-8")[:14]
|
||||
|
||||
|
||||
if store_response:
|
||||
resp = {"operation_id": operation_id}
|
||||
else:
|
||||
resp = {
|
||||
"operation_id": operation_id,
|
||||
"previous_state": {
|
||||
"progress": {
|
||||
"steps": {
|
||||
"step_kick_users": {
|
||||
"status": "complete"
|
||||
},
|
||||
"step_purge_history": {
|
||||
"status": "complete"
|
||||
},
|
||||
"step_purge_media": {
|
||||
"status": "complete"
|
||||
}
|
||||
}
|
||||
},
|
||||
"status": "complete"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return jsonify(resp)
|
||||
Reference in New Issue
Block a user