mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
refactor: update GMSL (#3058)
Sister PR to https://github.com/matrix-org/gomatrixserverlib/pull/364 Read this commit by commit to avoid going insane.
This commit is contained in:
parent
9fa39263c0
commit
72285b2659
306 changed files with 2117 additions and 1934 deletions
|
@ -21,11 +21,12 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
type eventMods struct {
|
||||
originServerTS time.Time
|
||||
origin gomatrixserverlib.ServerName
|
||||
origin spec.ServerName
|
||||
stateKey *string
|
||||
unsigned interface{}
|
||||
keyID gomatrixserverlib.KeyID
|
||||
|
@ -71,7 +72,7 @@ func WithPrivateKey(pkey ed25519.PrivateKey) eventModifier {
|
|||
}
|
||||
}
|
||||
|
||||
func WithOrigin(origin gomatrixserverlib.ServerName) eventModifier {
|
||||
func WithOrigin(origin spec.ServerName) eventModifier {
|
||||
return func(e *eventMods) {
|
||||
e.origin = origin
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/federationapi/storage/shared/receipt"
|
||||
"github.com/matrix-org/dendrite/federationapi/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
var nidMutex sync.Mutex
|
||||
|
@ -31,28 +32,28 @@ var nid = int64(0)
|
|||
|
||||
type InMemoryFederationDatabase struct {
|
||||
dbMutex sync.Mutex
|
||||
pendingPDUServers map[gomatrixserverlib.ServerName]struct{}
|
||||
pendingEDUServers map[gomatrixserverlib.ServerName]struct{}
|
||||
blacklistedServers map[gomatrixserverlib.ServerName]struct{}
|
||||
assumedOffline map[gomatrixserverlib.ServerName]struct{}
|
||||
pendingPDUServers map[spec.ServerName]struct{}
|
||||
pendingEDUServers map[spec.ServerName]struct{}
|
||||
blacklistedServers map[spec.ServerName]struct{}
|
||||
assumedOffline map[spec.ServerName]struct{}
|
||||
pendingPDUs map[*receipt.Receipt]*gomatrixserverlib.HeaderedEvent
|
||||
pendingEDUs map[*receipt.Receipt]*gomatrixserverlib.EDU
|
||||
associatedPDUs map[gomatrixserverlib.ServerName]map[*receipt.Receipt]struct{}
|
||||
associatedEDUs map[gomatrixserverlib.ServerName]map[*receipt.Receipt]struct{}
|
||||
relayServers map[gomatrixserverlib.ServerName][]gomatrixserverlib.ServerName
|
||||
associatedPDUs map[spec.ServerName]map[*receipt.Receipt]struct{}
|
||||
associatedEDUs map[spec.ServerName]map[*receipt.Receipt]struct{}
|
||||
relayServers map[spec.ServerName][]spec.ServerName
|
||||
}
|
||||
|
||||
func NewInMemoryFederationDatabase() *InMemoryFederationDatabase {
|
||||
return &InMemoryFederationDatabase{
|
||||
pendingPDUServers: make(map[gomatrixserverlib.ServerName]struct{}),
|
||||
pendingEDUServers: make(map[gomatrixserverlib.ServerName]struct{}),
|
||||
blacklistedServers: make(map[gomatrixserverlib.ServerName]struct{}),
|
||||
assumedOffline: make(map[gomatrixserverlib.ServerName]struct{}),
|
||||
pendingPDUServers: make(map[spec.ServerName]struct{}),
|
||||
pendingEDUServers: make(map[spec.ServerName]struct{}),
|
||||
blacklistedServers: make(map[spec.ServerName]struct{}),
|
||||
assumedOffline: make(map[spec.ServerName]struct{}),
|
||||
pendingPDUs: make(map[*receipt.Receipt]*gomatrixserverlib.HeaderedEvent),
|
||||
pendingEDUs: make(map[*receipt.Receipt]*gomatrixserverlib.EDU),
|
||||
associatedPDUs: make(map[gomatrixserverlib.ServerName]map[*receipt.Receipt]struct{}),
|
||||
associatedEDUs: make(map[gomatrixserverlib.ServerName]map[*receipt.Receipt]struct{}),
|
||||
relayServers: make(map[gomatrixserverlib.ServerName][]gomatrixserverlib.ServerName),
|
||||
associatedPDUs: make(map[spec.ServerName]map[*receipt.Receipt]struct{}),
|
||||
associatedEDUs: make(map[spec.ServerName]map[*receipt.Receipt]struct{}),
|
||||
relayServers: make(map[spec.ServerName][]spec.ServerName),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +89,7 @@ func (d *InMemoryFederationDatabase) StoreJSON(
|
|||
|
||||
func (d *InMemoryFederationDatabase) GetPendingPDUs(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
limit int,
|
||||
) (pdus map[*receipt.Receipt]*gomatrixserverlib.HeaderedEvent, err error) {
|
||||
d.dbMutex.Lock()
|
||||
|
@ -112,7 +113,7 @@ func (d *InMemoryFederationDatabase) GetPendingPDUs(
|
|||
|
||||
func (d *InMemoryFederationDatabase) GetPendingEDUs(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
limit int,
|
||||
) (edus map[*receipt.Receipt]*gomatrixserverlib.EDU, err error) {
|
||||
d.dbMutex.Lock()
|
||||
|
@ -136,7 +137,7 @@ func (d *InMemoryFederationDatabase) GetPendingEDUs(
|
|||
|
||||
func (d *InMemoryFederationDatabase) AssociatePDUWithDestinations(
|
||||
ctx context.Context,
|
||||
destinations map[gomatrixserverlib.ServerName]struct{},
|
||||
destinations map[spec.ServerName]struct{},
|
||||
dbReceipt *receipt.Receipt,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
|
@ -158,7 +159,7 @@ func (d *InMemoryFederationDatabase) AssociatePDUWithDestinations(
|
|||
|
||||
func (d *InMemoryFederationDatabase) AssociateEDUWithDestinations(
|
||||
ctx context.Context,
|
||||
destinations map[gomatrixserverlib.ServerName]struct{},
|
||||
destinations map[spec.ServerName]struct{},
|
||||
dbReceipt *receipt.Receipt,
|
||||
eduType string,
|
||||
expireEDUTypes map[string]time.Duration,
|
||||
|
@ -182,7 +183,7 @@ func (d *InMemoryFederationDatabase) AssociateEDUWithDestinations(
|
|||
|
||||
func (d *InMemoryFederationDatabase) CleanPDUs(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
receipts []*receipt.Receipt,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
|
@ -199,7 +200,7 @@ func (d *InMemoryFederationDatabase) CleanPDUs(
|
|||
|
||||
func (d *InMemoryFederationDatabase) CleanEDUs(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
receipts []*receipt.Receipt,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
|
@ -216,7 +217,7 @@ func (d *InMemoryFederationDatabase) CleanEDUs(
|
|||
|
||||
func (d *InMemoryFederationDatabase) GetPendingPDUCount(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) (int64, error) {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -230,7 +231,7 @@ func (d *InMemoryFederationDatabase) GetPendingPDUCount(
|
|||
|
||||
func (d *InMemoryFederationDatabase) GetPendingEDUCount(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) (int64, error) {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -244,11 +245,11 @@ func (d *InMemoryFederationDatabase) GetPendingEDUCount(
|
|||
|
||||
func (d *InMemoryFederationDatabase) GetPendingPDUServerNames(
|
||||
ctx context.Context,
|
||||
) ([]gomatrixserverlib.ServerName, error) {
|
||||
) ([]spec.ServerName, error) {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
||||
servers := []gomatrixserverlib.ServerName{}
|
||||
servers := []spec.ServerName{}
|
||||
for server := range d.pendingPDUServers {
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
@ -257,11 +258,11 @@ func (d *InMemoryFederationDatabase) GetPendingPDUServerNames(
|
|||
|
||||
func (d *InMemoryFederationDatabase) GetPendingEDUServerNames(
|
||||
ctx context.Context,
|
||||
) ([]gomatrixserverlib.ServerName, error) {
|
||||
) ([]spec.ServerName, error) {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
||||
servers := []gomatrixserverlib.ServerName{}
|
||||
servers := []spec.ServerName{}
|
||||
for server := range d.pendingEDUServers {
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
@ -269,7 +270,7 @@ func (d *InMemoryFederationDatabase) GetPendingEDUServerNames(
|
|||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) AddServerToBlacklist(
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -279,7 +280,7 @@ func (d *InMemoryFederationDatabase) AddServerToBlacklist(
|
|||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) RemoveServerFromBlacklist(
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -292,12 +293,12 @@ func (d *InMemoryFederationDatabase) RemoveAllServersFromBlacklist() error {
|
|||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
||||
d.blacklistedServers = make(map[gomatrixserverlib.ServerName]struct{})
|
||||
d.blacklistedServers = make(map[spec.ServerName]struct{})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) IsServerBlacklisted(
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) (bool, error) {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -312,7 +313,7 @@ func (d *InMemoryFederationDatabase) IsServerBlacklisted(
|
|||
|
||||
func (d *InMemoryFederationDatabase) SetServerAssumedOffline(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -323,7 +324,7 @@ func (d *InMemoryFederationDatabase) SetServerAssumedOffline(
|
|||
|
||||
func (d *InMemoryFederationDatabase) RemoveServerAssumedOffline(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -338,13 +339,13 @@ func (d *InMemoryFederationDatabase) RemoveAllServersAssumedOffine(
|
|||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
||||
d.assumedOffline = make(map[gomatrixserverlib.ServerName]struct{})
|
||||
d.assumedOffline = make(map[spec.ServerName]struct{})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) IsServerAssumedOffline(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) (bool, error) {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -359,12 +360,12 @@ func (d *InMemoryFederationDatabase) IsServerAssumedOffline(
|
|||
|
||||
func (d *InMemoryFederationDatabase) P2PGetRelayServersForServer(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
) ([]gomatrixserverlib.ServerName, error) {
|
||||
serverName spec.ServerName,
|
||||
) ([]spec.ServerName, error) {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
||||
knownRelayServers := []gomatrixserverlib.ServerName{}
|
||||
knownRelayServers := []spec.ServerName{}
|
||||
if relayServers, ok := d.relayServers[serverName]; ok {
|
||||
knownRelayServers = relayServers
|
||||
}
|
||||
|
@ -374,8 +375,8 @@ func (d *InMemoryFederationDatabase) P2PGetRelayServersForServer(
|
|||
|
||||
func (d *InMemoryFederationDatabase) P2PAddRelayServersForServer(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
relayServers []gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
relayServers []spec.ServerName,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -401,8 +402,8 @@ func (d *InMemoryFederationDatabase) P2PAddRelayServersForServer(
|
|||
|
||||
func (d *InMemoryFederationDatabase) P2PRemoveRelayServersForServer(
|
||||
ctx context.Context,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
relayServers []gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
relayServers []spec.ServerName,
|
||||
) error {
|
||||
d.dbMutex.Lock()
|
||||
defer d.dbMutex.Unlock()
|
||||
|
@ -426,7 +427,7 @@ func (d *InMemoryFederationDatabase) P2PRemoveRelayServersForServer(
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) FetchKeys(ctx context.Context, requests map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp) (map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult, error) {
|
||||
func (d *InMemoryFederationDatabase) FetchKeys(ctx context.Context, requests map[gomatrixserverlib.PublicKeyLookupRequest]spec.Timestamp) (map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -446,11 +447,11 @@ func (d *InMemoryFederationDatabase) GetJoinedHosts(ctx context.Context, roomID
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) GetAllJoinedHosts(ctx context.Context) ([]gomatrixserverlib.ServerName, error) {
|
||||
func (d *InMemoryFederationDatabase) GetAllJoinedHosts(ctx context.Context) ([]spec.ServerName, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) GetJoinedHostsForRooms(ctx context.Context, roomIDs []string, excludeSelf, excludeBlacklisted bool) ([]gomatrixserverlib.ServerName, error) {
|
||||
func (d *InMemoryFederationDatabase) GetJoinedHostsForRooms(ctx context.Context, roomIDs []string, excludeSelf, excludeBlacklisted bool) ([]spec.ServerName, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -458,19 +459,19 @@ func (d *InMemoryFederationDatabase) RemoveAllServersAssumedOffline(ctx context.
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) P2PRemoveAllRelayServersForServer(ctx context.Context, serverName gomatrixserverlib.ServerName) error {
|
||||
func (d *InMemoryFederationDatabase) P2PRemoveAllRelayServersForServer(ctx context.Context, serverName spec.ServerName) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) AddOutboundPeek(ctx context.Context, serverName gomatrixserverlib.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
func (d *InMemoryFederationDatabase) AddOutboundPeek(ctx context.Context, serverName spec.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) RenewOutboundPeek(ctx context.Context, serverName gomatrixserverlib.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
func (d *InMemoryFederationDatabase) RenewOutboundPeek(ctx context.Context, serverName spec.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) GetOutboundPeek(ctx context.Context, serverName gomatrixserverlib.ServerName, roomID, peekID string) (*types.OutboundPeek, error) {
|
||||
func (d *InMemoryFederationDatabase) GetOutboundPeek(ctx context.Context, serverName spec.ServerName, roomID, peekID string) (*types.OutboundPeek, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -478,15 +479,15 @@ func (d *InMemoryFederationDatabase) GetOutboundPeeks(ctx context.Context, roomI
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) AddInboundPeek(ctx context.Context, serverName gomatrixserverlib.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
func (d *InMemoryFederationDatabase) AddInboundPeek(ctx context.Context, serverName spec.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) RenewInboundPeek(ctx context.Context, serverName gomatrixserverlib.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
func (d *InMemoryFederationDatabase) RenewInboundPeek(ctx context.Context, serverName spec.ServerName, roomID, peekID string, renewalInterval int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) GetInboundPeek(ctx context.Context, serverName gomatrixserverlib.ServerName, roomID, peekID string) (*types.InboundPeek, error) {
|
||||
func (d *InMemoryFederationDatabase) GetInboundPeek(ctx context.Context, serverName spec.ServerName, roomID, peekID string) (*types.InboundPeek, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -494,11 +495,11 @@ func (d *InMemoryFederationDatabase) GetInboundPeeks(ctx context.Context, roomID
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) UpdateNotaryKeys(ctx context.Context, serverName gomatrixserverlib.ServerName, serverKeys gomatrixserverlib.ServerKeys) error {
|
||||
func (d *InMemoryFederationDatabase) UpdateNotaryKeys(ctx context.Context, serverName spec.ServerName, serverKeys gomatrixserverlib.ServerKeys) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemoryFederationDatabase) GetNotaryKeys(ctx context.Context, serverName gomatrixserverlib.ServerName, optKeyIDs []gomatrixserverlib.KeyID) ([]gomatrixserverlib.ServerKeys, error) {
|
||||
func (d *InMemoryFederationDatabase) GetNotaryKeys(ctx context.Context, serverName spec.ServerName, optKeyIDs []gomatrixserverlib.KeyID) ([]gomatrixserverlib.ServerKeys, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,14 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
type InMemoryRelayDatabase struct {
|
||||
nid int64
|
||||
nidMutex sync.Mutex
|
||||
transactions map[int64]json.RawMessage
|
||||
associations map[gomatrixserverlib.ServerName][]int64
|
||||
associations map[spec.ServerName][]int64
|
||||
}
|
||||
|
||||
func NewInMemoryRelayDatabase() *InMemoryRelayDatabase {
|
||||
|
@ -35,7 +36,7 @@ func NewInMemoryRelayDatabase() *InMemoryRelayDatabase {
|
|||
nid: 1,
|
||||
nidMutex: sync.Mutex{},
|
||||
transactions: make(map[int64]json.RawMessage),
|
||||
associations: make(map[gomatrixserverlib.ServerName][]int64),
|
||||
associations: make(map[spec.ServerName][]int64),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +44,7 @@ func (d *InMemoryRelayDatabase) InsertQueueEntry(
|
|||
ctx context.Context,
|
||||
txn *sql.Tx,
|
||||
transactionID gomatrixserverlib.TransactionID,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
nid int64,
|
||||
) error {
|
||||
if _, ok := d.associations[serverName]; !ok {
|
||||
|
@ -56,7 +57,7 @@ func (d *InMemoryRelayDatabase) InsertQueueEntry(
|
|||
func (d *InMemoryRelayDatabase) DeleteQueueEntries(
|
||||
ctx context.Context,
|
||||
txn *sql.Tx,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
jsonNIDs []int64,
|
||||
) error {
|
||||
for _, nid := range jsonNIDs {
|
||||
|
@ -72,7 +73,7 @@ func (d *InMemoryRelayDatabase) DeleteQueueEntries(
|
|||
|
||||
func (d *InMemoryRelayDatabase) SelectQueueEntries(
|
||||
ctx context.Context,
|
||||
txn *sql.Tx, serverName gomatrixserverlib.ServerName,
|
||||
txn *sql.Tx, serverName spec.ServerName,
|
||||
limit int,
|
||||
) ([]int64, error) {
|
||||
results := []int64{}
|
||||
|
@ -92,7 +93,7 @@ func (d *InMemoryRelayDatabase) SelectQueueEntries(
|
|||
func (d *InMemoryRelayDatabase) SelectQueueEntryCount(
|
||||
ctx context.Context,
|
||||
txn *sql.Tx,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) (int64, error) {
|
||||
return int64(len(d.associations[serverName])), nil
|
||||
}
|
||||
|
|
15
test/room.go
15
test/room.go
|
@ -22,6 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal/eventutil"
|
||||
)
|
||||
|
@ -111,18 +112,18 @@ func (r *Room) insertCreateEvents(t *testing.T) {
|
|||
hisVis.HistoryVisibility = r.visibility
|
||||
}
|
||||
|
||||
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomCreate, map[string]interface{}{
|
||||
r.CreateAndInsert(t, r.creator, spec.MRoomCreate, map[string]interface{}{
|
||||
"creator": r.creator.ID,
|
||||
"room_version": r.Version,
|
||||
}, WithStateKey(""))
|
||||
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomMember, map[string]interface{}{
|
||||
r.CreateAndInsert(t, r.creator, spec.MRoomMember, map[string]interface{}{
|
||||
"membership": "join",
|
||||
}, WithStateKey(r.creator.ID))
|
||||
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomPowerLevels, plContent, WithStateKey(""))
|
||||
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomJoinRules, joinRule, WithStateKey(""))
|
||||
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomHistoryVisibility, hisVis, WithStateKey(""))
|
||||
r.CreateAndInsert(t, r.creator, spec.MRoomPowerLevels, plContent, WithStateKey(""))
|
||||
r.CreateAndInsert(t, r.creator, spec.MRoomJoinRules, joinRule, WithStateKey(""))
|
||||
r.CreateAndInsert(t, r.creator, spec.MRoomHistoryVisibility, hisVis, WithStateKey(""))
|
||||
if r.guestCanJoin {
|
||||
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomGuestAccess, map[string]string{
|
||||
r.CreateAndInsert(t, r.creator, spec.MRoomGuestAccess, map[string]string{
|
||||
"guest_access": "can_join",
|
||||
}, WithStateKey(""))
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, conten
|
|||
mod.origin = creator.srvName
|
||||
}
|
||||
|
||||
var unsigned gomatrixserverlib.RawJSON
|
||||
var unsigned spec.RawJSON
|
||||
var err error
|
||||
if mod.unsigned != nil {
|
||||
unsigned, err = json.Marshal(mod.unsigned)
|
||||
|
|
|
@ -23,12 +23,13 @@ import (
|
|||
|
||||
"github.com/matrix-org/dendrite/userapi/api"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
var (
|
||||
userIDCounter = int64(0)
|
||||
|
||||
serverName = gomatrixserverlib.ServerName("test")
|
||||
serverName = spec.ServerName("test")
|
||||
keyID = gomatrixserverlib.KeyID("ed25519:test")
|
||||
privateKey = ed25519.NewKeyFromSeed([]byte{
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
|
@ -53,12 +54,12 @@ type User struct {
|
|||
// key ID and private key of the server who has this user, if known.
|
||||
keyID gomatrixserverlib.KeyID
|
||||
privKey ed25519.PrivateKey
|
||||
srvName gomatrixserverlib.ServerName
|
||||
srvName spec.ServerName
|
||||
}
|
||||
|
||||
type UserOpt func(*User)
|
||||
|
||||
func WithSigningServer(srvName gomatrixserverlib.ServerName, keyID gomatrixserverlib.KeyID, privKey ed25519.PrivateKey) UserOpt {
|
||||
func WithSigningServer(srvName spec.ServerName, keyID gomatrixserverlib.KeyID, privKey ed25519.PrivateKey) UserOpt {
|
||||
return func(u *User) {
|
||||
u.keyID = keyID
|
||||
u.privKey = privKey
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue