mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 19:03:09 -06:00
Don't send federation queries to ourselves.
Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
parent
a930c0d0b1
commit
ee86685e0b
|
|
@ -71,18 +71,24 @@ func DirectoryRoom(
|
||||||
|
|
||||||
if res.RoomID == "" {
|
if res.RoomID == "" {
|
||||||
// If we don't know it locally, do a federation query.
|
// If we don't know it locally, do a federation query.
|
||||||
fedRes, fedErr := federation.LookupRoomAlias(req.Context(), domain, roomAlias)
|
// But don't send the query to ourselves.
|
||||||
if fedErr != nil {
|
if domain != cfg.Matrix.ServerName {
|
||||||
switch fedErr.(type) {
|
fedRes, fedErr := federation.LookupRoomAlias(req.Context(), domain, roomAlias)
|
||||||
case gomatrix.HTTPError:
|
if fedErr != nil {
|
||||||
// TODO: Return 502 if the remote server errored.
|
switch fedErr.(type) {
|
||||||
// TODO: Return 504 if the remote server timed out.
|
case gomatrix.HTTPError:
|
||||||
return httputil.LogThenError(req, fedErr)
|
// TODO: Return 502 if the remote server errored.
|
||||||
default:
|
// TODO: Return 504 if the remote server timed out.
|
||||||
return httputil.LogThenError(req, fedErr)
|
return httputil.LogThenError(req, fedErr)
|
||||||
|
default:
|
||||||
|
return httputil.LogThenError(req, fedErr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
res.RoomID = fedRes.RoomID
|
||||||
|
res.fillServers(fedRes.Servers)
|
||||||
}
|
}
|
||||||
if fedRes.RoomID == "" {
|
|
||||||
|
if res.RoomID == "" {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusNotFound,
|
Code: http.StatusNotFound,
|
||||||
JSON: jsonerror.NotFound(
|
JSON: jsonerror.NotFound(
|
||||||
|
|
@ -90,9 +96,6 @@ func DirectoryRoom(
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.RoomID = fedRes.RoomID
|
|
||||||
res.fillServers(fedRes.Servers)
|
|
||||||
} else {
|
} else {
|
||||||
joinedHostsReq := federationSenderAPI.QueryJoinedHostServerNamesInRoomRequest{RoomID: res.RoomID}
|
joinedHostsReq := federationSenderAPI.QueryJoinedHostServerNamesInRoomRequest{RoomID: res.RoomID}
|
||||||
var joinedHostsRes federationSenderAPI.QueryJoinedHostServerNamesInRoomResponse
|
var joinedHostsRes federationSenderAPI.QueryJoinedHostServerNamesInRoomResponse
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue