mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 11:41:38 +00:00
Add a route matching the trailing slash on the state event sending route (#182)
* Add a route matching the trailing slash on the state event sending route * Use single route for both cases * Use synapse regexp
This commit is contained in:
parent
877ea5cb62
commit
f607ef29c2
@ -17,6 +17,7 @@ package routing
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
|
||||
@ -93,11 +94,16 @@ func Setup(
|
||||
return writers.SendEvent(req, device, vars["roomID"], vars["eventType"], vars["txnID"], nil, cfg, queryAPI, producer)
|
||||
}),
|
||||
)
|
||||
r0mux.Handle("/rooms/{roomID}/state/{eventType}",
|
||||
r0mux.Handle("/rooms/{roomID}/state/{eventType:[^/]+/?}",
|
||||
common.MakeAuthAPI("send_message", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
|
||||
vars := mux.Vars(req)
|
||||
emptyString := ""
|
||||
return writers.SendEvent(req, device, vars["roomID"], vars["eventType"], vars["txnID"], &emptyString, cfg, queryAPI, producer)
|
||||
eventType := vars["eventType"]
|
||||
// If there's a trailing slash, remove it
|
||||
if strings.HasSuffix(eventType, "/") {
|
||||
eventType = eventType[:len(eventType)-1]
|
||||
}
|
||||
return writers.SendEvent(req, device, vars["roomID"], eventType, vars["txnID"], &emptyString, cfg, queryAPI, producer)
|
||||
}),
|
||||
)
|
||||
r0mux.Handle("/rooms/{roomID}/state/{eventType}/{stateKey}",
|
||||
|
Loading…
Reference in New Issue
Block a user