aboutsummaryrefslogtreecommitdiff
path: root/roomserver
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 /roomserver
parente4da04e75b4cba1c9afb63b9973444e1da12021b (diff)
Define component interfaces based on consumers (2/2) (#2425)
* convert remaining interfaces * Tidy up the userapi interfaces
Diffstat (limited to 'roomserver')
-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
13 files changed, 50 insertions, 60 deletions
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