Skip to content

Commit

Permalink
Handle authed media endpoint (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK committed Jul 30, 2024
1 parent 5d64767 commit 6e4426a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions federation/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}
}

Expand Down

0 comments on commit 6e4426a

Please sign in to comment.