mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-13 09:53:10 -06:00
Fix linting errors and use of httpReq.FormValue
Signed-off-by: Ross Schulman <ross@rbs.io>
This commit is contained in:
parent
febc3126af
commit
4fd5aaf93d
|
|
@ -16,6 +16,7 @@ package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
"github.com/matrix-org/dendrite/clientapi/httputil"
|
"github.com/matrix-org/dendrite/clientapi/httputil"
|
||||||
|
|
@ -26,16 +27,15 @@ import (
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RoomAliasToID converts the queried alias into a room ID and returns it
|
||||||
func RoomAliasToID (
|
func RoomAliasToID (
|
||||||
httpReq *http.Request,
|
httpReq *http.Request,
|
||||||
federation *gomatrixserverlib.FederationClient,
|
federation *gomatrixserverlib.FederationClient,
|
||||||
request *gomatrixserverlib.FederationRequest,
|
|
||||||
cfg config.Dendrite,
|
cfg config.Dendrite,
|
||||||
aliasAPI api.RoomserverAliasAPI,
|
aliasAPI api.RoomserverAliasAPI,
|
||||||
query api.RoomserverQueryAPI,
|
|
||||||
roomAlias string,
|
roomAlias string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
_, domain, err := gomatrixserverlib.SplitID('#', roomAlias)
|
_, domain, err := gomatrixserverlib.SplitID('#', httpReq.FormValue("alias"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: 400,
|
Code: 400,
|
||||||
|
|
@ -52,7 +52,7 @@ var resp gomatrixserverlib.RespDirectory
|
||||||
return httputil.LogThenError(httpReq, err)
|
return httputil.LogThenError(httpReq, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(queryRes.RoomID) > 0 {
|
if (queryRes.RoomID == "") {
|
||||||
// TODO: List servers that are aware of this room alias
|
// TODO: List servers that are aware of this room alias
|
||||||
resp = gomatrixserverlib.RespDirectory{
|
resp = gomatrixserverlib.RespDirectory{
|
||||||
RoomID: queryRes.RoomID,
|
RoomID: queryRes.RoomID,
|
||||||
|
|
@ -62,7 +62,7 @@ var resp gomatrixserverlib.RespDirectory
|
||||||
// If the response doesn't contain a non-empty string, return an error
|
// If the response doesn't contain a non-empty string, return an error
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: 404,
|
Code: 404,
|
||||||
JSON: jsonerror.NotFound("Room alias " + roomAlias + " not found."),
|
JSON: jsonerror.NotFound(fmt.Sprintf("Room alias %s not found", roomAlias)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -86,5 +86,5 @@ var resp gomatrixserverlib.RespDirectory
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: 200,
|
Code: 200,
|
||||||
JSON: resp,
|
JSON: resp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ func Setup(
|
||||||
},
|
},
|
||||||
)).Methods("POST", "OPTIONS")
|
)).Methods("POST", "OPTIONS")
|
||||||
|
|
||||||
v1fedmux.Handle("/exchange_third_party_invite/{roomID}", common.MakeFedAPI(
|
v1fedmux.Handle("/exchange_third_party_invite/{roomID}", common.MakeFedAPI(
|
||||||
"exchange_third_party_invite", cfg.Matrix.ServerName, keys,
|
"exchange_third_party_invite", cfg.Matrix.ServerName, keys,
|
||||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
||||||
vars := mux.Vars(httpReq)
|
vars := mux.Vars(httpReq)
|
||||||
|
|
@ -94,9 +94,9 @@ func Setup(
|
||||||
httpReq, request, vars["roomID"], query, cfg, federation, producer,
|
httpReq, request, vars["roomID"], query, cfg, federation, producer,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)).Methods("PUT", "OPTIONS")
|
)).Methods("PUT", "OPTIONS")
|
||||||
|
|
||||||
v1fedmux.Handle("/event/{eventID}", common.MakeFedAPI(
|
v1fedmux.Handle("/event/{eventID}", common.MakeFedAPI(
|
||||||
"federation_get_event", cfg.Matrix.ServerName, keys,
|
"federation_get_event", cfg.Matrix.ServerName, keys,
|
||||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
||||||
vars := mux.Vars(httpReq)
|
vars := mux.Vars(httpReq)
|
||||||
|
|
@ -104,22 +104,22 @@ func Setup(
|
||||||
httpReq.Context(), request, cfg, query, time.Now(), keys, vars["eventID"],
|
httpReq.Context(), request, cfg, query, time.Now(), keys, vars["eventID"],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)).Methods("GET")
|
)).Methods("GET")
|
||||||
|
|
||||||
v1fedmux.Handle("/version", common.MakeExternalAPI(
|
v1fedmux.Handle("/version", common.MakeExternalAPI(
|
||||||
"federation_version",
|
"federation_version",
|
||||||
func(httpReq *http.Request) util.JSONResponse {
|
func(httpReq *http.Request) util.JSONResponse {
|
||||||
return Version()
|
return Version()
|
||||||
},
|
},
|
||||||
)).Methods("GET")
|
)).Methods("GET")
|
||||||
|
|
||||||
v1fedmux.Handle("/query/directory/?room_alias={alias}", common.MakeFedAPI(
|
v1fedmux.Handle("/query/directory/?room_alias={alias}", common.MakeFedAPI(
|
||||||
"federation_query_room_alias", cfg.Matrix.ServerName, keys,
|
"federation_query_room_alias", cfg.Matrix.ServerName, keys,
|
||||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
||||||
vars := mux.Vars(httpReq)
|
vars := mux.Vars(httpReq)
|
||||||
return RoomAliasToID(
|
return RoomAliasToID(
|
||||||
httpReq, federation, request, cfg, aliasAPI, query, vars["alias"],
|
httpReq, federation, cfg, aliasAPI, vars["alias"],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)).Methods("Get")
|
)).Methods("Get")
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue