From 6e4426a9e63233f9821a4d2382bfed145244183f Mon Sep 17 00:00:00 2001 From: Till <2353100+S7evinK@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:12:44 +0200 Subject: [PATCH] Handle authed media endpoint (#731) --- federation/handle.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/federation/handle.go b/federation/handle.go index 18b45068..772e3d44 100644 --- a/federation/handle.go +++ b/federation/handle.go @@ -471,6 +471,7 @@ func HandleKeyRequests() func(*Server) { func HandleMediaRequests(mediaIds map[string]func(w http.ResponseWriter)) func(*Server) { return func(srv *Server) { mediamux := srv.mux.PathPrefix("/_matrix/media").Subrouter() + mediamuxAuthenticated := srv.mux.PathPrefix("/_matrix/federation/v1/media").Subrouter() downloadFn := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { vars := mux.Vars(req) @@ -497,6 +498,9 @@ func HandleMediaRequests(mediaIds map[string]func(w http.ResponseWriter)) func(* mediamux.Handle("/r0/download/{origin}/{mediaId}", downloadFn).Methods("GET") mediamux.Handle("/v1/download/{origin}/{mediaId}", downloadFn).Methods("GET") mediamux.Handle("/v3/download/{origin}/{mediaId}", downloadFn).Methods("GET") + + // Also handle authenticated media requests + mediamuxAuthenticated.Handle("/download/{mediaId}", downloadFn).Methods("GET") } }