aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2023-04-06 09:55:01 +0100
committerGitHub <noreply@github.com>2023-04-06 09:55:01 +0100
commit0db43f13a6b79cc2bd3e210051800e4d6de87c42 (patch)
tree71ab9b12df44791abddf0cf87690e80f970c06fa /internal
parente093005bc2a2a582ed884826fc4efc90c4b9d9ad (diff)
refactor: use latest GMSL which splits fed client from matrix room logic (#3051)
Part of a series of refactors on GMSL.
Diffstat (limited to 'internal')
-rw-r--r--internal/caching/cache_space_rooms.go12
-rw-r--r--internal/caching/caches.go3
-rw-r--r--internal/caching/impl_ristretto.go3
-rw-r--r--internal/eventutil/events.go5
-rw-r--r--internal/transactionrequest.go15
5 files changed, 20 insertions, 18 deletions
diff --git a/internal/caching/cache_space_rooms.go b/internal/caching/cache_space_rooms.go
index 697f9926..100ab902 100644
--- a/internal/caching/cache_space_rooms.go
+++ b/internal/caching/cache_space_rooms.go
@@ -1,18 +1,16 @@
package caching
-import (
- "github.com/matrix-org/gomatrixserverlib"
-)
+import "github.com/matrix-org/gomatrixserverlib/fclient"
type SpaceSummaryRoomsCache interface {
- GetSpaceSummary(roomID string) (r gomatrixserverlib.MSC2946SpacesResponse, ok bool)
- StoreSpaceSummary(roomID string, r gomatrixserverlib.MSC2946SpacesResponse)
+ GetSpaceSummary(roomID string) (r fclient.MSC2946SpacesResponse, ok bool)
+ StoreSpaceSummary(roomID string, r fclient.MSC2946SpacesResponse)
}
-func (c Caches) GetSpaceSummary(roomID string) (r gomatrixserverlib.MSC2946SpacesResponse, ok bool) {
+func (c Caches) GetSpaceSummary(roomID string) (r fclient.MSC2946SpacesResponse, ok bool) {
return c.SpaceSummaryRooms.Get(roomID)
}
-func (c Caches) StoreSpaceSummary(roomID string, r gomatrixserverlib.MSC2946SpacesResponse) {
+func (c Caches) StoreSpaceSummary(roomID string, r fclient.MSC2946SpacesResponse) {
c.SpaceSummaryRooms.Set(roomID, r)
}
diff --git a/internal/caching/caches.go b/internal/caching/caches.go
index 47992046..a678632e 100644
--- a/internal/caching/caches.go
+++ b/internal/caching/caches.go
@@ -17,6 +17,7 @@ package caching
import (
"github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/fclient"
)
// Caches contains a set of references to caches. They may be
@@ -34,7 +35,7 @@ type Caches struct {
RoomServerEventTypes Cache[types.EventTypeNID, string] // eventType NID -> eventType
FederationPDUs Cache[int64, *gomatrixserverlib.HeaderedEvent] // queue NID -> PDU
FederationEDUs Cache[int64, *gomatrixserverlib.EDU] // queue NID -> EDU
- SpaceSummaryRooms Cache[string, gomatrixserverlib.MSC2946SpacesResponse] // room ID -> space response
+ SpaceSummaryRooms Cache[string, fclient.MSC2946SpacesResponse] // room ID -> space response
LazyLoading Cache[lazyLoadingCacheKey, string] // composite key -> event ID
}
diff --git a/internal/caching/impl_ristretto.go b/internal/caching/impl_ristretto.go
index 7663ddcb..4656b6b7 100644
--- a/internal/caching/impl_ristretto.go
+++ b/internal/caching/impl_ristretto.go
@@ -23,6 +23,7 @@ import (
"github.com/dgraph-io/ristretto"
"github.com/dgraph-io/ristretto/z"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/fclient"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
@@ -146,7 +147,7 @@ func NewRistrettoCache(maxCost config.DataUnit, maxAge time.Duration, enableProm
MaxAge: lesserOf(time.Hour/2, maxAge),
},
},
- SpaceSummaryRooms: &RistrettoCachePartition[string, gomatrixserverlib.MSC2946SpacesResponse]{ // room ID -> space response
+ SpaceSummaryRooms: &RistrettoCachePartition[string, fclient.MSC2946SpacesResponse]{ // room ID -> space response
cache: cache,
Prefix: spaceSummaryRoomsCache,
Mutable: true,
diff --git a/internal/eventutil/events.go b/internal/eventutil/events.go
index c572d883..984a3f53 100644
--- a/internal/eventutil/events.go
+++ b/internal/eventutil/events.go
@@ -22,6 +22,7 @@ import (
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/setup/config"
+ "github.com/matrix-org/gomatrixserverlib/fclient"
"github.com/matrix-org/gomatrixserverlib"
)
@@ -39,7 +40,7 @@ var ErrRoomNoExists = errors.New("room does not exist")
func QueryAndBuildEvent(
ctx context.Context,
builder *gomatrixserverlib.EventBuilder, cfg *config.Global,
- identity *gomatrixserverlib.SigningIdentity, evTime time.Time,
+ identity *fclient.SigningIdentity, evTime time.Time,
rsAPI api.QueryLatestEventsAndStateAPI, queryRes *api.QueryLatestEventsAndStateResponse,
) (*gomatrixserverlib.HeaderedEvent, error) {
if queryRes == nil {
@@ -59,7 +60,7 @@ func QueryAndBuildEvent(
func BuildEvent(
ctx context.Context,
builder *gomatrixserverlib.EventBuilder, cfg *config.Global,
- identity *gomatrixserverlib.SigningIdentity, evTime time.Time,
+ identity *fclient.SigningIdentity, evTime time.Time,
eventsNeeded *gomatrixserverlib.StateNeeded, queryRes *api.QueryLatestEventsAndStateResponse,
) (*gomatrixserverlib.HeaderedEvent, error) {
if err := addPrevEventsToEvent(builder, eventsNeeded, queryRes); err != nil {
diff --git a/internal/transactionrequest.go b/internal/transactionrequest.go
index 13b00af5..60c02b12 100644
--- a/internal/transactionrequest.go
+++ b/internal/transactionrequest.go
@@ -28,6 +28,7 @@ import (
syncTypes "github.com/matrix-org/dendrite/syncapi/types"
userAPI "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/fclient"
"github.com/matrix-org/util"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
@@ -97,7 +98,7 @@ func NewTxnReq(
return t
}
-func (t *TxnReq) ProcessTransaction(ctx context.Context) (*gomatrixserverlib.RespSend, *util.JSONResponse) {
+func (t *TxnReq) ProcessTransaction(ctx context.Context) (*fclient.RespSend, *util.JSONResponse) {
var wg sync.WaitGroup
wg.Add(1)
go func() {
@@ -107,7 +108,7 @@ func (t *TxnReq) ProcessTransaction(ctx context.Context) (*gomatrixserverlib.Res
}
}()
- results := make(map[string]gomatrixserverlib.PDUResult)
+ results := make(map[string]fclient.PDUResult)
roomVersions := make(map[string]gomatrixserverlib.RoomVersion)
getRoomVersion := func(roomID string) gomatrixserverlib.RoomVersion {
if v, ok := roomVersions[roomID]; ok {
@@ -157,14 +158,14 @@ func (t *TxnReq) ProcessTransaction(ctx context.Context) (*gomatrixserverlib.Res
continue
}
if api.IsServerBannedFromRoom(ctx, t.rsAPI, event.RoomID(), t.Origin) {
- results[event.EventID()] = gomatrixserverlib.PDUResult{
+ results[event.EventID()] = fclient.PDUResult{
Error: "Forbidden by server ACLs",
}
continue
}
if err = event.VerifyEventSignatures(ctx, t.keys); err != nil {
util.GetLogger(ctx).WithError(err).Debugf("Transaction: Couldn't validate signature of event %q", event.EventID())
- results[event.EventID()] = gomatrixserverlib.PDUResult{
+ results[event.EventID()] = fclient.PDUResult{
Error: err.Error(),
}
continue
@@ -187,18 +188,18 @@ func (t *TxnReq) ProcessTransaction(ctx context.Context) (*gomatrixserverlib.Res
true,
); err != nil {
util.GetLogger(ctx).WithError(err).Errorf("Transaction: Couldn't submit event %q to input queue: %s", event.EventID(), err)
- results[event.EventID()] = gomatrixserverlib.PDUResult{
+ results[event.EventID()] = fclient.PDUResult{
Error: err.Error(),
}
continue
}
- results[event.EventID()] = gomatrixserverlib.PDUResult{}
+ results[event.EventID()] = fclient.PDUResult{}
PDUCountTotal.WithLabelValues("success").Inc()
}
wg.Wait()
- return &gomatrixserverlib.RespSend{PDUs: results}, nil
+ return &fclient.RespSend{PDUs: results}, nil
}
// nolint:gocyclo