mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-26 08:11:55 -06:00
Use PDU in even more places (#3074)
- No longer rely on *Event returning from NewEventFrom... functions Requires https://github.com/matrix-org/gomatrixserverlib/pull/377
This commit is contained in:
parent
9b98e5a102
commit
6284790f98
|
@ -453,7 +453,7 @@ func createRoom(
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
builder.PrevEvents = []gomatrixserverlib.EventReference{builtEvents[i-1].EventReference()}
|
builder.PrevEvents = []gomatrixserverlib.EventReference{builtEvents[i-1].EventReference()}
|
||||||
}
|
}
|
||||||
var ev *gomatrixserverlib.Event
|
var ev gomatrixserverlib.PDU
|
||||||
ev, err = builder.AddAuthEventsAndBuild(userDomain, &authEvents, evTime, roomVersion, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey)
|
ev, err = builder.AddAuthEventsAndBuild(userDomain, &authEvents, evTime, roomVersion, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.GetLogger(ctx).WithError(err).Error("buildEvent failed")
|
util.GetLogger(ctx).WithError(err).Error("buildEvent failed")
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package api
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
|
||||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ServersInRoomProvider interface {
|
|
||||||
GetServersForRoom(ctx context.Context, roomID string, event *gomatrixserverlib.Event) []spec.ServerName
|
|
||||||
}
|
|
|
@ -53,7 +53,6 @@ func AddPublicRoutes(
|
||||||
keyRing gomatrixserverlib.JSONVerifier,
|
keyRing gomatrixserverlib.JSONVerifier,
|
||||||
rsAPI roomserverAPI.FederationRoomserverAPI,
|
rsAPI roomserverAPI.FederationRoomserverAPI,
|
||||||
fedAPI federationAPI.FederationInternalAPI,
|
fedAPI federationAPI.FederationInternalAPI,
|
||||||
servers federationAPI.ServersInRoomProvider,
|
|
||||||
enableMetrics bool,
|
enableMetrics bool,
|
||||||
) {
|
) {
|
||||||
cfg := &dendriteConfig.FederationAPI
|
cfg := &dendriteConfig.FederationAPI
|
||||||
|
@ -87,7 +86,7 @@ func AddPublicRoutes(
|
||||||
dendriteConfig,
|
dendriteConfig,
|
||||||
rsAPI, f, keyRing,
|
rsAPI, f, keyRing,
|
||||||
federation, userAPI, mscCfg,
|
federation, userAPI, mscCfg,
|
||||||
servers, producer, enableMetrics,
|
producer, enableMetrics,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
|
||||||
natsInstance := jetstream.NATSInstance{}
|
natsInstance := jetstream.NATSInstance{}
|
||||||
// TODO: This is pretty fragile, as if anything calls anything on these nils this test will break.
|
// TODO: This is pretty fragile, as if anything calls anything on these nils this test will break.
|
||||||
// Unfortunately, it makes little sense to instantiate these dependencies when we just want to test routing.
|
// Unfortunately, it makes little sense to instantiate these dependencies when we just want to test routing.
|
||||||
federationapi.AddPublicRoutes(processCtx, routers, cfg, &natsInstance, nil, nil, keyRing, nil, &internal.FederationInternalAPI{}, nil, caching.DisableMetrics)
|
federationapi.AddPublicRoutes(processCtx, routers, cfg, &natsInstance, nil, nil, keyRing, nil, &internal.FederationInternalAPI{}, caching.DisableMetrics)
|
||||||
baseURL, cancel := test.ListenAndServe(t, routers.Federation, true)
|
baseURL, cancel := test.ListenAndServe(t, routers.Federation, true)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
serverName := spec.ServerName(strings.TrimPrefix(baseURL, "https://"))
|
serverName := spec.ServerName(strings.TrimPrefix(baseURL, "https://"))
|
||||||
|
|
|
@ -71,7 +71,7 @@ func TestHandleQueryProfile(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("This is a programming error.")
|
panic("This is a programming error.")
|
||||||
}
|
}
|
||||||
routing.Setup(routers, cfg, nil, r, keyRing, &fedClient, &userapi, &cfg.MSCs, nil, nil, caching.DisableMetrics)
|
routing.Setup(routers, cfg, nil, r, keyRing, &fedClient, &userapi, &cfg.MSCs, nil, caching.DisableMetrics)
|
||||||
|
|
||||||
handler := fedMux.Get(routing.QueryProfileRouteName).GetHandler().ServeHTTP
|
handler := fedMux.Get(routing.QueryProfileRouteName).GetHandler().ServeHTTP
|
||||||
_, sk, _ := ed25519.GenerateKey(nil)
|
_, sk, _ := ed25519.GenerateKey(nil)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func TestHandleQueryDirectory(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("This is a programming error.")
|
panic("This is a programming error.")
|
||||||
}
|
}
|
||||||
routing.Setup(routers, cfg, nil, r, keyRing, &fedClient, &userapi, &cfg.MSCs, nil, nil, caching.DisableMetrics)
|
routing.Setup(routers, cfg, nil, r, keyRing, &fedClient, &userapi, &cfg.MSCs, nil, caching.DisableMetrics)
|
||||||
|
|
||||||
handler := fedMux.Get(routing.QueryDirectoryRouteName).GetHandler().ServeHTTP
|
handler := fedMux.Get(routing.QueryDirectoryRouteName).GetHandler().ServeHTTP
|
||||||
_, sk, _ := ed25519.GenerateKey(nil)
|
_, sk, _ := ed25519.GenerateKey(nil)
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||||
federationAPI "github.com/matrix-org/dendrite/federationapi/api"
|
|
||||||
fedInternal "github.com/matrix-org/dendrite/federationapi/internal"
|
fedInternal "github.com/matrix-org/dendrite/federationapi/internal"
|
||||||
"github.com/matrix-org/dendrite/federationapi/producers"
|
"github.com/matrix-org/dendrite/federationapi/producers"
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
|
@ -64,7 +63,6 @@ func Setup(
|
||||||
federation fclient.FederationClient,
|
federation fclient.FederationClient,
|
||||||
userAPI userapi.FederationUserAPI,
|
userAPI userapi.FederationUserAPI,
|
||||||
mscCfg *config.MSCs,
|
mscCfg *config.MSCs,
|
||||||
servers federationAPI.ServersInRoomProvider,
|
|
||||||
producer *producers.SyncAPIProducer, enableMetrics bool,
|
producer *producers.SyncAPIProducer, enableMetrics bool,
|
||||||
) {
|
) {
|
||||||
fedMux := routers.Federation
|
fedMux := routers.Federation
|
||||||
|
@ -141,7 +139,7 @@ func Setup(
|
||||||
func(httpReq *http.Request, request *fclient.FederationRequest, vars map[string]string) util.JSONResponse {
|
func(httpReq *http.Request, request *fclient.FederationRequest, vars map[string]string) util.JSONResponse {
|
||||||
return Send(
|
return Send(
|
||||||
httpReq, request, gomatrixserverlib.TransactionID(vars["txnID"]),
|
httpReq, request, gomatrixserverlib.TransactionID(vars["txnID"]),
|
||||||
cfg, rsAPI, userAPI, keys, federation, mu, servers, producer,
|
cfg, rsAPI, userAPI, keys, federation, mu, producer,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)).Methods(http.MethodPut, http.MethodOptions).Name(SendRouteName)
|
)).Methods(http.MethodPut, http.MethodOptions).Name(SendRouteName)
|
||||||
|
|
|
@ -26,7 +26,6 @@ import (
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||||
federationAPI "github.com/matrix-org/dendrite/federationapi/api"
|
|
||||||
"github.com/matrix-org/dendrite/federationapi/producers"
|
"github.com/matrix-org/dendrite/federationapi/producers"
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
@ -64,7 +63,6 @@ func Send(
|
||||||
keys gomatrixserverlib.JSONVerifier,
|
keys gomatrixserverlib.JSONVerifier,
|
||||||
federation fclient.FederationClient,
|
federation fclient.FederationClient,
|
||||||
mu *internal.MutexByRoom,
|
mu *internal.MutexByRoom,
|
||||||
servers federationAPI.ServersInRoomProvider,
|
|
||||||
producer *producers.SyncAPIProducer,
|
producer *producers.SyncAPIProducer,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
// First we should check if this origin has already submitted this
|
// First we should check if this origin has already submitted this
|
||||||
|
|
|
@ -66,7 +66,7 @@ func TestHandleSend(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("This is a programming error.")
|
panic("This is a programming error.")
|
||||||
}
|
}
|
||||||
routing.Setup(routers, cfg, nil, r, keyRing, nil, nil, &cfg.MSCs, nil, nil, caching.DisableMetrics)
|
routing.Setup(routers, cfg, nil, r, keyRing, nil, nil, &cfg.MSCs, nil, caching.DisableMetrics)
|
||||||
|
|
||||||
handler := fedMux.Get(routing.SendRouteName).GetHandler().ServeHTTP
|
handler := fedMux.Get(routing.SendRouteName).GetHandler().ServeHTTP
|
||||||
_, sk, _ := ed25519.GenerateKey(nil)
|
_, sk, _ := ed25519.GenerateKey(nil)
|
||||||
|
|
|
@ -237,7 +237,7 @@ func createInviteFrom3PIDInvite(
|
||||||
cfg *config.FederationAPI,
|
cfg *config.FederationAPI,
|
||||||
inv invite, federation fclient.FederationClient,
|
inv invite, federation fclient.FederationClient,
|
||||||
userAPI userapi.FederationUserAPI,
|
userAPI userapi.FederationUserAPI,
|
||||||
) (*gomatrixserverlib.Event, error) {
|
) (gomatrixserverlib.PDU, error) {
|
||||||
_, server, err := gomatrixserverlib.SplitID('@', inv.MXID)
|
_, server, err := gomatrixserverlib.SplitID('@', inv.MXID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -293,7 +293,7 @@ func buildMembershipEvent(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
builder *gomatrixserverlib.EventBuilder, rsAPI api.FederationRoomserverAPI,
|
builder *gomatrixserverlib.EventBuilder, rsAPI api.FederationRoomserverAPI,
|
||||||
cfg *config.FederationAPI,
|
cfg *config.FederationAPI,
|
||||||
) (*gomatrixserverlib.Event, error) {
|
) (gomatrixserverlib.PDU, error) {
|
||||||
eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder)
|
eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -22,7 +22,7 @@ require (
|
||||||
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
||||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230502133856-ad26780a085c
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230503081352-9e29bff996eb
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a
|
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a
|
||||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
||||||
github.com/mattn/go-sqlite3 v1.14.16
|
github.com/mattn/go-sqlite3 v1.14.16
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -331,6 +331,8 @@ github.com/matrix-org/gomatrixserverlib v0.0.0-20230502101247-782aebf83205 h1:fo
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230502101247-782aebf83205/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230502101247-782aebf83205/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230502133856-ad26780a085c h1:5xXMu/08j8tWfiVUvD4yfs6mepz07BgC4kL2i0oGJX4=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230502133856-ad26780a085c h1:5xXMu/08j8tWfiVUvD4yfs6mepz07BgC4kL2i0oGJX4=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230502133856-ad26780a085c/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230502133856-ad26780a085c/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
|
||||||
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230503081352-9e29bff996eb h1:qg9iR39ctvB7A4hBcddjxmHQO/t3y4mpQnpmEc3xvNI=
|
||||||
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230503081352-9e29bff996eb/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a h1:awrPDf9LEFySxTLKYBMCiObelNx/cBuv/wzllvCCH3A=
|
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a h1:awrPDf9LEFySxTLKYBMCiObelNx/cBuv/wzllvCCH3A=
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a/go.mod h1:HchJX9oKMXaT2xYFs0Ha/6Zs06mxLU8k6F1ODnrGkeQ=
|
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a/go.mod h1:HchJX9oKMXaT2xYFs0Ha/6Zs06mxLU8k6F1ODnrGkeQ=
|
||||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
||||||
|
|
|
@ -2,22 +2,21 @@ package caching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/matrix-org/dendrite/roomserver/types"
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RoomServerEventsCache contains the subset of functions needed for
|
// RoomServerEventsCache contains the subset of functions needed for
|
||||||
// a roomserver event cache.
|
// a roomserver event cache.
|
||||||
type RoomServerEventsCache interface {
|
type RoomServerEventsCache interface {
|
||||||
GetRoomServerEvent(eventNID types.EventNID) (*gomatrixserverlib.Event, bool)
|
GetRoomServerEvent(eventNID types.EventNID) (*types.HeaderedEvent, bool)
|
||||||
StoreRoomServerEvent(eventNID types.EventNID, event *gomatrixserverlib.Event)
|
StoreRoomServerEvent(eventNID types.EventNID, event *types.HeaderedEvent)
|
||||||
InvalidateRoomServerEvent(eventNID types.EventNID)
|
InvalidateRoomServerEvent(eventNID types.EventNID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Caches) GetRoomServerEvent(eventNID types.EventNID) (*gomatrixserverlib.Event, bool) {
|
func (c Caches) GetRoomServerEvent(eventNID types.EventNID) (*types.HeaderedEvent, bool) {
|
||||||
return c.RoomServerEvents.Get(int64(eventNID))
|
return c.RoomServerEvents.Get(int64(eventNID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Caches) StoreRoomServerEvent(eventNID types.EventNID, event *gomatrixserverlib.Event) {
|
func (c Caches) StoreRoomServerEvent(eventNID types.EventNID, event *types.HeaderedEvent) {
|
||||||
c.RoomServerEvents.Set(int64(eventNID), event)
|
c.RoomServerEvents.Set(int64(eventNID), event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ type Caches struct {
|
||||||
ServerKeys Cache[string, gomatrixserverlib.PublicKeyLookupResult] // server name -> server keys
|
ServerKeys Cache[string, gomatrixserverlib.PublicKeyLookupResult] // server name -> server keys
|
||||||
RoomServerRoomNIDs Cache[string, types.RoomNID] // room ID -> room NID
|
RoomServerRoomNIDs Cache[string, types.RoomNID] // room ID -> room NID
|
||||||
RoomServerRoomIDs Cache[types.RoomNID, string] // room NID -> room ID
|
RoomServerRoomIDs Cache[types.RoomNID, string] // room NID -> room ID
|
||||||
RoomServerEvents Cache[int64, *gomatrixserverlib.Event] // event NID -> event
|
RoomServerEvents Cache[int64, *types.HeaderedEvent] // event NID -> event
|
||||||
RoomServerStateKeys Cache[types.EventStateKeyNID, string] // eventStateKey NID -> event state key
|
RoomServerStateKeys Cache[types.EventStateKeyNID, string] // eventStateKey NID -> event state key
|
||||||
RoomServerStateKeyNIDs Cache[string, types.EventStateKeyNID] // event state key -> eventStateKey NID
|
RoomServerStateKeyNIDs Cache[string, types.EventStateKeyNID] // event state key -> eventStateKey NID
|
||||||
RoomServerEventTypeNIDs Cache[string, types.EventTypeNID] // eventType -> eventType NID
|
RoomServerEventTypeNIDs Cache[string, types.EventTypeNID] // eventType -> eventType NID
|
||||||
|
|
|
@ -103,8 +103,8 @@ func NewRistrettoCache(maxCost config.DataUnit, maxAge time.Duration, enableProm
|
||||||
Prefix: roomIDsCache,
|
Prefix: roomIDsCache,
|
||||||
MaxAge: maxAge,
|
MaxAge: maxAge,
|
||||||
},
|
},
|
||||||
RoomServerEvents: &RistrettoCostedCachePartition[int64, *gomatrixserverlib.Event]{ // event NID -> event
|
RoomServerEvents: &RistrettoCostedCachePartition[int64, *types.HeaderedEvent]{ // event NID -> event
|
||||||
&RistrettoCachePartition[int64, *gomatrixserverlib.Event]{
|
&RistrettoCachePartition[int64, *types.HeaderedEvent]{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
Prefix: roomEventsCache,
|
Prefix: roomEventsCache,
|
||||||
MaxAge: maxAge,
|
MaxAge: maxAge,
|
||||||
|
|
|
@ -100,7 +100,7 @@ func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, serverNam
|
||||||
func IsInvitePending(
|
func IsInvitePending(
|
||||||
ctx context.Context, db storage.Database,
|
ctx context.Context, db storage.Database,
|
||||||
roomID, userID string,
|
roomID, userID string,
|
||||||
) (bool, string, string, *gomatrixserverlib.Event, error) {
|
) (bool, string, string, gomatrixserverlib.PDU, error) {
|
||||||
// Look up the room NID for the supplied room ID.
|
// Look up the room NID for the supplied room ID.
|
||||||
info, err := db.RoomInfo(ctx, roomID)
|
info, err := db.RoomInfo(ctx, roomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -856,7 +856,7 @@ func (t *missingStateReq) lookupEvent(ctx context.Context, roomVersion gomatrixs
|
||||||
return events[0].PDU, nil
|
return events[0].PDU, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var event *gomatrixserverlib.Event
|
var event gomatrixserverlib.PDU
|
||||||
found := false
|
found := false
|
||||||
for _, serverName := range t.servers {
|
for _, serverName := range t.servers {
|
||||||
reqctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
reqctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||||
|
|
|
@ -473,7 +473,7 @@ func (r *Upgrader) sendInitialEvents(ctx context.Context, evTime time.Time, user
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
builder.PrevEvents = []gomatrixserverlib.EventReference{builtEvents[i-1].EventReference()}
|
builder.PrevEvents = []gomatrixserverlib.EventReference{builtEvents[i-1].EventReference()}
|
||||||
}
|
}
|
||||||
var event *gomatrixserverlib.Event
|
var event gomatrixserverlib.PDU
|
||||||
event, err = builder.AddAuthEventsAndBuild(userDomain, &authEvents, evTime, newVersion, r.Cfg.Matrix.KeyID, r.Cfg.Matrix.PrivateKey)
|
event, err = builder.AddAuthEventsAndBuild(userDomain, &authEvents, evTime, newVersion, r.Cfg.Matrix.KeyID, r.Cfg.Matrix.PrivateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to build new %q event: %w", builder.Type, err)
|
return fmt.Errorf("failed to build new %q event: %w", builder.Type, err)
|
||||||
|
|
|
@ -26,12 +26,12 @@ import (
|
||||||
|
|
||||||
// used to implement RoomserverInternalAPIEventDB to test getAuthChain
|
// used to implement RoomserverInternalAPIEventDB to test getAuthChain
|
||||||
type getEventDB struct {
|
type getEventDB struct {
|
||||||
eventMap map[string]*gomatrixserverlib.Event
|
eventMap map[string]gomatrixserverlib.PDU
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEventDB() *getEventDB {
|
func createEventDB() *getEventDB {
|
||||||
return &getEventDB{
|
return &getEventDB{
|
||||||
eventMap: make(map[string]*gomatrixserverlib.Event),
|
eventMap: make(map[string]gomatrixserverlib.PDU),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -543,7 +543,7 @@ func (d *EventDatabase) events(
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(inputEventNIDs)
|
sort.Sort(inputEventNIDs)
|
||||||
events := make(map[types.EventNID]*gomatrixserverlib.Event, len(inputEventNIDs))
|
events := make(map[types.EventNID]gomatrixserverlib.PDU, len(inputEventNIDs))
|
||||||
eventNIDs := make([]types.EventNID, 0, len(inputEventNIDs))
|
eventNIDs := make([]types.EventNID, 0, len(inputEventNIDs))
|
||||||
for _, nid := range inputEventNIDs {
|
for _, nid := range inputEventNIDs {
|
||||||
if event, ok := d.Cache.GetRoomServerEvent(nid); ok && event != nil {
|
if event, ok := d.Cache.GetRoomServerEvent(nid); ok && event != nil {
|
||||||
|
@ -593,7 +593,7 @@ func (d *EventDatabase) events(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if event := events[eventJSON.EventNID]; event != nil {
|
if event := events[eventJSON.EventNID]; event != nil {
|
||||||
d.Cache.StoreRoomServerEvent(eventJSON.EventNID, event)
|
d.Cache.StoreRoomServerEvent(eventJSON.EventNID, &types.HeaderedEvent{PDU: event})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results := make([]types.Event, 0, len(inputEventNIDs))
|
results := make([]types.Event, 0, len(inputEventNIDs))
|
||||||
|
|
|
@ -76,7 +76,7 @@ func (m *Monolith) AddAllPublicRoutes(
|
||||||
m.ExtPublicRoomsProvider, enableMetrics,
|
m.ExtPublicRoomsProvider, enableMetrics,
|
||||||
)
|
)
|
||||||
federationapi.AddPublicRoutes(
|
federationapi.AddPublicRoutes(
|
||||||
processCtx, routers, cfg, natsInstance, m.UserAPI, m.FedClient, m.KeyRing, m.RoomserverAPI, m.FederationAPI, nil, enableMetrics,
|
processCtx, routers, cfg, natsInstance, m.UserAPI, m.FedClient, m.KeyRing, m.RoomserverAPI, m.FederationAPI, enableMetrics,
|
||||||
)
|
)
|
||||||
mediaapi.AddPublicRoutes(routers.Media, cm, cfg, m.UserAPI, m.Client)
|
mediaapi.AddPublicRoutes(routers.Media, cm, cfg, m.UserAPI, m.Client)
|
||||||
syncapi.AddPublicRoutes(processCtx, routers, cfg, cm, natsInstance, m.UserAPI, m.RoomserverAPI, caches, enableMetrics)
|
syncapi.AddPublicRoutes(processCtx, routers, cfg, cm, natsInstance, m.UserAPI, m.RoomserverAPI, caches, enableMetrics)
|
||||||
|
|
|
@ -79,7 +79,7 @@ func (n *Notifier) SetCurrentPosition(currPos types.StreamingToken) {
|
||||||
// OnNewEvent is called when a new event is received from the room server. Must only be
|
// OnNewEvent is called when a new event is received from the room server. Must only be
|
||||||
// called from a single goroutine, to avoid races between updates which could set the
|
// called from a single goroutine, to avoid races between updates which could set the
|
||||||
// current sync position incorrectly.
|
// current sync position incorrectly.
|
||||||
// Chooses which user sync streams to update by a provided *gomatrixserverlib.Event
|
// Chooses which user sync streams to update by a provided gomatrixserverlib.PDU
|
||||||
// (based on the users in the event's room),
|
// (based on the users in the event's room),
|
||||||
// a roomID directly, or a list of user IDs, prioritised by parameter ordering.
|
// a roomID directly, or a list of user IDs, prioritised by parameter ordering.
|
||||||
// posUpdate contains the latest position(s) for one or more types of events.
|
// posUpdate contains the latest position(s) for one or more types of events.
|
||||||
|
|
Loading…
Reference in a new issue