2019-08-22 12:47:52 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-04-29 11:34:31 +01:00
|
|
|
"github.com/matrix-org/dendrite/federationsender/types"
|
2020-05-21 14:40:13 +01:00
|
|
|
internalHTTP "github.com/matrix-org/dendrite/internal/http"
|
2019-08-22 12:47:52 +01:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
|
|
|
|
"github.com/opentracing/opentracing-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FederationSenderQueryJoinedHostsInRoomPath is the HTTP path for the QueryJoinedHostsInRoom API.
|
2020-05-22 14:14:39 +01:00
|
|
|
const FederationSenderQueryJoinedHostsInRoomPath = "/federationsender/queryJoinedHostsInRoom"
|
2019-08-22 12:47:52 +01:00
|
|
|
|
|
|
|
// FederationSenderQueryJoinedHostServerNamesInRoomPath is the HTTP path for the QueryJoinedHostServerNamesInRoom API.
|
2020-05-22 14:14:39 +01:00
|
|
|
const FederationSenderQueryJoinedHostServerNamesInRoomPath = "/federationsender/queryJoinedHostServerNamesInRoom"
|
2019-08-22 12:47:52 +01:00
|
|
|
|
2020-04-29 11:34:31 +01:00
|
|
|
// QueryJoinedHostsInRoomRequest is a request to QueryJoinedHostsInRoom
|
|
|
|
type QueryJoinedHostsInRoomRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
2019-08-22 12:47:52 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 11:34:31 +01:00
|
|
|
// QueryJoinedHostsInRoomResponse is a response to QueryJoinedHostsInRoom
|
|
|
|
type QueryJoinedHostsInRoomResponse struct {
|
|
|
|
JoinedHosts []types.JoinedHost `json:"joined_hosts"`
|
2019-08-22 12:47:52 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 11:34:31 +01:00
|
|
|
// QueryJoinedHostsInRoom implements FederationSenderInternalAPI
|
|
|
|
func (h *httpFederationSenderInternalAPI) QueryJoinedHostsInRoom(
|
2019-08-22 12:47:52 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryJoinedHostsInRoomRequest,
|
|
|
|
response *QueryJoinedHostsInRoomResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryJoinedHostsInRoom")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.federationSenderURL + FederationSenderQueryJoinedHostsInRoomPath
|
2020-05-21 14:40:13 +01:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2019-08-22 12:47:52 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 11:34:31 +01:00
|
|
|
// QueryJoinedHostServerNamesRequest is a request to QueryJoinedHostServerNames
|
|
|
|
type QueryJoinedHostServerNamesInRoomRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryJoinedHostServerNamesResponse is a response to QueryJoinedHostServerNames
|
|
|
|
type QueryJoinedHostServerNamesInRoomResponse struct {
|
|
|
|
ServerNames []gomatrixserverlib.ServerName `json:"server_names"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryJoinedHostServerNamesInRoom implements FederationSenderInternalAPI
|
|
|
|
func (h *httpFederationSenderInternalAPI) QueryJoinedHostServerNamesInRoom(
|
2019-08-22 12:47:52 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryJoinedHostServerNamesInRoomRequest,
|
|
|
|
response *QueryJoinedHostServerNamesInRoomResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryJoinedHostServerNamesInRoom")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.federationSenderURL + FederationSenderQueryJoinedHostServerNamesInRoomPath
|
2020-05-21 14:40:13 +01:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2019-08-22 12:47:52 +01:00
|
|
|
}
|