Only permit the v1 send_join endpoint for v1/v2 rooms

This commit is contained in:
2025-11-05 12:30:51 -05:00
parent 2212453a96
commit a5b34fb4a8

View File

@@ -10,6 +10,7 @@ from flask import (
Response,
request,
Blueprint,
abort,
)
server = Blueprint("federation", __name__)
@@ -37,6 +38,7 @@ async def version():
}
})
@server.route("/_matrix/key/v2/server")
async def keys():
return jsonify(globals.sign_json({
@@ -50,6 +52,7 @@ async def keys():
}
}))
@server.route("/_matrix/federation/v1/query/directory")
async def room_query():
return jsonify({
@@ -57,6 +60,7 @@ async def room_query():
"servers": [config.server_name]
})
@server.route("/_matrix/federation/v1/media/download/<media_id>")
async def download_media(media_id):
# Auth media requires this to be
@@ -80,6 +84,7 @@ async def download_media(media_id):
return response
@server.route("/_matrix/federation/v1/media/thumbnail/<media_id>")
async def thumbnail_media(media_id):
return jsonify({
@@ -101,6 +106,10 @@ async def send_join_v1(room, eventId):
@server.route("/_matrix/federation/v2/send_join/<room>/<path:eventId>", methods=["PUT"])
async def send_join_v2(room, eventId):
if globals.room_version_from_id(room) in ["1", "2"]:
# Spec says to fallback to the v1 send_join endpoint if this fails
abort(404)
return jsonify(send_join(request, room))
@@ -184,7 +193,6 @@ async def room_directory():
return jsonify(globals.room_dir)
# https://spec.matrix.org/latest/server-server-api/#transactions
@server.route("/_matrix/federation/v1/send/<txnId>", methods=["PUT"])
async def receive_txn(txnId):
# We will need to implement a way to store every