2020-06-04 15:43:07 +01:00
|
|
|
package inthttp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"net/http"
|
|
|
|
|
2022-08-11 17:23:35 +01:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
|
2020-12-18 13:33:28 +00:00
|
|
|
asAPI "github.com/matrix-org/dendrite/appservice/api"
|
2021-11-24 10:45:23 +00:00
|
|
|
fsInputAPI "github.com/matrix-org/dendrite/federationapi/api"
|
2020-06-04 15:43:07 +01:00
|
|
|
"github.com/matrix-org/dendrite/internal/caching"
|
2020-06-12 14:55:57 +01:00
|
|
|
"github.com/matrix-org/dendrite/internal/httputil"
|
2020-06-04 15:43:07 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/api"
|
2022-02-18 15:05:03 +00:00
|
|
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
2020-06-04 15:43:07 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Alias operations
|
|
|
|
RoomserverSetRoomAliasPath = "/roomserver/setRoomAlias"
|
|
|
|
RoomserverGetRoomIDForAliasPath = "/roomserver/GetRoomIDForAlias"
|
|
|
|
RoomserverGetAliasesForRoomIDPath = "/roomserver/GetAliasesForRoomID"
|
|
|
|
RoomserverGetCreatorIDForAliasPath = "/roomserver/GetCreatorIDForAlias"
|
|
|
|
RoomserverRemoveRoomAliasPath = "/roomserver/removeRoomAlias"
|
|
|
|
|
|
|
|
// Input operations
|
|
|
|
RoomserverInputRoomEventsPath = "/roomserver/inputRoomEvents"
|
|
|
|
|
|
|
|
// Perform operations
|
2022-04-28 16:02:30 +01:00
|
|
|
RoomserverPerformInvitePath = "/roomserver/performInvite"
|
|
|
|
RoomserverPerformPeekPath = "/roomserver/performPeek"
|
|
|
|
RoomserverPerformUnpeekPath = "/roomserver/performUnpeek"
|
|
|
|
RoomserverPerformRoomUpgradePath = "/roomserver/performRoomUpgrade"
|
|
|
|
RoomserverPerformJoinPath = "/roomserver/performJoin"
|
|
|
|
RoomserverPerformLeavePath = "/roomserver/performLeave"
|
|
|
|
RoomserverPerformBackfillPath = "/roomserver/performBackfill"
|
|
|
|
RoomserverPerformPublishPath = "/roomserver/performPublish"
|
|
|
|
RoomserverPerformInboundPeekPath = "/roomserver/performInboundPeek"
|
|
|
|
RoomserverPerformForgetPath = "/roomserver/performForget"
|
|
|
|
RoomserverPerformAdminEvacuateRoomPath = "/roomserver/performAdminEvacuateRoom"
|
2022-06-29 15:29:39 +01:00
|
|
|
RoomserverPerformAdminEvacuateUserPath = "/roomserver/performAdminEvacuateUser"
|
2020-06-04 15:43:07 +01:00
|
|
|
|
|
|
|
// Query operations
|
|
|
|
RoomserverQueryLatestEventsAndStatePath = "/roomserver/queryLatestEventsAndState"
|
|
|
|
RoomserverQueryStateAfterEventsPath = "/roomserver/queryStateAfterEvents"
|
|
|
|
RoomserverQueryEventsByIDPath = "/roomserver/queryEventsByID"
|
|
|
|
RoomserverQueryMembershipForUserPath = "/roomserver/queryMembershipForUser"
|
|
|
|
RoomserverQueryMembershipsForRoomPath = "/roomserver/queryMembershipsForRoom"
|
2020-09-24 16:18:13 +01:00
|
|
|
RoomserverQueryServerJoinedToRoomPath = "/roomserver/queryServerJoinedToRoomPath"
|
2020-06-04 15:43:07 +01:00
|
|
|
RoomserverQueryServerAllowedToSeeEventPath = "/roomserver/queryServerAllowedToSeeEvent"
|
|
|
|
RoomserverQueryMissingEventsPath = "/roomserver/queryMissingEvents"
|
|
|
|
RoomserverQueryStateAndAuthChainPath = "/roomserver/queryStateAndAuthChain"
|
|
|
|
RoomserverQueryRoomVersionCapabilitiesPath = "/roomserver/queryRoomVersionCapabilities"
|
|
|
|
RoomserverQueryRoomVersionForRoomPath = "/roomserver/queryRoomVersionForRoom"
|
2020-07-02 15:41:18 +01:00
|
|
|
RoomserverQueryPublishedRoomsPath = "/roomserver/queryPublishedRooms"
|
2020-09-03 17:20:54 +01:00
|
|
|
RoomserverQueryCurrentStatePath = "/roomserver/queryCurrentState"
|
|
|
|
RoomserverQueryRoomsForUserPath = "/roomserver/queryRoomsForUser"
|
|
|
|
RoomserverQueryBulkStateContentPath = "/roomserver/queryBulkStateContent"
|
|
|
|
RoomserverQuerySharedUsersPath = "/roomserver/querySharedUsers"
|
|
|
|
RoomserverQueryKnownUsersPath = "/roomserver/queryKnownUsers"
|
|
|
|
RoomserverQueryServerBannedFromRoomPath = "/roomserver/queryServerBannedFromRoom"
|
2020-12-04 14:11:01 +00:00
|
|
|
RoomserverQueryAuthChainPath = "/roomserver/queryAuthChain"
|
2022-05-25 10:05:30 +01:00
|
|
|
RoomserverQueryRestrictedJoinAllowed = "/roomserver/queryRestrictedJoinAllowed"
|
2022-08-11 17:23:35 +01:00
|
|
|
RoomserverQueryMembershipAtEventPath = "/roomserver/queryMembershipAtEvent"
|
2020-06-04 15:43:07 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type httpRoomserverInternalAPI struct {
|
2020-06-05 16:42:01 +01:00
|
|
|
roomserverURL string
|
|
|
|
httpClient *http.Client
|
|
|
|
cache caching.RoomVersionCache
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewRoomserverClient creates a RoomserverInputAPI implemented by talking to a HTTP POST API.
|
|
|
|
// If httpClient is nil an error is returned
|
|
|
|
func NewRoomserverClient(
|
|
|
|
roomserverURL string,
|
|
|
|
httpClient *http.Client,
|
2020-06-05 16:42:01 +01:00
|
|
|
cache caching.RoomVersionCache,
|
2020-06-04 15:43:07 +01:00
|
|
|
) (api.RoomserverInternalAPI, error) {
|
|
|
|
if httpClient == nil {
|
|
|
|
return nil, errors.New("NewRoomserverInternalAPIHTTP: httpClient is <nil>")
|
|
|
|
}
|
|
|
|
return &httpRoomserverInternalAPI{
|
2020-06-05 16:42:01 +01:00
|
|
|
roomserverURL: roomserverURL,
|
|
|
|
httpClient: httpClient,
|
|
|
|
cache: cache,
|
2020-06-04 15:43:07 +01:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
// SetFederationInputAPI no-ops in HTTP client mode as there is no chicken/egg scenario
|
2022-05-05 19:30:38 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) SetFederationAPI(fsAPI fsInputAPI.RoomserverFederationAPI, keyRing *gomatrixserverlib.KeyRing) {
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
2020-12-18 13:33:28 +00:00
|
|
|
// SetAppserviceAPI no-ops in HTTP client mode as there is no chicken/egg scenario
|
2022-05-06 12:39:26 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) SetAppserviceAPI(asAPI asAPI.AppServiceInternalAPI) {
|
2020-12-18 13:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-02-18 15:05:03 +00:00
|
|
|
// SetUserAPI no-ops in HTTP client mode as there is no chicken/egg scenario
|
2022-05-06 12:39:26 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) SetUserAPI(userAPI userapi.RoomserverUserAPI) {
|
2022-02-18 15:05:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 15:43:07 +01:00
|
|
|
// SetRoomAlias implements RoomserverAliasAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) SetRoomAlias(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.SetRoomAliasRequest,
|
|
|
|
response *api.SetRoomAliasResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"SetRoomAlias", h.roomserverURL+RoomserverSetRoomAliasPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetRoomIDForAlias implements RoomserverAliasAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) GetRoomIDForAlias(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.GetRoomIDForAliasRequest,
|
|
|
|
response *api.GetRoomIDForAliasResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"GetRoomIDForAlias", h.roomserverURL+RoomserverGetRoomIDForAliasPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetAliasesForRoomID implements RoomserverAliasAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) GetAliasesForRoomID(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.GetAliasesForRoomIDRequest,
|
|
|
|
response *api.GetAliasesForRoomIDResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"GetAliasesForRoomID", h.roomserverURL+RoomserverGetAliasesForRoomIDPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveRoomAlias implements RoomserverAliasAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) RemoveRoomAlias(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.RemoveRoomAliasRequest,
|
|
|
|
response *api.RemoveRoomAliasResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"RemoveRoomAlias", h.roomserverURL+RoomserverRemoveRoomAliasPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// InputRoomEvents implements RoomserverInputAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) InputRoomEvents(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.InputRoomEventsRequest,
|
|
|
|
response *api.InputRoomEventsResponse,
|
2022-08-11 15:29:33 +01:00
|
|
|
) error {
|
|
|
|
if err := httputil.CallInternalRPCAPI(
|
|
|
|
"InputRoomEvents", h.roomserverURL+RoomserverInputRoomEventsPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
); err != nil {
|
2020-09-16 13:00:52 +01:00
|
|
|
response.ErrMsg = err.Error()
|
|
|
|
}
|
2022-08-11 15:29:33 +01:00
|
|
|
return nil
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
2020-06-24 15:06:14 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformInvite(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformInviteRequest,
|
|
|
|
response *api.PerformInviteResponse,
|
2020-08-17 11:40:49 +01:00
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformInvite", h.roomserverURL+RoomserverPerformInvitePath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-24 15:06:14 +01:00
|
|
|
}
|
|
|
|
|
2020-06-04 15:43:07 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformJoin(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformJoinRequest,
|
|
|
|
response *api.PerformJoinResponse,
|
2022-08-11 15:29:33 +01:00
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformJoin", h.roomserverURL+RoomserverPerformJoinPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
2020-09-10 14:39:18 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformPeek(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformPeekRequest,
|
|
|
|
response *api.PerformPeekResponse,
|
2022-08-11 15:29:33 +01:00
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformPeek", h.roomserverURL+RoomserverPerformPeekPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-10 14:39:18 +01:00
|
|
|
}
|
|
|
|
|
2021-01-22 14:55:08 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformInboundPeek(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformInboundPeekRequest,
|
|
|
|
response *api.PerformInboundPeekResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformInboundPeek", h.roomserverURL+RoomserverPerformInboundPeekPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2021-01-22 14:55:08 +00:00
|
|
|
}
|
|
|
|
|
2020-12-03 11:11:46 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformUnpeek(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformUnpeekRequest,
|
|
|
|
response *api.PerformUnpeekResponse,
|
2022-08-11 15:29:33 +01:00
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformUnpeek", h.roomserverURL+RoomserverPerformUnpeekPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-12-03 11:11:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 10:04:08 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformRoomUpgrade(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformRoomUpgradeRequest,
|
|
|
|
response *api.PerformRoomUpgradeResponse,
|
2022-08-11 15:29:33 +01:00
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformRoomUpgrade", h.roomserverURL+RoomserverPerformRoomUpgradePath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2022-04-05 10:04:08 +01:00
|
|
|
}
|
|
|
|
|
2020-06-04 15:43:07 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformLeave(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformLeaveRequest,
|
|
|
|
response *api.PerformLeaveResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformLeave", h.roomserverURL+RoomserverPerformLeavePath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
2020-07-02 15:41:18 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformPublish(
|
|
|
|
ctx context.Context,
|
2022-08-11 15:29:33 +01:00
|
|
|
request *api.PerformPublishRequest,
|
|
|
|
response *api.PerformPublishResponse,
|
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformPublish", h.roomserverURL+RoomserverPerformPublishPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-07-02 15:41:18 +01:00
|
|
|
}
|
|
|
|
|
2022-04-28 16:02:30 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformAdminEvacuateRoom(
|
|
|
|
ctx context.Context,
|
2022-08-11 15:29:33 +01:00
|
|
|
request *api.PerformAdminEvacuateRoomRequest,
|
|
|
|
response *api.PerformAdminEvacuateRoomResponse,
|
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformAdminEvacuateRoom", h.roomserverURL+RoomserverPerformAdminEvacuateRoomPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2022-06-29 15:29:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) PerformAdminEvacuateUser(
|
|
|
|
ctx context.Context,
|
2022-08-11 15:29:33 +01:00
|
|
|
request *api.PerformAdminEvacuateUserRequest,
|
|
|
|
response *api.PerformAdminEvacuateUserResponse,
|
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformAdminEvacuateUser", h.roomserverURL+RoomserverPerformAdminEvacuateUserPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2022-04-28 16:02:30 +01:00
|
|
|
}
|
|
|
|
|
2020-06-04 15:43:07 +01:00
|
|
|
// QueryLatestEventsAndState implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryLatestEventsAndState(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryLatestEventsAndStateRequest,
|
|
|
|
response *api.QueryLatestEventsAndStateResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryLatestEventsAndState", h.roomserverURL+RoomserverQueryLatestEventsAndStatePath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryStateAfterEvents implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryStateAfterEvents(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryStateAfterEventsRequest,
|
|
|
|
response *api.QueryStateAfterEventsResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryStateAfterEvents", h.roomserverURL+RoomserverQueryStateAfterEventsPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryEventsByID implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryEventsByID(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryEventsByIDRequest,
|
|
|
|
response *api.QueryEventsByIDResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryEventsByID", h.roomserverURL+RoomserverQueryEventsByIDPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
2020-07-02 15:41:18 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryPublishedRooms(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryPublishedRoomsRequest,
|
|
|
|
response *api.QueryPublishedRoomsResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryPublishedRooms", h.roomserverURL+RoomserverQueryPublishedRoomsPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-07-02 15:41:18 +01:00
|
|
|
}
|
|
|
|
|
2020-06-04 15:43:07 +01:00
|
|
|
// QueryMembershipForUser implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryMembershipForUser(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryMembershipForUserRequest,
|
|
|
|
response *api.QueryMembershipForUserResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryMembershipForUser", h.roomserverURL+RoomserverQueryMembershipForUserPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryMembershipsForRoom implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryMembershipsForRoom(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryMembershipsForRoomRequest,
|
|
|
|
response *api.QueryMembershipsForRoomResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryMembershipsForRoom", h.roomserverURL+RoomserverQueryMembershipsForRoomPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
2020-09-24 16:18:13 +01:00
|
|
|
// QueryMembershipsForRoom implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryServerJoinedToRoom(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryServerJoinedToRoomRequest,
|
|
|
|
response *api.QueryServerJoinedToRoomResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryServerJoinedToRoom", h.roomserverURL+RoomserverQueryServerJoinedToRoomPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-24 16:18:13 +01:00
|
|
|
}
|
|
|
|
|
2020-06-04 15:43:07 +01:00
|
|
|
// QueryServerAllowedToSeeEvent implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryServerAllowedToSeeEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryServerAllowedToSeeEventRequest,
|
|
|
|
response *api.QueryServerAllowedToSeeEventResponse,
|
|
|
|
) (err error) {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryServerAllowedToSeeEvent", h.roomserverURL+RoomserverQueryServerAllowedToSeeEventPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryMissingEvents implements RoomServerQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryMissingEvents(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryMissingEventsRequest,
|
|
|
|
response *api.QueryMissingEventsResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryMissingEvents", h.roomserverURL+RoomserverQueryMissingEventsPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryStateAndAuthChain implements RoomserverQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryStateAndAuthChain(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryStateAndAuthChainRequest,
|
|
|
|
response *api.QueryStateAndAuthChainResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryStateAndAuthChain", h.roomserverURL+RoomserverQueryStateAndAuthChainPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
2020-06-11 19:50:40 +01:00
|
|
|
// PerformBackfill implements RoomServerQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) PerformBackfill(
|
2020-06-04 15:43:07 +01:00
|
|
|
ctx context.Context,
|
2020-06-11 19:50:40 +01:00
|
|
|
request *api.PerformBackfillRequest,
|
|
|
|
response *api.PerformBackfillResponse,
|
2020-06-04 15:43:07 +01:00
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformBackfill", h.roomserverURL+RoomserverPerformBackfillPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryRoomVersionCapabilities implements RoomServerQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryRoomVersionCapabilities(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryRoomVersionCapabilitiesRequest,
|
|
|
|
response *api.QueryRoomVersionCapabilitiesResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryRoomVersionCapabilities", h.roomserverURL+RoomserverQueryRoomVersionCapabilitiesPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryRoomVersionForRoom implements RoomServerQueryAPI
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryRoomVersionForRoom(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryRoomVersionForRoomRequest,
|
|
|
|
response *api.QueryRoomVersionForRoomResponse,
|
|
|
|
) error {
|
2020-06-05 16:42:01 +01:00
|
|
|
if roomVersion, ok := h.cache.GetRoomVersion(request.RoomID); ok {
|
2020-06-04 15:43:07 +01:00
|
|
|
response.RoomVersion = roomVersion
|
|
|
|
return nil
|
|
|
|
}
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryRoomVersionForRoom", h.roomserverURL+RoomserverQueryRoomVersionForRoomPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-06-04 15:43:07 +01:00
|
|
|
}
|
2020-09-03 17:20:54 +01:00
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryCurrentState(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryCurrentStateRequest,
|
|
|
|
response *api.QueryCurrentStateResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryCurrentState", h.roomserverURL+RoomserverQueryCurrentStatePath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-03 17:20:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryRoomsForUser(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryRoomsForUserRequest,
|
|
|
|
response *api.QueryRoomsForUserResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryRoomsForUser", h.roomserverURL+RoomserverQueryRoomsForUserPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-03 17:20:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryBulkStateContent(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryBulkStateContentRequest,
|
|
|
|
response *api.QueryBulkStateContentResponse,
|
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryBulkStateContent", h.roomserverURL+RoomserverQueryBulkStateContentPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-03 17:20:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) QuerySharedUsers(
|
2022-08-11 15:29:33 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *api.QuerySharedUsersRequest,
|
|
|
|
response *api.QuerySharedUsersResponse,
|
2020-09-03 17:20:54 +01:00
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QuerySharedUsers", h.roomserverURL+RoomserverQuerySharedUsersPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-03 17:20:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryKnownUsers(
|
2022-08-11 15:29:33 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryKnownUsersRequest,
|
|
|
|
response *api.QueryKnownUsersResponse,
|
2020-09-03 17:20:54 +01:00
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryKnownUsers", h.roomserverURL+RoomserverQueryKnownUsersPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-03 17:20:54 +01:00
|
|
|
}
|
|
|
|
|
2020-12-04 14:11:01 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryAuthChain(
|
2022-08-11 15:29:33 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryAuthChainRequest,
|
|
|
|
response *api.QueryAuthChainResponse,
|
2020-12-04 14:11:01 +00:00
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryAuthChain", h.roomserverURL+RoomserverQueryAuthChainPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-12-04 14:11:01 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 17:20:54 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryServerBannedFromRoom(
|
2022-08-11 15:29:33 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryServerBannedFromRoomRequest,
|
|
|
|
response *api.QueryServerBannedFromRoomResponse,
|
2020-09-03 17:20:54 +01:00
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryServerBannedFromRoom", h.roomserverURL+RoomserverQueryServerBannedFromRoomPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-09-03 17:20:54 +01:00
|
|
|
}
|
2020-11-05 10:19:23 +00:00
|
|
|
|
2022-05-25 10:05:30 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryRestrictedJoinAllowed(
|
2022-08-11 15:29:33 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryRestrictedJoinAllowedRequest,
|
|
|
|
response *api.QueryRestrictedJoinAllowedResponse,
|
2022-05-25 10:05:30 +01:00
|
|
|
) error {
|
2022-08-11 15:29:33 +01:00
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryRestrictedJoinAllowed", h.roomserverURL+RoomserverQueryRestrictedJoinAllowed,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2022-05-25 10:05:30 +01:00
|
|
|
}
|
|
|
|
|
2022-08-11 15:29:33 +01:00
|
|
|
func (h *httpRoomserverInternalAPI) PerformForget(
|
|
|
|
ctx context.Context,
|
|
|
|
request *api.PerformForgetRequest,
|
|
|
|
response *api.PerformForgetResponse,
|
|
|
|
) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"PerformForget", h.roomserverURL+RoomserverPerformForgetPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
2020-11-05 10:19:23 +00:00
|
|
|
|
|
|
|
}
|
2022-08-11 17:23:35 +01:00
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) QueryMembershipAtEvent(ctx context.Context, request *api.QueryMembershipAtEventRequest, response *api.QueryMembershipAtEventResponse) error {
|
|
|
|
return httputil.CallInternalRPCAPI(
|
|
|
|
"QueryMembershiptAtEvent", h.roomserverURL+RoomserverQueryMembershipAtEventPath,
|
|
|
|
h.httpClient, ctx, request, response,
|
|
|
|
)
|
|
|
|
}
|