aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2022-05-05 19:30:38 +0100
committerGitHub <noreply@github.com>2022-05-05 19:30:38 +0100
commit9957752a9d60d4519cc0b7e8b9b40a781240c27d (patch)
tree80de96398e63ea04a334802212f828d983a98b6e
parente4da04e75b4cba1c9afb63b9973444e1da12021b (diff)
Define component interfaces based on consumers (2/2) (#2425)
* convert remaining interfaces * Tidy up the userapi interfaces
-rw-r--r--clientapi/clientapi.go2
-rw-r--r--clientapi/routing/routing.go2
-rw-r--r--clientapi/routing/userdirectory.go2
-rw-r--r--cmd/dendrite-demo-pinecone/users/users.go4
-rw-r--r--federationapi/api/api.go62
-rw-r--r--federationapi/federationapi.go2
-rw-r--r--federationapi/routing/backfill.go2
-rw-r--r--federationapi/routing/eventauth.go2
-rw-r--r--federationapi/routing/events.go6
-rw-r--r--federationapi/routing/invite.go6
-rw-r--r--federationapi/routing/join.go4
-rw-r--r--federationapi/routing/leave.go4
-rw-r--r--federationapi/routing/missingevents.go2
-rw-r--r--federationapi/routing/openid.go2
-rw-r--r--federationapi/routing/peek.go2
-rw-r--r--federationapi/routing/profile.go2
-rw-r--r--federationapi/routing/publicrooms.go6
-rw-r--r--federationapi/routing/query.go2
-rw-r--r--federationapi/routing/routing.go6
-rw-r--r--federationapi/routing/send.go4
-rw-r--r--federationapi/routing/send_test.go2
-rw-r--r--federationapi/routing/state.go6
-rw-r--r--federationapi/routing/threepid.go12
-rw-r--r--keyserver/api/api.go9
-rw-r--r--roomserver/api/api.go80
-rw-r--r--roomserver/api/api_trace.go2
-rw-r--r--roomserver/api/wrapper.go2
-rw-r--r--roomserver/internal/api.go4
-rw-r--r--roomserver/internal/input/input.go2
-rw-r--r--roomserver/internal/input/input_missing.go2
-rw-r--r--roomserver/internal/perform/perform_backfill.go6
-rw-r--r--roomserver/internal/perform/perform_invite.go2
-rw-r--r--roomserver/internal/perform/perform_join.go2
-rw-r--r--roomserver/internal/perform/perform_leave.go2
-rw-r--r--roomserver/internal/perform/perform_peek.go2
-rw-r--r--roomserver/internal/perform/perform_unpeek.go2
-rw-r--r--roomserver/inthttp/client.go2
-rw-r--r--setup/monolith.go2
-rw-r--r--userapi/api/api.go38
-rw-r--r--userapi/consumers/syncapi_streamevent.go6
-rw-r--r--userapi/internal/api.go2
-rw-r--r--userapi/userapi.go4
42 files changed, 153 insertions, 162 deletions
diff --git a/clientapi/clientapi.go b/clientapi/clientapi.go
index 957d082a..ad460908 100644
--- a/clientapi/clientapi.go
+++ b/clientapi/clientapi.go
@@ -38,7 +38,7 @@ func AddPublicRoutes(
transactionsCache *transactions.Cache,
fsAPI federationAPI.ClientFederationAPI,
userAPI userapi.ClientUserAPI,
- userDirectoryProvider userapi.UserDirectoryProvider,
+ userDirectoryProvider userapi.QuerySearchProfilesAPI,
keyAPI keyserverAPI.ClientKeyAPI,
extRoomsProvider api.ExtraPublicRoomsProvider,
) {
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index 6da46707..f9f71ed7 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -53,7 +53,7 @@ func Setup(
rsAPI roomserverAPI.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
userAPI userapi.ClientUserAPI,
- userDirectoryProvider userapi.UserDirectoryProvider,
+ userDirectoryProvider userapi.QuerySearchProfilesAPI,
federation *gomatrixserverlib.FederationClient,
syncProducer *producers.SyncAPIProducer,
transactionsCache *transactions.Cache,
diff --git a/clientapi/routing/userdirectory.go b/clientapi/routing/userdirectory.go
index 4d41da73..f311457a 100644
--- a/clientapi/routing/userdirectory.go
+++ b/clientapi/routing/userdirectory.go
@@ -36,7 +36,7 @@ func SearchUserDirectory(
device *userapi.Device,
userAPI userapi.ClientUserAPI,
rsAPI api.ClientRoomserverAPI,
- provider userapi.UserDirectoryProvider,
+ provider userapi.QuerySearchProfilesAPI,
serverName gomatrixserverlib.ServerName,
searchString string,
limit int,
diff --git a/cmd/dendrite-demo-pinecone/users/users.go b/cmd/dendrite-demo-pinecone/users/users.go
index ebfb5cbe..fc66bf29 100644
--- a/cmd/dendrite-demo-pinecone/users/users.go
+++ b/cmd/dendrite-demo-pinecone/users/users.go
@@ -37,7 +37,7 @@ import (
type PineconeUserProvider struct {
r *pineconeRouter.Router
s *pineconeSessions.Sessions
- userAPI userapi.UserProfileAPI
+ userAPI userapi.QuerySearchProfilesAPI
fedClient *gomatrixserverlib.FederationClient
}
@@ -46,7 +46,7 @@ const PublicURL = "/_matrix/p2p/profiles"
func NewPineconeUserProvider(
r *pineconeRouter.Router,
s *pineconeSessions.Sessions,
- userAPI userapi.UserProfileAPI,
+ userAPI userapi.QuerySearchProfilesAPI,
fedClient *gomatrixserverlib.FederationClient,
) *PineconeUserProvider {
p := &PineconeUserProvider{
diff --git a/federationapi/api/api.go b/federationapi/api/api.go
index ce6a0f2e..87b03718 100644
--- a/federationapi/api/api.go
+++ b/federationapi/api/api.go
@@ -14,17 +14,13 @@ import (
// implements as proxy calls, with built-in backoff/retries/etc. Errors returned from functions in
// this interface are of type FederationClientError
type FederationClient interface {
- gomatrixserverlib.BackfillClient
gomatrixserverlib.FederatedStateClient
GetUserDevices(ctx context.Context, s gomatrixserverlib.ServerName, userID string) (res gomatrixserverlib.RespUserDevices, err error)
ClaimKeys(ctx context.Context, s gomatrixserverlib.ServerName, oneTimeKeys map[string]map[string]string) (res gomatrixserverlib.RespClaimKeys, err error)
QueryKeys(ctx context.Context, s gomatrixserverlib.ServerName, keys map[string][]string) (res gomatrixserverlib.RespQueryKeys, err error)
- GetEvent(ctx context.Context, s gomatrixserverlib.ServerName, eventID string) (res gomatrixserverlib.Transaction, err error)
MSC2836EventRelationships(ctx context.Context, dst gomatrixserverlib.ServerName, r gomatrixserverlib.MSC2836EventRelationshipsRequest, roomVersion gomatrixserverlib.RoomVersion) (res gomatrixserverlib.MSC2836EventRelationshipsResponse, err error)
MSC2946Spaces(ctx context.Context, dst gomatrixserverlib.ServerName, roomID string, suggestedOnly bool) (res gomatrixserverlib.MSC2946SpacesResponse, err error)
LookupServerKeys(ctx context.Context, s gomatrixserverlib.ServerName, keyRequests map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp) ([]gomatrixserverlib.ServerKeys, error)
- GetEventAuth(ctx context.Context, s gomatrixserverlib.ServerName, roomVersion gomatrixserverlib.RoomVersion, roomID, eventID string) (res gomatrixserverlib.RespEventAuth, err error)
- LookupMissingEvents(ctx context.Context, s gomatrixserverlib.ServerName, roomID string, missing gomatrixserverlib.MissingEvents, roomVersion gomatrixserverlib.RoomVersion) (res gomatrixserverlib.RespMissingEvents, err error)
}
// FederationClientError is returned from FederationClient methods in the event of a problem.
@@ -43,17 +39,10 @@ type FederationInternalAPI interface {
FederationClient
gomatrixserverlib.KeyDatabase
ClientFederationAPI
-
- KeyRing() *gomatrixserverlib.KeyRing
+ RoomserverFederationAPI
QueryServerKeys(ctx context.Context, request *QueryServerKeysRequest, response *QueryServerKeysResponse) error
- // PerformDirectoryLookup looks up a remote room ID from a room alias.
- PerformDirectoryLookup(
- ctx context.Context,
- request *PerformDirectoryLookupRequest,
- response *PerformDirectoryLookupResponse,
- ) error
// Query the server names of the joined hosts in a room.
// Unlike QueryJoinedHostsInRoom, this function returns a de-duplicated slice
// containing only the server names (without information for membership events).
@@ -63,30 +52,6 @@ type FederationInternalAPI interface {
request *QueryJoinedHostServerNamesInRoomRequest,
response *QueryJoinedHostServerNamesInRoomResponse,
) error
- // Handle an instruction to make_join & send_join with a remote server.
- PerformJoin(
- ctx context.Context,
- request *PerformJoinRequest,
- response *PerformJoinResponse,
- )
- // Handle an instruction to peek a room on a remote server.
- PerformOutboundPeek(
- ctx context.Context,
- request *PerformOutboundPeekRequest,
- response *PerformOutboundPeekResponse,
- ) error
- // Handle an instruction to make_leave & send_leave with a remote server.
- PerformLeave(
- ctx context.Context,
- request *PerformLeaveRequest,
- response *PerformLeaveResponse,
- ) error
- // Handle sending an invite to a remote server.
- PerformInvite(
- ctx context.Context,
- request *PerformInviteRequest,
- response *PerformInviteResponse,
- ) error
// Notifies the federation sender that these servers may be online and to retry sending messages.
PerformServersAlive(
ctx context.Context,
@@ -105,6 +70,31 @@ type ClientFederationAPI interface {
QueryJoinedHostServerNamesInRoom(ctx context.Context, request *QueryJoinedHostServerNamesInRoomRequest, response *QueryJoinedHostServerNamesInRoomResponse) error
}
+type RoomserverFederationAPI interface {
+ gomatrixserverlib.BackfillClient
+ gomatrixserverlib.FederatedStateClient
+ KeyRing() *gomatrixserverlib.KeyRing
+
+ // PerformDirectoryLookup looks up a remote room ID from a room alias.
+ PerformDirectoryLookup(ctx context.Context, request *PerformDirectoryLookupRequest, response *PerformDirectoryLookupResponse) error
+ // Handle an instruction to make_join & send_join with a remote server.
+ PerformJoin(ctx context.Context, request *PerformJoinRequest, response *PerformJoinResponse)
+ // Handle an instruction to make_leave & send_leave with a remote server.
+ PerformLeave(ctx context.Context, request *PerformLeaveRequest, response *PerformLeaveResponse) error
+ // Handle sending an invite to a remote server.
+ PerformInvite(ctx context.Context, request *PerformInviteRequest, response *PerformInviteResponse) error
+ // Handle an instruction to peek a room on a remote server.
+ PerformOutboundPeek(ctx context.Context, request *PerformOutboundPeekRequest, response *PerformOutboundPeekResponse) error
+ // Query the server names of the joined hosts in a room.
+ // Unlike QueryJoinedHostsInRoom, this function returns a de-duplicated slice
+ // containing only the server names (without information for membership events).
+ // The response will include this server if they are joined to the room.
+ QueryJoinedHostServerNamesInRoom(ctx context.Context, request *QueryJoinedHostServerNamesInRoomRequest, response *QueryJoinedHostServerNamesInRoomResponse) error
+ GetEventAuth(ctx context.Context, s gomatrixserverlib.ServerName, roomVersion gomatrixserverlib.RoomVersion, roomID, eventID string) (res gomatrixserverlib.RespEventAuth, err error)
+ GetEvent(ctx context.Context, s gomatrixserverlib.ServerName, eventID string) (res gomatrixserverlib.Transaction, err error)
+ LookupMissingEvents(ctx context.Context, s gomatrixserverlib.ServerName, roomID string, missing gomatrixserverlib.MissingEvents, roomVersion gomatrixserverlib.RoomVersion) (res gomatrixserverlib.RespMissingEvents, err error)
+}
+
type QueryServerKeysRequest struct {
ServerName gomatrixserverlib.ServerName
KeyIDToCriteria map[gomatrixserverlib.KeyID]gomatrixserverlib.PublicKeyNotaryQueryCriteria
diff --git a/federationapi/federationapi.go b/federationapi/federationapi.go
index c627aab5..632994db 100644
--- a/federationapi/federationapi.go
+++ b/federationapi/federationapi.go
@@ -49,7 +49,7 @@ func AddPublicRoutes(
userAPI userapi.UserInternalAPI,
federation *gomatrixserverlib.FederationClient,
keyRing gomatrixserverlib.JSONVerifier,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.FederationRoomserverAPI,
federationAPI federationAPI.FederationInternalAPI,
keyAPI keyserverAPI.KeyInternalAPI,
servers federationAPI.ServersInRoomProvider,
diff --git a/federationapi/routing/backfill.go b/federationapi/routing/backfill.go
index 82f6cbab..7b9ca66f 100644
--- a/federationapi/routing/backfill.go
+++ b/federationapi/routing/backfill.go
@@ -33,7 +33,7 @@ import (
func Backfill(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID string,
cfg *config.FederationAPI,
) util.JSONResponse {
diff --git a/federationapi/routing/eventauth.go b/federationapi/routing/eventauth.go
index e83cb8ad..868785a9 100644
--- a/federationapi/routing/eventauth.go
+++ b/federationapi/routing/eventauth.go
@@ -26,7 +26,7 @@ import (
func GetEventAuth(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID string,
eventID string,
) util.JSONResponse {
diff --git a/federationapi/routing/events.go b/federationapi/routing/events.go
index 312ef9f8..23796edf 100644
--- a/federationapi/routing/events.go
+++ b/federationapi/routing/events.go
@@ -29,7 +29,7 @@ import (
func GetEvent(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
eventID string,
origin gomatrixserverlib.ServerName,
) util.JSONResponse {
@@ -56,7 +56,7 @@ func GetEvent(
func allowedToSeeEvent(
ctx context.Context,
origin gomatrixserverlib.ServerName,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
eventID string,
) *util.JSONResponse {
var authResponse api.QueryServerAllowedToSeeEventResponse
@@ -82,7 +82,7 @@ func allowedToSeeEvent(
}
// fetchEvent fetches the event without auth checks. Returns an error if the event cannot be found.
-func fetchEvent(ctx context.Context, rsAPI api.RoomserverInternalAPI, eventID string) (*gomatrixserverlib.Event, *util.JSONResponse) {
+func fetchEvent(ctx context.Context, rsAPI api.FederationRoomserverAPI, eventID string) (*gomatrixserverlib.Event, *util.JSONResponse) {
var eventsResponse api.QueryEventsByIDResponse
err := rsAPI.QueryEventsByID(
ctx,
diff --git a/federationapi/routing/invite.go b/federationapi/routing/invite.go
index 25faff0c..a5797645 100644
--- a/federationapi/routing/invite.go
+++ b/federationapi/routing/invite.go
@@ -35,7 +35,7 @@ func InviteV2(
roomID string,
eventID string,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
keys gomatrixserverlib.JSONVerifier,
) util.JSONResponse {
inviteReq := gomatrixserverlib.InviteV2Request{}
@@ -72,7 +72,7 @@ func InviteV1(
roomID string,
eventID string,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
keys gomatrixserverlib.JSONVerifier,
) util.JSONResponse {
roomVer := gomatrixserverlib.RoomVersionV1
@@ -110,7 +110,7 @@ func processInvite(
roomID string,
eventID string,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
keys gomatrixserverlib.JSONVerifier,
) util.JSONResponse {
diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go
index 495b8c91..76769972 100644
--- a/federationapi/routing/join.go
+++ b/federationapi/routing/join.go
@@ -34,7 +34,7 @@ func MakeJoin(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID, userID string,
remoteVersions []gomatrixserverlib.RoomVersion,
) util.JSONResponse {
@@ -165,7 +165,7 @@ func SendJoin(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
keys gomatrixserverlib.JSONVerifier,
roomID, eventID string,
) util.JSONResponse {
diff --git a/federationapi/routing/leave.go b/federationapi/routing/leave.go
index 0b83f04a..54b2c3e8 100644
--- a/federationapi/routing/leave.go
+++ b/federationapi/routing/leave.go
@@ -30,7 +30,7 @@ func MakeLeave(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID, userID string,
) util.JSONResponse {
_, domain, err := gomatrixserverlib.SplitID('@', userID)
@@ -122,7 +122,7 @@ func SendLeave(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
keys gomatrixserverlib.JSONVerifier,
roomID, eventID string,
) util.JSONResponse {
diff --git a/federationapi/routing/missingevents.go b/federationapi/routing/missingevents.go
index b826d69c..531cb9e2 100644
--- a/federationapi/routing/missingevents.go
+++ b/federationapi/routing/missingevents.go
@@ -34,7 +34,7 @@ type getMissingEventRequest struct {
func GetMissingEvents(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID string,
) util.JSONResponse {
var gme getMissingEventRequest
diff --git a/federationapi/routing/openid.go b/federationapi/routing/openid.go
index 829dbcca..cbc75a9a 100644
--- a/federationapi/routing/openid.go
+++ b/federationapi/routing/openid.go
@@ -30,7 +30,7 @@ type openIDUserInfoResponse struct {
// GetOpenIDUserInfo implements GET /_matrix/federation/v1/openid/userinfo
func GetOpenIDUserInfo(
httpReq *http.Request,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.FederationUserAPI,
) util.JSONResponse {
token := httpReq.URL.Query().Get("access_token")
if len(token) == 0 {
diff --git a/federationapi/routing/peek.go b/federationapi/routing/peek.go
index 827d1116..bc4dac90 100644
--- a/federationapi/routing/peek.go
+++ b/federationapi/routing/peek.go
@@ -29,7 +29,7 @@ func Peek(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID, peekID string,
remoteVersions []gomatrixserverlib.RoomVersion,
) util.JSONResponse {
diff --git a/federationapi/routing/profile.go b/federationapi/routing/profile.go
index dbc209ce..f672811a 100644
--- a/federationapi/routing/profile.go
+++ b/federationapi/routing/profile.go
@@ -29,7 +29,7 @@ import (
// GetProfile implements GET /_matrix/federation/v1/query/profile
func GetProfile(
httpReq *http.Request,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.FederationUserAPI,
cfg *config.FederationAPI,
) util.JSONResponse {
userID, field := httpReq.FormValue("user_id"), httpReq.FormValue("field")
diff --git a/federationapi/routing/publicrooms.go b/federationapi/routing/publicrooms.go
index a253f86e..1a54f5a7 100644
--- a/federationapi/routing/publicrooms.go
+++ b/federationapi/routing/publicrooms.go
@@ -23,7 +23,7 @@ type filter struct {
}
// GetPostPublicRooms implements GET and POST /publicRooms
-func GetPostPublicRooms(req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI) util.JSONResponse {
+func GetPostPublicRooms(req *http.Request, rsAPI roomserverAPI.FederationRoomserverAPI) util.JSONResponse {
var request PublicRoomReq
if fillErr := fillPublicRoomsReq(req, &request); fillErr != nil {
return *fillErr
@@ -42,7 +42,7 @@ func GetPostPublicRooms(req *http.Request, rsAPI roomserverAPI.RoomserverInterna
}
func publicRooms(
- ctx context.Context, request PublicRoomReq, rsAPI roomserverAPI.RoomserverInternalAPI,
+ ctx context.Context, request PublicRoomReq, rsAPI roomserverAPI.FederationRoomserverAPI,
) (*gomatrixserverlib.RespPublicRooms, error) {
var response gomatrixserverlib.RespPublicRooms
@@ -111,7 +111,7 @@ func fillPublicRoomsReq(httpReq *http.Request, request *PublicRoomReq) *util.JSO
}
// due to lots of switches
-func fillInRooms(ctx context.Context, roomIDs []string, rsAPI roomserverAPI.RoomserverInternalAPI) ([]gomatrixserverlib.PublicRoom, error) {
+func fillInRooms(ctx context.Context, roomIDs []string, rsAPI roomserverAPI.FederationRoomserverAPI) ([]gomatrixserverlib.PublicRoom, error) {
avatarTuple := gomatrixserverlib.StateKeyTuple{EventType: "m.room.avatar", StateKey: ""}
nameTuple := gomatrixserverlib.StateKeyTuple{EventType: "m.room.name", StateKey: ""}
canonicalTuple := gomatrixserverlib.StateKeyTuple{EventType: gomatrixserverlib.MRoomCanonicalAlias, StateKey: ""}
diff --git a/federationapi/routing/query.go b/federationapi/routing/query.go
index 47d3b2df..707b7b01 100644
--- a/federationapi/routing/query.go
+++ b/federationapi/routing/query.go
@@ -32,7 +32,7 @@ func RoomAliasToID(
httpReq *http.Request,
federation *gomatrixserverlib.FederationClient,
cfg *config.FederationAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.FederationRoomserverAPI,
senderAPI federationAPI.FederationInternalAPI,
) util.JSONResponse {
roomAlias := httpReq.FormValue("room_alias")
diff --git a/federationapi/routing/routing.go b/federationapi/routing/routing.go
index 6d24c8b4..51adc279 100644
--- a/federationapi/routing/routing.go
+++ b/federationapi/routing/routing.go
@@ -47,11 +47,11 @@ import (
func Setup(
fedMux, keyMux, wkMux *mux.Router,
cfg *config.FederationAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.FederationRoomserverAPI,
fsAPI federationAPI.FederationInternalAPI,
keys gomatrixserverlib.JSONVerifier,
federation *gomatrixserverlib.FederationClient,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.FederationUserAPI,
keyAPI keyserverAPI.KeyInternalAPI,
mscCfg *config.MSCs,
servers federationAPI.ServersInRoomProvider,
@@ -497,7 +497,7 @@ func Setup(
func ErrorIfLocalServerNotInRoom(
ctx context.Context,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID string,
) *util.JSONResponse {
// Check if we think we're in this room. If we aren't then
diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go
index 2c01afb1..b9b6d33b 100644
--- a/federationapi/routing/send.go
+++ b/federationapi/routing/send.go
@@ -82,7 +82,7 @@ func Send(
request *gomatrixserverlib.FederationRequest,
txnID gomatrixserverlib.TransactionID,
cfg *config.FederationAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
keyAPI keyapi.KeyInternalAPI,
keys gomatrixserverlib.JSONVerifier,
federation *gomatrixserverlib.FederationClient,
@@ -182,7 +182,7 @@ func Send(
type txnReq struct {
gomatrixserverlib.Transaction
- rsAPI api.RoomserverInternalAPI
+ rsAPI api.FederationRoomserverAPI
keyAPI keyapi.KeyInternalAPI
ourServerName gomatrixserverlib.ServerName
keys gomatrixserverlib.JSONVerifier
diff --git a/federationapi/routing/send_test.go b/federationapi/routing/send_test.go
index 8d2d8504..011d4e34 100644
--- a/federationapi/routing/send_test.go
+++ b/federationapi/routing/send_test.go
@@ -183,7 +183,7 @@ func (c *txnFedClient) LookupMissingEvents(ctx context.Context, s gomatrixserver
return c.getMissingEvents(missing)
}
-func mustCreateTransaction(rsAPI api.RoomserverInternalAPI, fedClient txnFederationClient, pdus []json.RawMessage) *txnReq {
+func mustCreateTransaction(rsAPI api.FederationRoomserverAPI, fedClient txnFederationClient, pdus []json.RawMessage) *txnReq {
t := &txnReq{
rsAPI: rsAPI,
keys: &test.NopJSONVerifier{},
diff --git a/federationapi/routing/state.go b/federationapi/routing/state.go
index e2b67776..6fdce20c 100644
--- a/federationapi/routing/state.go
+++ b/federationapi/routing/state.go
@@ -27,7 +27,7 @@ import (
func GetState(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID string,
) util.JSONResponse {
eventID, err := parseEventIDParam(request)
@@ -50,7 +50,7 @@ func GetState(
func GetStateIDs(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID string,
) util.JSONResponse {
eventID, err := parseEventIDParam(request)
@@ -97,7 +97,7 @@ func parseEventIDParam(
func getState(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
roomID string,
eventID string,
) (stateEvents, authEvents []*gomatrixserverlib.HeaderedEvent, errRes *util.JSONResponse) {
diff --git a/federationapi/routing/threepid.go b/federationapi/routing/threepid.go
index 8ae7130c..16f245ce 100644
--- a/federationapi/routing/threepid.go
+++ b/federationapi/routing/threepid.go
@@ -55,10 +55,10 @@ var (
// CreateInvitesFrom3PIDInvites implements POST /_matrix/federation/v1/3pid/onbind
func CreateInvitesFrom3PIDInvites(
- req *http.Request, rsAPI api.RoomserverInternalAPI,
+ req *http.Request, rsAPI api.FederationRoomserverAPI,
cfg *config.FederationAPI,
federation *gomatrixserverlib.FederationClient,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.FederationUserAPI,
) util.JSONResponse {
var body invites
if reqErr := httputil.UnmarshalJSONRequest(req, &body); reqErr != nil {
@@ -105,7 +105,7 @@ func ExchangeThirdPartyInvite(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
roomID string,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.FederationRoomserverAPI,
cfg *config.FederationAPI,
federation *gomatrixserverlib.FederationClient,
) util.JSONResponse {
@@ -203,10 +203,10 @@ func ExchangeThirdPartyInvite(
// Returns an error if there was a problem building the event or fetching the
// necessary data to do so.
func createInviteFrom3PIDInvite(
- ctx context.Context, rsAPI api.RoomserverInternalAPI,
+ ctx context.Context, rsAPI api.FederationRoomserverAPI,
cfg *config.FederationAPI,
inv invite, federation *gomatrixserverlib.FederationClient,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.FederationUserAPI,
) (*gomatrixserverlib.Event, error) {
verReq := api.QueryRoomVersionForRoomRequest{RoomID: inv.RoomID}
verRes := api.QueryRoomVersionForRoomResponse{}
@@ -270,7 +270,7 @@ func createInviteFrom3PIDInvite(
// Returns an error if something failed during the process.
func buildMembershipEvent(
ctx context.Context,
- builder *gomatrixserverlib.EventBuilder, rsAPI api.RoomserverInternalAPI,
+ builder *gomatrixserverlib.EventBuilder, rsAPI api.FederationRoomserverAPI,
cfg *config.FederationAPI,
) (*gomatrixserverlib.Event, error) {
eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder)
diff --git a/keyserver/api/api.go b/keyserver/api/api.go
index 5564eb27..6cee2c01 100644
--- a/keyserver/api/api.go
+++ b/keyserver/api/api.go
@@ -29,12 +29,13 @@ import (
type KeyInternalAPI interface {
SyncKeyAPI
ClientKeyAPI
+ UserKeyAPI
+
// SetUserAPI assigns a user API to query when extracting device names.
SetUserAPI(i userapi.UserInternalAPI)
// InputDeviceListUpdate from a federated server EDU
InputDeviceListUpdate(ctx context.Context, req *InputDeviceListUpdateRequest, res *InputDeviceListUpdateResponse)
- PerformDeleteKeys(ctx context.Context, req *PerformDeleteKeysRequest, res *PerformDeleteKeysResponse)
QueryDeviceMessages(ctx context.Context, req *QueryDeviceMessagesRequest, res *QueryDeviceMessagesResponse)
QuerySignatures(ctx context.Context, req *QuerySignaturesRequest, res *QuerySignaturesResponse)
}
@@ -49,6 +50,12 @@ type ClientKeyAPI interface {
PerformClaimKeys(ctx context.Context, req *PerformClaimKeysRequest, res *PerformClaimKeysResponse)
}
+// API functions required by the userapi
+type UserKeyAPI interface {
+ PerformUploadKeys(ctx context.Context, req *PerformUploadKeysRequest, res *PerformUploadKeysResponse)
+ PerformDeleteKeys(ctx context.Context, req *PerformDeleteKeysRequest, res *PerformDeleteKeysResponse)
+}
+
// API functions required by the syncapi
type SyncKeyAPI interface {
QueryKeyChanges(ctx context.Context, req *QueryKeyChangesRequest, res *QueryKeyChangesResponse)
diff --git a/roomserver/api/api.go b/roomserver/api/api.go
index 33c3d157..7e1e568c 100644
--- a/roomserver/api/api.go
+++ b/roomserver/api/api.go
@@ -19,10 +19,12 @@ type RoomserverInternalAPI interface {
SyncRoomserverAPI
AppserviceRoomserverAPI
ClientRoomserverAPI
+ UserRoomserverAPI
+ FederationRoomserverAPI
// needed to avoid chicken and egg scenario when setting up the
// interdependencies between the roomserver and other input APIs
- SetFederationAPI(fsAPI fsAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing)
+ SetFederationAPI(fsAPI fsAPI.RoomserverFederationAPI, keyRing *gomatrixserverlib.KeyRing)
SetAppserviceAPI(asAPI asAPI.AppServiceQueryAPI)
SetUserAPI(userAPI userapi.UserInternalAPI)
@@ -62,48 +64,6 @@ type RoomserverInternalAPI interface {
res *PerformPublishResponse,
)
- PerformInboundPeek(
- ctx context.Context,
- req *PerformInboundPeekRequest,
- res *PerformInboundPeekResponse,
- ) error
-
- QueryPublishedRooms(
- ctx context.Context,
- req *QueryPublishedRoomsRequest,
- res *QueryPublishedRoomsResponse,
- ) error
-
- // Query if we think we're still in a room.
- QueryServerJoinedToRoom(
- ctx context.Context,
- req *QueryServerJoinedToRoomRequest,
- res *QueryServerJoinedToRoomResponse,
- ) error
-
- // Query whether a server is allowed to see an event
- QueryServerAllowedToSeeEvent(
- ctx context.Context,
- req *QueryServerAllowedToSeeEventRequest,
- res *QueryServerAllowedToSeeEventResponse,
- ) error
-
- // Query missing events for a room from roomserver
- QueryMissingEvents(
- ctx context.Context,
- req *QueryMissingEventsRequest,
- res *QueryMissingEventsResponse,
- ) error
-
- // Query to get state and auth chain for a (potentially hypothetical) event.
- // Takes lists of PrevEventIDs and AuthEventsIDs and uses them to calculate
- // the state and auth chain to return.
- QueryStateAndAuthChain(
- ctx context.Context,
- req *QueryStateAndAuthChainRequest,
- res *QueryStateAndAuthChainResponse,
- ) error
-
// QueryAuthChain returns the entire auth chain for the event IDs given.
// The response includes the events in the request.
// Omits without error for any missing auth events. There will be no duplicates.
@@ -115,8 +75,6 @@ type RoomserverInternalAPI interface {
// QueryRoomsForUser retrieves a list of room IDs matching the given query.
QueryRoomsForUser(ctx context.Context, req *QueryRoomsForUserRequest, res *QueryRoomsForUserResponse) error
- // QueryServerBannedFromRoom returns whether a server is banned from a room by server ACLs.
- QueryServerBannedFromRoom(ctx context.Context, req *QueryServerBannedFromRoomRequest, res *QueryServerBannedFromRoomResponse) error
// PerformRoomUpgrade upgrades a room to a newer version
PerformRoomUpgrade(ctx context.Context, req *PerformRoomUpgradeRequest, resp *PerformRoomUpgradeResponse)
@@ -285,3 +243,35 @@ type ClientRoomserverAPI interface {
SetRoomAlias(ctx context.Context, req *SetRoomAliasRequest, res *SetRoomAliasResponse) error
RemoveRoomAlias(ctx context.Context, req *RemoveRoomAliasRequest, res *RemoveRoomAliasResponse) error
}
+
+type UserRoomserverAPI interface {
+ QueryLatestEventsAndStateAPI
+ QueryCurrentState(ctx context.Context, req *QueryCurrentStateRequest, res *QueryCurrentStateResponse) error
+ QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
+}
+
+type FederationRoomserverAPI interface {
+ InputRoomEventsAPI
+ QueryLatestEventsAndStateAPI
+ QueryBulkStateContentAPI
+ // QueryServerBannedFromRoom returns whether a server is banned from a room by server ACLs.
+ QueryServerBannedFromRoom(ctx context.Context, req *QueryServerBannedFromRoomRequest, res *QueryServerBannedFromRoomResponse) error
+ QueryRoomVersionForRoom(ctx context.Context, req *QueryRoomVersionForRoomRequest, res *QueryRoomVersionForRoomResponse) error
+ GetRoomIDForAlias(ctx context.Context, req *GetRoomIDForAliasRequest, res *GetRoomIDForAliasResponse) error
+ QueryEventsByID(ctx context.Context, req *QueryEventsByIDRequest, res *QueryEventsByIDResponse) error
+ // Query to get state and auth chain for a (potentially hypothetical) event.
+ // Takes lists of PrevEventIDs and AuthEventsIDs and uses them to calculate
+ // the state and auth chain to return.
+ QueryStateAndAuthChain(ctx context.Context, req *QueryStateAndAuthChainRequest, res *QueryStateAndAuthChainResponse) error
+ // Query if we think we're still in a room.
+ QueryServerJoinedToRoom(ctx context.Context, req *QueryServerJoinedToRoomRequest, res *QueryServerJoinedToRoomResponse) error
+ QueryPublishedRooms(ctx context.Context, req *QueryPublishedRoomsRequest, res *QueryPublishedRoomsResponse) error
+ // Query missing events for a room from roomserver
+ QueryMissingEvents(ctx context.Context, req *QueryMissingEventsRequest, res *QueryMissingEventsResponse) error
+ // Query whether a server is allowed to see an event
+ QueryServerAllowedToSeeEvent(ctx context.Context, req *QueryServerAllowedToSeeEventRequest, res *QueryServerAllowedToSeeEventResponse) error
+ PerformInboundPeek(ctx context.Context, req *PerformInboundPeekRequest, res *PerformInboundPeekResponse) error
+ PerformInvite(ctx context.Context, req *PerformInviteRequest, res *PerformInviteResponse) error
+ // Query a given amount (or less) of events prior to a given set of events.
+ PerformBackfill(ctx context.Context, req *PerformBackfillRequest, res *PerformBackfillResponse) error
+}
diff --git a/roomserver/api/api_trace.go b/roomserver/api/api_trace.go
index 61c06e88..bc60999e 100644
--- a/roomserver/api/api_trace.go
+++ b/roomserver/api/api_trace.go
@@ -19,7 +19,7 @@ type RoomserverInternalAPITrace struct {
Impl RoomserverInternalAPI
}
-func (t *RoomserverInternalAPITrace) SetFederationAPI(fsAPI fsAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing) {
+func (t *RoomserverInternalAPITrace) SetFederationAPI(fsAPI fsAPI.RoomserverFederationAPI, keyRing *gomatrixserverlib.KeyRing) {
t.Impl.SetFederationAPI(fsAPI, keyRing)
}
diff --git a/roomserver/api/wrapper.go b/roomserver/api/wrapper.go
index 9f7a09dd..344e9b07 100644
--- a/roomserver/api/wrapper.go
+++ b/roomserver/api/wrapper.go
@@ -129,7 +129,7 @@ func GetStateEvent(ctx context.Context, rsAPI QueryEventsAPI, roomID string, tup
}
// IsServerBannedFromRoom returns whether the server is banned from a room by server ACLs.
-func IsServerBannedFromRoom(ctx context.Context, rsAPI RoomserverInternalAPI, roomID string, serverName gomatrixserverlib.ServerName) bool {
+func IsServerBannedFromRoom(ctx context.Context, rsAPI FederationRoomserverAPI, roomID string, serverName gomatrixserverlib.ServerName) bool {
req := &QueryServerBannedFromRoomRequest{
ServerName: serverName,
RoomID: roomID,
diff --git a/roomserver/internal/api.go b/roomserver/internal/api.go
index 267cd409..dc0a0a71 100644
--- a/roomserver/internal/api.go
+++ b/roomserver/internal/api.go
@@ -43,7 +43,7 @@ type RoomserverInternalAPI struct {
ServerName gomatrixserverlib.ServerName
KeyRing gomatrixserverlib.JSONVerifier
ServerACLs *acls.ServerACLs
- fsAPI fsAPI.FederationInternalAPI
+ fsAPI fsAPI.RoomserverFederationAPI
asAPI asAPI.AppServiceQueryAPI
NATSClient *nats.Conn
JetStream nats.JetStreamContext
@@ -87,7 +87,7 @@ func NewRoomserverAPI(
// SetFederationInputAPI passes in a federation input API reference so that we can
// avoid the chicken-and-egg problem of both the roomserver input API and the
// federation input API being interdependent.
-func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing) {
+func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederationAPI, keyRing *gomatrixserverlib.KeyRing) {
r.fsAPI = fsAPI
r.KeyRing = keyRing
diff --git a/roomserver/internal/input/input.go b/roomserver/internal/input/input.go
index 10c21022..600994c5 100644
--- a/roomserver/internal/input/input.go
+++ b/roomserver/internal/input/input.go
@@ -82,7 +82,7 @@ type Inputer struct {
JetStream nats.JetStreamContext
Durable nats.SubOpt
ServerName gomatrixserverlib.ServerName
- FSAPI fedapi.FederationInternalAPI
+ FSAPI fedapi.RoomserverFederationAPI
KeyRing gomatrixserverlib.JSONVerifier
ACLs *acls.ServerACLs
InputRoomEventTopic string
diff --git a/roomserver/internal/input/input_missing.go b/roomserver/internal/input/input_missing.go
index 2c958335..9c70076c 100644
--- a/roomserver/internal/input/input_missing.go
+++ b/roomserver/internal/input/input_missing.go
@@ -44,7 +44,7 @@ type missingStateReq struct {
roomInfo *types.RoomInfo
inputer *Inputer
keys gomatrixserverlib.JSONVerifier
- federation fedapi.FederationInternalAPI
+ federation fedapi.RoomserverFederationAPI
roomsMu *internal.MutexByRoom
servers []gomatrixserverlib.ServerName
hadEvents map[string]bool
diff --git a/roomserver/internal/perform/perform_backfill.go b/roomserver/internal/perform/perform_backfill.go
index 081f694a..1bc4c75c 100644
--- a/roomserver/internal/perform/perform_backfill.go
+++ b/roomserver/internal/perform/perform_backfill.go
@@ -38,7 +38,7 @@ const maxBackfillServers = 5
type Backfiller struct {
ServerName gomatrixserverlib.ServerName
DB storage.Database
- FSAPI federationAPI.FederationInternalAPI
+ FSAPI federationAPI.RoomserverFederationAPI
KeyRing gomatrixserverlib.JSONVerifier
// The servers which should be preferred above other servers when backfilling
@@ -228,7 +228,7 @@ func (r *Backfiller) fetchAndStoreMissingEvents(ctx context.Context, roomVer gom
// backfillRequester implements gomatrixserverlib.BackfillRequester
type backfillRequester struct {
db storage.Database
- fsAPI federationAPI.FederationInternalAPI
+ fsAPI federationAPI.RoomserverFederationAPI
thisServer gomatrixserverlib.ServerName
preferServer map[gomatrixserverlib.ServerName]bool
bwExtrems map[string][]string
@@ -240,7 +240,7 @@ type backfillRequester struct {
}
func newBackfillRequester(
- db storage.Database, fsAPI federationAPI.FederationInternalAPI, thisServer gomatrixserverlib.ServerName,
+ db storage.Database, fsAPI federationAPI.RoomserverFederationAPI, thisServer gomatrixserverlib.ServerName,
bwExtrems map[string][]string, preferServers []gomatrixserverlib.ServerName,
) *backfillRequester {
preferServer := make(map[gomatrixserverlib.ServerName]bool)
diff --git a/roomserver/internal/perform/perform_invite.go b/roomserver/internal/perform/perform_invite.go
index 6111372d..b0148a31 100644
--- a/roomserver/internal/perform/perform_invite.go
+++ b/roomserver/internal/perform/perform_invite.go
@@ -35,7 +35,7 @@ import (
type Inviter struct {
DB storage.Database
Cfg *config.RoomServer
- FSAPI federationAPI.FederationInternalAPI
+ FSAPI federationAPI.RoomserverFederationAPI
Inputer *input.Inputer
}
diff --git a/roomserver/internal/perform/perform_join.go b/roomserver/internal/perform/perform_join.go
index a40f66d2..61a0206e 100644
--- a/roomserver/internal/perform/perform_join.go
+++ b/roomserver/internal/perform/perform_join.go
@@ -38,7 +38,7 @@ import (
type Joiner struct {
ServerName gomatrixserverlib.ServerName
Cfg *config.RoomServer
- FSAPI fsAPI.FederationInternalAPI
+ FSAPI fsAPI.RoomserverFederationAPI
RSAPI rsAPI.RoomserverInternalAPI
DB storage.Database
diff --git a/roomserver/internal/perform/perform_leave.go b/roomserver/internal/perform/perform_leave.go
index 5b4cd3c6..b006843f 100644
--- a/roomserver/internal/perform/perform_leave.go
+++ b/roomserver/internal/perform/perform_leave.go
@@ -37,7 +37,7 @@ import (
type Leaver struct {
Cfg *config.RoomServer
DB storage.Database
- FSAPI fsAPI.FederationInternalAPI
+ FSAPI fsAPI.RoomserverFederationAPI
UserAPI userapi.UserInternalAPI
Inputer *input.Inputer
}
diff --git a/roomserver/internal/perform/perform_peek.go b/roomserver/internal/perform/perform_peek.go
index 6a2c329b..45e63888 100644
--- a/roomserver/internal/perform/perform_peek.go
+++ b/roomserver/internal/perform/perform_peek.go
@@ -33,7 +33,7 @@ import (
type Peeker struct {
ServerName gomatrixserverlib.ServerName
Cfg *config.RoomServer
- FSAPI fsAPI.FederationInternalAPI
+ FSAPI fsAPI.RoomserverFederationAPI
DB storage.Database
Inputer *input.Inputer
diff --git a/roomserver/internal/perform/perform_unpeek.go b/roomserver/internal/perform/perform_unpeek.go
index 16b4eeae..1057499c 100644
--- a/roomserver/internal/perform/perform_unpeek.go
+++ b/roomserver/internal/perform/perform_unpeek.go
@@ -30,7 +30,7 @@ import (
type Unpeeker struct {
ServerName gomatrixserverlib.ServerName
Cfg *config.RoomServer
- FSAPI fsAPI.FederationInternalAPI
+ FSAPI fsAPI.RoomserverFederationAPI
DB storage.Database
Inputer *input.Inputer
diff --git a/roomserver/inthttp/client.go b/roomserver/inthttp/client.go
index 3b29001e..4fc75ff4 100644
--- a/roomserver/inthttp/client.go
+++ b/roomserver/inthttp/client.go
@@ -87,7 +87,7 @@ func NewRoomserverClient(
}
// SetFederationInputAPI no-ops in HTTP client mode as there is no chicken/egg scenario
-func (h *httpRoomserverInternalAPI) SetFederationAPI(fsAPI fsInputAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing) {
+func (h *httpRoomserverInternalAPI) SetFederationAPI(fsAPI fsInputAPI.RoomserverFederationAPI, keyRing *gomatrixserverlib.KeyRing) {
}
// SetAppserviceAPI no-ops in HTTP client mode as there is no chicken/egg scenario
diff --git a/setup/monolith.go b/setup/monolith.go
index e033c14d..a0e850d8 100644
--- a/setup/monolith.go
+++ b/setup/monolith.go
@@ -47,7 +47,7 @@ type Monolith struct {
// Optional
ExtPublicRoomsProvider api.ExtraPublicRoomsProvider
- ExtUserDirectoryProvider userapi.UserDirectoryProvider
+ ExtUserDirectoryProvider userapi.QuerySearchProfilesAPI
}
// AddAllPublicRoutes attaches all public paths to the given router
diff --git a/userapi/api/api.go b/userapi/api/api.go
index 928b91e6..dc8c12b7 100644
--- a/userapi/api/api.go
+++ b/userapi/api/api.go
@@ -26,34 +26,33 @@ import (
// UserInternalAPI is the internal API for information about users and devices.
type UserInternalAPI interface {
- UserProfileAPI
- QueryAcccessTokenAPI
-
AppserviceUserAPI
SyncUserAPI
ClientUserAPI
MediaUserAPI
+ FederationUserAPI
- QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error
-}
-
-type QueryAcccessTokenAPI interface {
- QueryAccessToken(ctx context.Context, req *QueryAccessTokenRequest, res *QueryAccessTokenResponse) error
-}
-
-type UserLoginAPI interface {
- QueryAccountByPassword(ctx context.Context, req *QueryAccountByPasswordRequest, res *QueryAccountByPasswordResponse) error
+ QuerySearchProfilesAPI // used by p2p demos
}
+// api functions required by the appservice api
type AppserviceUserAPI interface {
PerformAccountCreation(ctx context.Context, req *PerformAccountCreationRequest, res *PerformAccountCreationResponse) error
PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
}
+// api functions required by the media api
type MediaUserAPI interface {
QueryAcccessTokenAPI
}
+// api functions required by the federation api
+type FederationUserAPI interface {
+ QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error
+ QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
+}
+
+// api functions required by the sync api
type SyncUserAPI interface {
QueryAcccessTokenAPI
QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
@@ -63,6 +62,7 @@ type SyncUserAPI interface {
QueryDeviceInfos(ctx context.Context, req *QueryDeviceInfosRequest, res *QueryDeviceInfosResponse) error
}
+// api functions required by the client api
type ClientUserAPI interface {
QueryAcccessTokenAPI
LoginTokenInternalAPI
@@ -97,14 +97,18 @@ type ClientUserAPI interface {
PerformSaveThreePIDAssociation(ctx context.Context, req *PerformSaveThreePIDAssociationRequest, res *struct{}) error
}
-type UserDirectoryProvider interface {
+// custom api functions required by pinecone / p2p demos
+type QuerySearchProfilesAPI interface {
QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
}
-// UserProfileAPI provides functions for getting user profiles
-type UserProfileAPI interface {
- QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
- QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
+// common function for creating authenticated endpoints (used in client/media/sync api)
+type QueryAcccessTokenAPI interface {
+ QueryAccessToken(ctx context.Context, req *QueryAccessTokenRequest, res *QueryAccessTokenResponse) error
+}
+
+type UserLoginAPI interface {
+ QueryAccountByPassword(ctx context.Context, req *QueryAccountByPasswordRequest, res *QueryAccountByPasswordResponse) error
}
type PerformKeyBackupRequest struct {
diff --git a/userapi/consumers/syncapi_streamevent.go b/userapi/consumers/syncapi_streamevent.go
index 9ef7b508..7807c763 100644
--- a/userapi/consumers/syncapi_streamevent.go
+++ b/userapi/consumers/syncapi_streamevent.go
@@ -29,7 +29,7 @@ type OutputStreamEventConsumer struct {
ctx context.Context
cfg *config.UserAPI
userAPI api.UserInternalAPI
- rsAPI rsapi.RoomserverInternalAPI
+ rsAPI rsapi.UserRoomserverAPI
jetstream nats.JetStreamContext
durable string
db storage.Database
@@ -45,7 +45,7 @@ func NewOutputStreamEventConsumer(
store storage.Database,
pgClient pushgateway.Client,
userAPI api.UserInternalAPI,
- rsAPI rsapi.RoomserverInternalAPI,
+ rsAPI rsapi.UserRoomserverAPI,
syncProducer *producers.SyncAPI,
) *OutputStreamEventConsumer {
return &OutputStreamEventConsumer{
@@ -455,7 +455,7 @@ func (s *OutputStreamEventConsumer) evaluatePushRules(ctx context.Context, event
type ruleSetEvalContext struct {
ctx context.Context
- rsAPI rsapi.RoomserverInternalAPI
+ rsAPI rsapi.UserRoomserverAPI
mem *localMembership
roomID string
roomSize int
diff --git a/userapi/internal/api.go b/userapi/internal/api.go
index 394bfa22..9d2f63c7 100644
--- a/userapi/internal/api.go
+++ b/userapi/internal/api.go
@@ -48,7 +48,7 @@ type UserInternalAPI struct {
ServerName gomatrixserverlib.ServerName
// AppServices is the list of all registered AS
AppServices []config.ApplicationService
- KeyAPI keyapi.KeyInternalAPI
+ KeyAPI keyapi.UserKeyAPI
}
func (a *UserInternalAPI) InputAccountData(ctx context.Context, req *api.InputAccountDataRequest, res *api.InputAccountDataResponse) error {
diff --git a/userapi/userapi.go b/userapi/userapi.go
index 5b11665d..03a46807 100644
--- a/userapi/userapi.go
+++ b/userapi/userapi.go
@@ -44,8 +44,8 @@ func AddInternalRoutes(router *mux.Router, intAPI api.UserInternalAPI) {
// can call functions directly on the returned API or via an HTTP interface using AddInternalRoutes.
func NewInternalAPI(
base *base.BaseDendrite, cfg *config.UserAPI,
- appServices []config.ApplicationService, keyAPI keyapi.KeyInternalAPI,
- rsAPI rsapi.RoomserverInternalAPI, pgClient pushgateway.Client,
+ appServices []config.ApplicationService, keyAPI keyapi.UserKeyAPI,
+ rsAPI rsapi.UserRoomserverAPI, pgClient pushgateway.Client,
) api.UserInternalAPI {
js, _ := jetstream.Prepare(base.ProcessContext, &cfg.Matrix.JetStream)