Only permit the v1 send_join endpoint for v1/v2 rooms
This commit is contained in:
@@ -10,6 +10,7 @@ from flask import (
|
|||||||
Response,
|
Response,
|
||||||
request,
|
request,
|
||||||
Blueprint,
|
Blueprint,
|
||||||
|
abort,
|
||||||
)
|
)
|
||||||
|
|
||||||
server = Blueprint("federation", __name__)
|
server = Blueprint("federation", __name__)
|
||||||
@@ -37,6 +38,7 @@ async def version():
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@server.route("/_matrix/key/v2/server")
|
@server.route("/_matrix/key/v2/server")
|
||||||
async def keys():
|
async def keys():
|
||||||
return jsonify(globals.sign_json({
|
return jsonify(globals.sign_json({
|
||||||
@@ -50,6 +52,7 @@ async def keys():
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
@server.route("/_matrix/federation/v1/query/directory")
|
@server.route("/_matrix/federation/v1/query/directory")
|
||||||
async def room_query():
|
async def room_query():
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@@ -57,6 +60,7 @@ async def room_query():
|
|||||||
"servers": [config.server_name]
|
"servers": [config.server_name]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@server.route("/_matrix/federation/v1/media/download/<media_id>")
|
@server.route("/_matrix/federation/v1/media/download/<media_id>")
|
||||||
async def download_media(media_id):
|
async def download_media(media_id):
|
||||||
# Auth media requires this to be
|
# Auth media requires this to be
|
||||||
@@ -80,6 +84,7 @@ async def download_media(media_id):
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@server.route("/_matrix/federation/v1/media/thumbnail/<media_id>")
|
@server.route("/_matrix/federation/v1/media/thumbnail/<media_id>")
|
||||||
async def thumbnail_media(media_id):
|
async def thumbnail_media(media_id):
|
||||||
return jsonify({
|
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"])
|
@server.route("/_matrix/federation/v2/send_join/<room>/<path:eventId>", methods=["PUT"])
|
||||||
async def send_join_v2(room, eventId):
|
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))
|
return jsonify(send_join(request, room))
|
||||||
|
|
||||||
|
|
||||||
@@ -184,7 +193,6 @@ async def room_directory():
|
|||||||
return jsonify(globals.room_dir)
|
return jsonify(globals.room_dir)
|
||||||
|
|
||||||
|
|
||||||
# https://spec.matrix.org/latest/server-server-api/#transactions
|
|
||||||
@server.route("/_matrix/federation/v1/send/<txnId>", methods=["PUT"])
|
@server.route("/_matrix/federation/v1/send/<txnId>", methods=["PUT"])
|
||||||
async def receive_txn(txnId):
|
async def receive_txn(txnId):
|
||||||
# We will need to implement a way to store every
|
# We will need to implement a way to store every
|
||||||
|
|||||||
Reference in New Issue
Block a user