2019-08-22 06:47:52 -05:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-04-29 05:34:31 -05:00
|
|
|
"github.com/matrix-org/dendrite/federationsender/types"
|
2020-05-21 08:40:13 -05:00
|
|
|
internalHTTP "github.com/matrix-org/dendrite/internal/http"
|
2019-08-22 06:47:52 -05:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
|
|
|
|
"github.com/opentracing/opentracing-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FederationSenderQueryJoinedHostsInRoomPath is the HTTP path for the QueryJoinedHostsInRoom API.
|
2020-05-22 08:14:39 -05:00
|
|
|
const FederationSenderQueryJoinedHostsInRoomPath = "/federationsender/queryJoinedHostsInRoom"
|
2019-08-22 06:47:52 -05:00
|
|
|
|
|
|
|
// FederationSenderQueryJoinedHostServerNamesInRoomPath is the HTTP path for the QueryJoinedHostServerNamesInRoom API.
|
2020-05-22 08:14:39 -05:00
|
|
|
const FederationSenderQueryJoinedHostServerNamesInRoomPath = "/federationsender/queryJoinedHostServerNamesInRoom"
|
2019-08-22 06:47:52 -05:00
|
|
|
|
2020-04-29 05:34:31 -05:00
|
|
|
// QueryJoinedHostsInRoomRequest is a request to QueryJoinedHostsInRoom
|
|
|
|
type QueryJoinedHostsInRoomRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
2019-08-22 06:47:52 -05:00
|
|
|
}
|
|
|
|
|
2020-04-29 05:34:31 -05:00
|
|
|
// QueryJoinedHostsInRoomResponse is a response to QueryJoinedHostsInRoom
|
|
|
|
type QueryJoinedHostsInRoomResponse struct {
|
|
|
|
JoinedHosts []types.JoinedHost `json:"joined_hosts"`
|
2019-08-22 06:47:52 -05:00
|
|
|
}
|
|
|
|
|
2020-04-29 05:34:31 -05:00
|
|
|
// QueryJoinedHostsInRoom implements FederationSenderInternalAPI
|
|
|
|
func (h *httpFederationSenderInternalAPI) QueryJoinedHostsInRoom(
|
2019-08-22 06:47:52 -05: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 08:40:13 -05:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2019-08-22 06:47:52 -05:00
|
|
|
}
|
|
|
|
|
2020-04-29 05:34:31 -05: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 06:47:52 -05: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 08:40:13 -05:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2019-08-22 06:47:52 -05:00
|
|
|
}
|