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