Federation: Improve /query/directory endpoint (#525)

This commit is contained in:
Andrew Morgan 2018-08-07 06:41:50 -07:00 committed by GitHub
parent b11591fdd1
commit e05a31f4c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -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)),

View file

@ -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(