Federation: Improve /query/directory endpoint (#525)
This commit is contained in:
parent
b11591fdd1
commit
e05a31f4c2
2 changed files with 4 additions and 4 deletions
|
@ -34,7 +34,7 @@ func RoomAliasToID(
|
|||
cfg config.Dendrite,
|
||||
aliasAPI api.RoomserverAliasAPI,
|
||||
) util.JSONResponse {
|
||||
roomAlias := httpReq.FormValue("alias")
|
||||
roomAlias := httpReq.FormValue("room_alias")
|
||||
if roomAlias == "" {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
@ -58,14 +58,14 @@ func RoomAliasToID(
|
|||
return httputil.LogThenError(httpReq, err)
|
||||
}
|
||||
|
||||
if queryRes.RoomID == "" {
|
||||
if queryRes.RoomID != "" {
|
||||
// TODO: List servers that are aware of this room alias
|
||||
resp = gomatrixserverlib.RespDirectory{
|
||||
RoomID: queryRes.RoomID,
|
||||
Servers: []gomatrixserverlib.ServerName{},
|
||||
}
|
||||
} else {
|
||||
// If the response doesn't contain a non-empty string, return an error
|
||||
// If no alias was found, return an error
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusNotFound,
|
||||
JSON: jsonerror.NotFound(fmt.Sprintf("Room alias %s not found", roomAlias)),
|
||||
|
|
|
@ -127,7 +127,7 @@ func Setup(
|
|||
},
|
||||
)).Methods(http.MethodGet)
|
||||
|
||||
v1fedmux.Handle("/query/directory/", common.MakeFedAPI(
|
||||
v1fedmux.Handle("/query/directory", common.MakeFedAPI(
|
||||
"federation_query_room_alias", cfg.Matrix.ServerName, keys,
|
||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
||||
return RoomAliasToID(
|
||||
|
|
Loading…
Reference in a new issue