mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-06 13:43:09 -06:00
Define more interfaces
This commit is contained in:
parent
ed3cddeba3
commit
52c38f976a
|
|
@ -51,7 +51,7 @@ func AddPublicRoutes(
|
||||||
keyRing gomatrixserverlib.JSONVerifier,
|
keyRing gomatrixserverlib.JSONVerifier,
|
||||||
rsAPI roomserverAPI.FederationRoomserverAPI,
|
rsAPI roomserverAPI.FederationRoomserverAPI,
|
||||||
federationAPI federationAPI.FederationInternalAPI,
|
federationAPI federationAPI.FederationInternalAPI,
|
||||||
keyAPI keyserverAPI.KeyInternalAPI,
|
keyAPI keyserverAPI.FederationKeyAPI,
|
||||||
servers federationAPI.ServersInRoomProvider,
|
servers federationAPI.ServersInRoomProvider,
|
||||||
) {
|
) {
|
||||||
cfg := &base.Cfg.FederationAPI
|
cfg := &base.Cfg.FederationAPI
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
// GetUserDevices for the given user id
|
// GetUserDevices for the given user id
|
||||||
func GetUserDevices(
|
func GetUserDevices(
|
||||||
req *http.Request,
|
req *http.Request,
|
||||||
keyAPI keyapi.KeyInternalAPI,
|
keyAPI keyapi.FederationKeyAPI,
|
||||||
userID string,
|
userID string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
var res keyapi.QueryDeviceMessagesResponse
|
var res keyapi.QueryDeviceMessagesResponse
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ type queryKeysRequest struct {
|
||||||
// QueryDeviceKeys returns device keys for users on this server.
|
// QueryDeviceKeys returns device keys for users on this server.
|
||||||
// https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-query
|
// https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-query
|
||||||
func QueryDeviceKeys(
|
func QueryDeviceKeys(
|
||||||
httpReq *http.Request, request *gomatrixserverlib.FederationRequest, keyAPI api.KeyInternalAPI, thisServer gomatrixserverlib.ServerName,
|
httpReq *http.Request, request *gomatrixserverlib.FederationRequest, keyAPI api.FederationKeyAPI, thisServer gomatrixserverlib.ServerName,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
var qkr queryKeysRequest
|
var qkr queryKeysRequest
|
||||||
err := json.Unmarshal(request.Content(), &qkr)
|
err := json.Unmarshal(request.Content(), &qkr)
|
||||||
|
|
@ -89,7 +89,7 @@ type claimOTKsRequest struct {
|
||||||
// ClaimOneTimeKeys claims OTKs for users on this server.
|
// ClaimOneTimeKeys claims OTKs for users on this server.
|
||||||
// https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-claim
|
// https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-claim
|
||||||
func ClaimOneTimeKeys(
|
func ClaimOneTimeKeys(
|
||||||
httpReq *http.Request, request *gomatrixserverlib.FederationRequest, keyAPI api.KeyInternalAPI, thisServer gomatrixserverlib.ServerName,
|
httpReq *http.Request, request *gomatrixserverlib.FederationRequest, keyAPI api.FederationKeyAPI, thisServer gomatrixserverlib.ServerName,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
var cor claimOTKsRequest
|
var cor claimOTKsRequest
|
||||||
err := json.Unmarshal(request.Content(), &cor)
|
err := json.Unmarshal(request.Content(), &cor)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ func Setup(
|
||||||
keys gomatrixserverlib.JSONVerifier,
|
keys gomatrixserverlib.JSONVerifier,
|
||||||
federation *gomatrixserverlib.FederationClient,
|
federation *gomatrixserverlib.FederationClient,
|
||||||
userAPI userapi.FederationUserAPI,
|
userAPI userapi.FederationUserAPI,
|
||||||
keyAPI keyserverAPI.KeyInternalAPI,
|
keyAPI keyserverAPI.FederationKeyAPI,
|
||||||
mscCfg *config.MSCs,
|
mscCfg *config.MSCs,
|
||||||
servers federationAPI.ServersInRoomProvider,
|
servers federationAPI.ServersInRoomProvider,
|
||||||
producer *producers.SyncAPIProducer,
|
producer *producers.SyncAPIProducer,
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ func Send(
|
||||||
txnID gomatrixserverlib.TransactionID,
|
txnID gomatrixserverlib.TransactionID,
|
||||||
cfg *config.FederationAPI,
|
cfg *config.FederationAPI,
|
||||||
rsAPI api.FederationRoomserverAPI,
|
rsAPI api.FederationRoomserverAPI,
|
||||||
keyAPI keyapi.KeyInternalAPI,
|
keyAPI keyapi.FederationKeyAPI,
|
||||||
keys gomatrixserverlib.JSONVerifier,
|
keys gomatrixserverlib.JSONVerifier,
|
||||||
federation *gomatrixserverlib.FederationClient,
|
federation *gomatrixserverlib.FederationClient,
|
||||||
mu *internal.MutexByRoom,
|
mu *internal.MutexByRoom,
|
||||||
|
|
@ -183,7 +183,7 @@ func Send(
|
||||||
type txnReq struct {
|
type txnReq struct {
|
||||||
gomatrixserverlib.Transaction
|
gomatrixserverlib.Transaction
|
||||||
rsAPI api.FederationRoomserverAPI
|
rsAPI api.FederationRoomserverAPI
|
||||||
keyAPI keyapi.KeyInternalAPI
|
keyAPI keyapi.FederationKeyAPI
|
||||||
ourServerName gomatrixserverlib.ServerName
|
ourServerName gomatrixserverlib.ServerName
|
||||||
keys gomatrixserverlib.JSONVerifier
|
keys gomatrixserverlib.JSONVerifier
|
||||||
federation txnFederationClient
|
federation txnFederationClient
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
type testRoomserverAPI struct {
|
type testRoomserverAPI struct {
|
||||||
api.FederationRoomserverAPITrace
|
api.RoomserverInternalAPITrace
|
||||||
inputRoomEvents []api.InputRoomEvent
|
inputRoomEvents []api.InputRoomEvent
|
||||||
queryStateAfterEvents func(*api.QueryStateAfterEventsRequest) api.QueryStateAfterEventsResponse
|
queryStateAfterEvents func(*api.QueryStateAfterEventsRequest) api.QueryStateAfterEventsResponse
|
||||||
queryEventsByID func(req *api.QueryEventsByIDRequest) api.QueryEventsByIDResponse
|
queryEventsByID func(req *api.QueryEventsByIDRequest) api.QueryEventsByIDResponse
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,11 @@ import (
|
||||||
type KeyInternalAPI interface {
|
type KeyInternalAPI interface {
|
||||||
SyncKeyAPI
|
SyncKeyAPI
|
||||||
ClientKeyAPI
|
ClientKeyAPI
|
||||||
|
FederationKeyAPI
|
||||||
UserKeyAPI
|
UserKeyAPI
|
||||||
|
|
||||||
// SetUserAPI assigns a user API to query when extracting device names.
|
// SetUserAPI assigns a user API to query when extracting device names.
|
||||||
SetUserAPI(i userapi.UserInternalAPI)
|
SetUserAPI(i userapi.KeyserverUserAPI)
|
||||||
// InputDeviceListUpdate from a federated server EDU
|
|
||||||
InputDeviceListUpdate(ctx context.Context, req *InputDeviceListUpdateRequest, res *InputDeviceListUpdateResponse)
|
|
||||||
|
|
||||||
QueryDeviceMessages(ctx context.Context, req *QueryDeviceMessagesRequest, res *QueryDeviceMessagesResponse)
|
|
||||||
QuerySignatures(ctx context.Context, req *QuerySignaturesRequest, res *QuerySignaturesResponse)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// API functions required by the clientapi
|
// API functions required by the clientapi
|
||||||
|
|
@ -62,6 +58,16 @@ type SyncKeyAPI interface {
|
||||||
QueryOneTimeKeys(ctx context.Context, req *QueryOneTimeKeysRequest, res *QueryOneTimeKeysResponse)
|
QueryOneTimeKeys(ctx context.Context, req *QueryOneTimeKeysRequest, res *QueryOneTimeKeysResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FederationKeyAPI interface {
|
||||||
|
QueryKeys(ctx context.Context, req *QueryKeysRequest, res *QueryKeysResponse)
|
||||||
|
QuerySignatures(ctx context.Context, req *QuerySignaturesRequest, res *QuerySignaturesResponse)
|
||||||
|
QueryDeviceMessages(ctx context.Context, req *QueryDeviceMessagesRequest, res *QueryDeviceMessagesResponse)
|
||||||
|
// InputDeviceListUpdate from a federated server EDU
|
||||||
|
InputDeviceListUpdate(ctx context.Context, req *InputDeviceListUpdateRequest, res *InputDeviceListUpdateResponse)
|
||||||
|
PerformUploadDeviceKeys(ctx context.Context, req *PerformUploadDeviceKeysRequest, res *PerformUploadDeviceKeysResponse)
|
||||||
|
PerformClaimKeys(ctx context.Context, req *PerformClaimKeysRequest, res *PerformClaimKeysResponse)
|
||||||
|
}
|
||||||
|
|
||||||
// KeyError is returned if there was a problem performing/querying the server
|
// KeyError is returned if there was a problem performing/querying the server
|
||||||
type KeyError struct {
|
type KeyError struct {
|
||||||
Err string `json:"error"`
|
Err string `json:"error"`
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@ type KeyInternalAPI struct {
|
||||||
DB storage.Database
|
DB storage.Database
|
||||||
ThisServer gomatrixserverlib.ServerName
|
ThisServer gomatrixserverlib.ServerName
|
||||||
FedClient fedsenderapi.FederationClient
|
FedClient fedsenderapi.FederationClient
|
||||||
UserAPI userapi.UserInternalAPI
|
UserAPI userapi.KeyserverUserAPI
|
||||||
Producer *producers.KeyChange
|
Producer *producers.KeyChange
|
||||||
Updater *DeviceListUpdater
|
Updater *DeviceListUpdater
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *KeyInternalAPI) SetUserAPI(i userapi.UserInternalAPI) {
|
func (a *KeyInternalAPI) SetUserAPI(i userapi.KeyserverUserAPI) {
|
||||||
a.UserAPI = i
|
a.UserAPI = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ type httpKeyInternalAPI struct {
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpKeyInternalAPI) SetUserAPI(i userapi.UserInternalAPI) {
|
func (h *httpKeyInternalAPI) SetUserAPI(i userapi.KeyserverUserAPI) {
|
||||||
// no-op: doesn't need it
|
// no-op: doesn't need it
|
||||||
}
|
}
|
||||||
func (h *httpKeyInternalAPI) InputDeviceListUpdate(
|
func (h *httpKeyInternalAPI) InputDeviceListUpdate(
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ type UserInternalAPI interface {
|
||||||
MediaUserAPI
|
MediaUserAPI
|
||||||
FederationUserAPI
|
FederationUserAPI
|
||||||
RoomserverUserAPI
|
RoomserverUserAPI
|
||||||
|
KeyserverUserAPI
|
||||||
|
|
||||||
QuerySearchProfilesAPI // used by p2p demos
|
QuerySearchProfilesAPI // used by p2p demos
|
||||||
}
|
}
|
||||||
|
|
@ -42,6 +43,11 @@ type AppserviceUserAPI interface {
|
||||||
PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
|
PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type KeyserverUserAPI interface {
|
||||||
|
QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
|
||||||
|
QueryDeviceInfos(ctx context.Context, req *QueryDeviceInfosRequest, res *QueryDeviceInfosResponse) error
|
||||||
|
}
|
||||||
|
|
||||||
type RoomserverUserAPI interface {
|
type RoomserverUserAPI interface {
|
||||||
QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
|
QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue