aboutsummaryrefslogtreecommitdiff
path: root/syncapi/storage
diff options
context:
space:
mode:
Diffstat (limited to 'syncapi/storage')
-rw-r--r--syncapi/storage/interface.go5
-rw-r--r--syncapi/storage/postgres/current_room_state_table.go5
-rw-r--r--syncapi/storage/postgres/presence_table.go6
-rw-r--r--syncapi/storage/postgres/receipt_table.go4
-rw-r--r--syncapi/storage/shared/storage_consumer.go11
-rw-r--r--syncapi/storage/shared/storage_sync.go33
-rw-r--r--syncapi/storage/sqlite3/current_room_state_table.go5
-rw-r--r--syncapi/storage/sqlite3/presence_table.go6
-rw-r--r--syncapi/storage/sqlite3/receipt_table.go4
-rw-r--r--syncapi/storage/storage_test.go39
-rw-r--r--syncapi/storage/tables/current_room_state_test.go4
-rw-r--r--syncapi/storage/tables/interface.go5
-rw-r--r--syncapi/storage/tables/memberships_test.go17
-rw-r--r--syncapi/storage/tables/output_room_events_test.go9
-rw-r--r--syncapi/storage/tables/presence_table_test.go5
15 files changed, 83 insertions, 75 deletions
diff --git a/syncapi/storage/interface.go b/syncapi/storage/interface.go
index 38c04e85..f5c1223a 100644
--- a/syncapi/storage/interface.go
+++ b/syncapi/storage/interface.go
@@ -18,6 +18,7 @@ import (
"context"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/matrix-org/dendrite/internal/eventutil"
"github.com/matrix-org/dendrite/internal/sqlutil"
@@ -174,7 +175,7 @@ type Database interface {
// RedactEvent wipes an event in the database and sets the unsigned.redacted_because key to the redaction event
RedactEvent(ctx context.Context, redactedEventID string, redactedBecause *gomatrixserverlib.HeaderedEvent) error
// StoreReceipt stores new receipt events
- StoreReceipt(ctx context.Context, roomId, receiptType, userId, eventId string, timestamp gomatrixserverlib.Timestamp) (pos types.StreamPosition, err error)
+ StoreReceipt(ctx context.Context, roomId, receiptType, userId, eventId string, timestamp spec.Timestamp) (pos types.StreamPosition, err error)
UpdateIgnoresForUser(ctx context.Context, userID string, ignores *types.IgnoredUsers) error
ReIndex(ctx context.Context, limit, afterID int64) (map[int64]gomatrixserverlib.HeaderedEvent, error)
UpdateRelations(ctx context.Context, event *gomatrixserverlib.HeaderedEvent) error
@@ -188,7 +189,7 @@ type Database interface {
type Presence interface {
GetPresences(ctx context.Context, userIDs []string) ([]*types.PresenceInternal, error)
- UpdatePresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, lastActiveTS gomatrixserverlib.Timestamp, fromSync bool) (types.StreamPosition, error)
+ UpdatePresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, lastActiveTS spec.Timestamp, fromSync bool) (types.StreamPosition, error)
}
type SharedUsers interface {
diff --git a/syncapi/storage/postgres/current_room_state_table.go b/syncapi/storage/postgres/current_room_state_table.go
index b0547758..c2a870c0 100644
--- a/syncapi/storage/postgres/current_room_state_table.go
+++ b/syncapi/storage/postgres/current_room_state_table.go
@@ -29,6 +29,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/synctypes"
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
)
const currentRoomStateSchema = `
@@ -278,9 +279,9 @@ func (s *currentRoomStateStatements) SelectCurrentState(
senders, notSenders := getSendersStateFilterFilter(stateFilter)
// We're going to query members later, so remove them from this request
if stateFilter.LazyLoadMembers && !stateFilter.IncludeRedundantMembers {
- notTypes := &[]string{gomatrixserverlib.MRoomMember}
+ notTypes := &[]string{spec.MRoomMember}
if stateFilter.NotTypes != nil {
- *stateFilter.NotTypes = append(*stateFilter.NotTypes, gomatrixserverlib.MRoomMember)
+ *stateFilter.NotTypes = append(*stateFilter.NotTypes, spec.MRoomMember)
} else {
stateFilter.NotTypes = notTypes
}
diff --git a/syncapi/storage/postgres/presence_table.go b/syncapi/storage/postgres/presence_table.go
index 3dba7756..f37b5331 100644
--- a/syncapi/storage/postgres/presence_table.go
+++ b/syncapi/storage/postgres/presence_table.go
@@ -20,7 +20,7 @@ import (
"time"
"github.com/lib/pq"
- "github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
@@ -109,7 +109,7 @@ func (p *presenceStatements) UpsertPresence(
userID string,
statusMsg *string,
presence types.Presence,
- lastActiveTS gomatrixserverlib.Timestamp,
+ lastActiveTS spec.Timestamp,
fromSync bool,
) (pos types.StreamPosition, err error) {
if fromSync {
@@ -161,7 +161,7 @@ func (p *presenceStatements) GetPresenceAfter(
) (presences map[string]*types.PresenceInternal, err error) {
presences = make(map[string]*types.PresenceInternal)
stmt := sqlutil.TxStmt(txn, p.selectPresenceAfterStmt)
- afterTS := gomatrixserverlib.AsTimestamp(time.Now().Add(time.Minute * -5))
+ afterTS := spec.AsTimestamp(time.Now().Add(time.Minute * -5))
rows, err := stmt.QueryContext(ctx, after, afterTS, filter.Limit)
if err != nil {
return nil, err
diff --git a/syncapi/storage/postgres/receipt_table.go b/syncapi/storage/postgres/receipt_table.go
index 0fcbebfc..9ab8eece 100644
--- a/syncapi/storage/postgres/receipt_table.go
+++ b/syncapi/storage/postgres/receipt_table.go
@@ -26,7 +26,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/storage/postgres/deltas"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
"github.com/matrix-org/dendrite/syncapi/types"
- "github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
)
const receiptsSchema = `
@@ -98,7 +98,7 @@ func NewPostgresReceiptsTable(db *sql.DB) (tables.Receipts, error) {
}.Prepare(db)
}
-func (r *receiptStatements) UpsertReceipt(ctx context.Context, txn *sql.Tx, roomId, receiptType, userId, eventId string, timestamp gomatrixserverlib.Timestamp) (pos types.StreamPosition, err error) {
+func (r *receiptStatements) UpsertReceipt(ctx context.Context, txn *sql.Tx, roomId, receiptType, userId, eventId string, timestamp spec.Timestamp) (pos types.StreamPosition, err error) {
stmt := sqlutil.TxStmt(txn, r.upsertReceipt)
err = stmt.QueryRowContext(ctx, roomId, receiptType, userId, eventId, timestamp).Scan(&pos)
return
diff --git a/syncapi/storage/shared/storage_consumer.go b/syncapi/storage/shared/storage_consumer.go
index 1894a094..47490fb0 100644
--- a/syncapi/storage/shared/storage_consumer.go
+++ b/syncapi/storage/shared/storage_consumer.go
@@ -23,6 +23,7 @@ import (
"github.com/tidwall/gjson"
userapi "github.com/matrix-org/dendrite/userapi/api"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
@@ -504,7 +505,7 @@ func getMembershipFromEvent(ev *gomatrixserverlib.Event, userID string) (string,
}
// StoreReceipt stores user receipts
-func (d *Database) StoreReceipt(ctx context.Context, roomId, receiptType, userId, eventId string, timestamp gomatrixserverlib.Timestamp) (pos types.StreamPosition, err error) {
+func (d *Database) StoreReceipt(ctx context.Context, roomId, receiptType, userId, eventId string, timestamp spec.Timestamp) (pos types.StreamPosition, err error) {
err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
pos, err = d.Receipts.UpsertReceipt(ctx, txn, roomId, receiptType, userId, eventId, timestamp)
return err
@@ -541,7 +542,7 @@ func (d *Database) UpdateIgnoresForUser(ctx context.Context, userID string, igno
})
}
-func (d *Database) UpdatePresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, lastActiveTS gomatrixserverlib.Timestamp, fromSync bool) (types.StreamPosition, error) {
+func (d *Database) UpdatePresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, lastActiveTS spec.Timestamp, fromSync bool) (types.StreamPosition, error) {
var pos types.StreamPosition
var err error
_ = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
@@ -561,15 +562,15 @@ func (d *Database) SelectMembershipForUser(ctx context.Context, roomID, userID s
func (d *Database) ReIndex(ctx context.Context, limit, afterID int64) (map[int64]gomatrixserverlib.HeaderedEvent, error) {
return d.OutputEvents.ReIndex(ctx, nil, limit, afterID, []string{
- gomatrixserverlib.MRoomName,
- gomatrixserverlib.MRoomTopic,
+ spec.MRoomName,
+ spec.MRoomTopic,
"m.room.message",
})
}
func (d *Database) UpdateRelations(ctx context.Context, event *gomatrixserverlib.HeaderedEvent) error {
// No need to unmarshal if the event is a redaction
- if event.Type() == gomatrixserverlib.MRoomRedaction {
+ if event.Type() == spec.MRoomRedaction {
return nil
}
var content gomatrixserverlib.RelationContent
diff --git a/syncapi/storage/shared/storage_sync.go b/syncapi/storage/shared/storage_sync.go
index a614544b..f11cbb57 100644
--- a/syncapi/storage/shared/storage_sync.go
+++ b/syncapi/storage/shared/storage_sync.go
@@ -7,6 +7,7 @@ import (
"math"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/tidwall/gjson"
"github.com/matrix-org/dendrite/internal/eventutil"
@@ -98,11 +99,11 @@ func (d *DatabaseTransaction) MembershipCount(ctx context.Context, roomID, membe
func (d *DatabaseTransaction) GetRoomSummary(ctx context.Context, roomID, userID string) (*types.Summary, error) {
summary := &types.Summary{Heroes: []string{}}
- joinCount, err := d.CurrentRoomState.SelectMembershipCount(ctx, d.txn, roomID, gomatrixserverlib.Join)
+ joinCount, err := d.CurrentRoomState.SelectMembershipCount(ctx, d.txn, roomID, spec.Join)
if err != nil {
return summary, err
}
- inviteCount, err := d.CurrentRoomState.SelectMembershipCount(ctx, d.txn, roomID, gomatrixserverlib.Invite)
+ inviteCount, err := d.CurrentRoomState.SelectMembershipCount(ctx, d.txn, roomID, spec.Invite)
if err != nil {
return summary, err
}
@@ -111,7 +112,7 @@ func (d *DatabaseTransaction) GetRoomSummary(ctx context.Context, roomID, userID
// Get the room name and canonical alias, if any
filter := synctypes.DefaultStateFilter()
- filterTypes := []string{gomatrixserverlib.MRoomName, gomatrixserverlib.MRoomCanonicalAlias}
+ filterTypes := []string{spec.MRoomName, spec.MRoomCanonicalAlias}
filterRooms := []string{roomID}
filter.Types = &filterTypes
@@ -123,11 +124,11 @@ func (d *DatabaseTransaction) GetRoomSummary(ctx context.Context, roomID, userID
for _, ev := range evs {
switch ev.Type() {
- case gomatrixserverlib.MRoomName:
+ case spec.MRoomName:
if gjson.GetBytes(ev.Content(), "name").Str != "" {
return summary, nil
}
- case gomatrixserverlib.MRoomCanonicalAlias:
+ case spec.MRoomCanonicalAlias:
if gjson.GetBytes(ev.Content(), "alias").Str != "" {
return summary, nil
}
@@ -135,14 +136,14 @@ func (d *DatabaseTransaction) GetRoomSummary(ctx context.Context, roomID, userID
}
// If there's no room name or canonical alias, get the room heroes, excluding the user
- heroes, err := d.CurrentRoomState.SelectRoomHeroes(ctx, d.txn, roomID, userID, []string{gomatrixserverlib.Join, gomatrixserverlib.Invite})
+ heroes, err := d.CurrentRoomState.SelectRoomHeroes(ctx, d.txn, roomID, userID, []string{spec.Join, spec.Invite})
if err != nil {
return summary, err
}
// "When no joined or invited members are available, this should consist of the banned and left users"
if len(heroes) == 0 {
- heroes, err = d.CurrentRoomState.SelectRoomHeroes(ctx, d.txn, roomID, userID, []string{gomatrixserverlib.Leave, gomatrixserverlib.Ban})
+ heroes, err = d.CurrentRoomState.SelectRoomHeroes(ctx, d.txn, roomID, userID, []string{spec.Leave, spec.Ban})
if err != nil {
return summary, err
}
@@ -349,7 +350,7 @@ func (d *DatabaseTransaction) GetStateDeltas(
joinedRoomIDs := make([]string, 0, len(memberships))
for roomID, membership := range memberships {
allRoomIDs = append(allRoomIDs, roomID)
- if membership == gomatrixserverlib.Join {
+ if membership == spec.Join {
joinedRoomIDs = append(joinedRoomIDs, roomID)
}
}
@@ -415,7 +416,7 @@ func (d *DatabaseTransaction) GetStateDeltas(
}
if !peek.Deleted {
deltas = append(deltas, types.StateDelta{
- Membership: gomatrixserverlib.Peek,
+ Membership: spec.Peek,
StateEvents: d.StreamEventsToEvents(device, state[peek.RoomID]),
RoomID: peek.RoomID,
})
@@ -433,7 +434,7 @@ func (d *DatabaseTransaction) GetStateDeltas(
continue
}
- if membership == gomatrixserverlib.Join {
+ if membership == spec.Join {
// If our membership is now join but the previous membership wasn't
// then this is a "join transition", so we'll insert this room.
if prevMembership != membership {
@@ -472,7 +473,7 @@ func (d *DatabaseTransaction) GetStateDeltas(
// join transitions above.
for _, joinedRoomID := range joinedRoomIDs {
deltas = append(deltas, types.StateDelta{
- Membership: gomatrixserverlib.Join,
+ Membership: spec.Join,
StateEvents: d.StreamEventsToEvents(device, stateFiltered[joinedRoomID]),
RoomID: joinedRoomID,
NewlyJoined: newlyJoinedRooms[joinedRoomID],
@@ -505,7 +506,7 @@ func (d *DatabaseTransaction) GetStateDeltasForFullStateSync(
joinedRoomIDs := make([]string, 0, len(memberships))
for roomID, membership := range memberships {
allRoomIDs = append(allRoomIDs, roomID)
- if membership == gomatrixserverlib.Join {
+ if membership == spec.Join {
joinedRoomIDs = append(joinedRoomIDs, roomID)
}
}
@@ -529,7 +530,7 @@ func (d *DatabaseTransaction) GetStateDeltasForFullStateSync(
return nil, nil, stateErr
}
deltas[peek.RoomID] = types.StateDelta{
- Membership: gomatrixserverlib.Peek,
+ Membership: spec.Peek,
StateEvents: d.StreamEventsToEvents(device, s),
RoomID: peek.RoomID,
}
@@ -555,7 +556,7 @@ func (d *DatabaseTransaction) GetStateDeltasForFullStateSync(
for roomID, stateStreamEvents := range state {
for _, ev := range stateStreamEvents {
if membership, _ := getMembershipFromEvent(ev.Event, userID); membership != "" {
- if membership != gomatrixserverlib.Join { // We've already added full state for all joined rooms above.
+ if membership != spec.Join { // We've already added full state for all joined rooms above.
deltas[roomID] = types.StateDelta{
Membership: membership,
MembershipPos: ev.StreamPosition,
@@ -579,7 +580,7 @@ func (d *DatabaseTransaction) GetStateDeltasForFullStateSync(
return nil, nil, stateErr
}
deltas[joinedRoomID] = types.StateDelta{
- Membership: gomatrixserverlib.Join,
+ Membership: spec.Join,
StateEvents: d.StreamEventsToEvents(device, s),
RoomID: joinedRoomID,
}
@@ -636,7 +637,7 @@ func (d *DatabaseTransaction) GetRoomReceipts(ctx context.Context, roomIDs []str
func (d *DatabaseTransaction) GetUserUnreadNotificationCountsForRooms(ctx context.Context, userID string, rooms map[string]string) (map[string]*eventutil.NotificationData, error) {
roomIDs := make([]string, 0, len(rooms))
for roomID, membership := range rooms {
- if membership != gomatrixserverlib.Join {
+ if membership != spec.Join {
continue
}
roomIDs = append(roomIDs, roomID)
diff --git a/syncapi/storage/sqlite3/current_room_state_table.go b/syncapi/storage/sqlite3/current_room_state_table.go
index c681933d..01dcff69 100644
--- a/syncapi/storage/sqlite3/current_room_state_table.go
+++ b/syncapi/storage/sqlite3/current_room_state_table.go
@@ -30,6 +30,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/synctypes"
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
)
const currentRoomStateSchema = `
@@ -270,9 +271,9 @@ func (s *currentRoomStateStatements) SelectCurrentState(
) ([]*gomatrixserverlib.HeaderedEvent, error) {
// We're going to query members later, so remove them from this request
if stateFilter.LazyLoadMembers && !stateFilter.IncludeRedundantMembers {
- notTypes := &[]string{gomatrixserverlib.MRoomMember}
+ notTypes := &[]string{spec.MRoomMember}
if stateFilter.NotTypes != nil {
- *stateFilter.NotTypes = append(*stateFilter.NotTypes, gomatrixserverlib.MRoomMember)
+ *stateFilter.NotTypes = append(*stateFilter.NotTypes, spec.MRoomMember)
} else {
stateFilter.NotTypes = notTypes
}
diff --git a/syncapi/storage/sqlite3/presence_table.go b/syncapi/storage/sqlite3/presence_table.go
index 5f76b370..573fbad6 100644
--- a/syncapi/storage/sqlite3/presence_table.go
+++ b/syncapi/storage/sqlite3/presence_table.go
@@ -20,7 +20,7 @@ import (
"strings"
"time"
- "github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
@@ -113,7 +113,7 @@ func (p *presenceStatements) UpsertPresence(
userID string,
statusMsg *string,
presence types.Presence,
- lastActiveTS gomatrixserverlib.Timestamp,
+ lastActiveTS spec.Timestamp,
fromSync bool,
) (pos types.StreamPosition, err error) {
pos, err = p.streamIDStatements.nextPresenceID(ctx, txn)
@@ -185,7 +185,7 @@ func (p *presenceStatements) GetPresenceAfter(
) (presences map[string]*types.PresenceInternal, err error) {
presences = make(map[string]*types.PresenceInternal)
stmt := sqlutil.TxStmt(txn, p.selectPresenceAfterStmt)
- afterTS := gomatrixserverlib.AsTimestamp(time.Now().Add(time.Minute * -5))
+ afterTS := spec.AsTimestamp(time.Now().Add(time.Minute * -5))
rows, err := stmt.QueryContext(ctx, after, afterTS, filter.Limit)
if err != nil {
return nil, err
diff --git a/syncapi/storage/sqlite3/receipt_table.go b/syncapi/storage/sqlite3/receipt_table.go
index ca3d80fb..b973903b 100644
--- a/syncapi/storage/sqlite3/receipt_table.go
+++ b/syncapi/storage/sqlite3/receipt_table.go
@@ -25,7 +25,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/storage/sqlite3/deltas"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
"github.com/matrix-org/dendrite/syncapi/types"
- "github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
)
const receiptsSchema = `
@@ -97,7 +97,7 @@ func NewSqliteReceiptsTable(db *sql.DB, streamID *StreamIDStatements) (tables.Re
}
// UpsertReceipt creates new user receipts
-func (r *receiptStatements) UpsertReceipt(ctx context.Context, txn *sql.Tx, roomId, receiptType, userId, eventId string, timestamp gomatrixserverlib.Timestamp) (pos types.StreamPosition, err error) {
+func (r *receiptStatements) UpsertReceipt(ctx context.Context, txn *sql.Tx, roomId, receiptType, userId, eventId string, timestamp spec.Timestamp) (pos types.StreamPosition, err error) {
pos, err = r.streamIDStatements.nextReceiptID(ctx, txn)
if err != nil {
return
diff --git a/syncapi/storage/storage_test.go b/syncapi/storage/storage_test.go
index fa3f54c0..2cc1378b 100644
--- a/syncapi/storage/storage_test.go
+++ b/syncapi/storage/storage_test.go
@@ -16,6 +16,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/dendrite/test"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/stretchr/testify/assert"
)
@@ -777,7 +778,7 @@ func TestRoomSummary(t *testing.T) {
name: "invited user",
wantSummary: &types.Summary{JoinedMemberCount: pointer(1), InvitedMemberCount: pointer(1), Heroes: []string{bob.ID}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
"membership": "invite",
}, test.WithStateKey(bob.ID))
},
@@ -786,10 +787,10 @@ func TestRoomSummary(t *testing.T) {
name: "invited user, but declined",
wantSummary: &types.Summary{JoinedMemberCount: pointer(1), InvitedMemberCount: pointer(0), Heroes: []string{bob.ID}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
"membership": "invite",
}, test.WithStateKey(bob.ID))
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "leave",
}, test.WithStateKey(bob.ID))
},
@@ -798,10 +799,10 @@ func TestRoomSummary(t *testing.T) {
name: "joined user after invitation",
wantSummary: &types.Summary{JoinedMemberCount: pointer(2), InvitedMemberCount: pointer(0), Heroes: []string{bob.ID}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
"membership": "invite",
}, test.WithStateKey(bob.ID))
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(bob.ID))
},
@@ -810,10 +811,10 @@ func TestRoomSummary(t *testing.T) {
name: "multiple joined user",
wantSummary: &types.Summary{JoinedMemberCount: pointer(3), InvitedMemberCount: pointer(0), Heroes: []string{charlie.ID, bob.ID}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, charlie, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, charlie, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(charlie.ID))
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(bob.ID))
},
@@ -822,10 +823,10 @@ func TestRoomSummary(t *testing.T) {
name: "multiple joined/invited user",
wantSummary: &types.Summary{JoinedMemberCount: pointer(2), InvitedMemberCount: pointer(1), Heroes: []string{charlie.ID, bob.ID}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
"membership": "invite",
}, test.WithStateKey(charlie.ID))
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(bob.ID))
},
@@ -834,13 +835,13 @@ func TestRoomSummary(t *testing.T) {
name: "multiple joined/invited/left user",
wantSummary: &types.Summary{JoinedMemberCount: pointer(1), InvitedMemberCount: pointer(1), Heroes: []string{charlie.ID}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
"membership": "invite",
}, test.WithStateKey(charlie.ID))
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(bob.ID))
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "leave",
}, test.WithStateKey(bob.ID))
},
@@ -849,10 +850,10 @@ func TestRoomSummary(t *testing.T) {
name: "leaving user after joining",
wantSummary: &types.Summary{JoinedMemberCount: pointer(1), InvitedMemberCount: pointer(0), Heroes: []string{bob.ID}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(bob.ID))
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "leave",
}, test.WithStateKey(bob.ID))
},
@@ -862,7 +863,7 @@ func TestRoomSummary(t *testing.T) {
wantSummary: &types.Summary{JoinedMemberCount: pointer(len(moreUserIDs) + 1), InvitedMemberCount: pointer(0), Heroes: moreUserIDs[:5]},
additionalEvents: func(t *testing.T, room *test.Room) {
for _, x := range moreUsers {
- room.CreateAndInsert(t, x, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, x, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(x.ID))
}
@@ -872,10 +873,10 @@ func TestRoomSummary(t *testing.T) {
name: "canonical alias set",
wantSummary: &types.Summary{JoinedMemberCount: pointer(2), InvitedMemberCount: pointer(0), Heroes: []string{}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(bob.ID))
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomCanonicalAlias, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomCanonicalAlias, map[string]interface{}{
"alias": "myalias",
}, test.WithStateKey(""))
},
@@ -884,10 +885,10 @@ func TestRoomSummary(t *testing.T) {
name: "room name set",
wantSummary: &types.Summary{JoinedMemberCount: pointer(2), InvitedMemberCount: pointer(0), Heroes: []string{}},
additionalEvents: func(t *testing.T, room *test.Room) {
- room.CreateAndInsert(t, bob, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(bob.ID))
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomName, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomName, map[string]interface{}{
"name": "my room name",
}, test.WithStateKey(""))
},
diff --git a/syncapi/storage/tables/current_room_state_test.go b/syncapi/storage/tables/current_room_state_test.go
index 5fe06c3c..7d4ec812 100644
--- a/syncapi/storage/tables/current_room_state_test.go
+++ b/syncapi/storage/tables/current_room_state_test.go
@@ -14,7 +14,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/synctypes"
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/dendrite/test"
- "github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
)
func newCurrentRoomStateTable(t *testing.T, dbType test.DBType) (tables.CurrentRoomState, *sql.DB, func()) {
@@ -115,7 +115,7 @@ func testCurrentState(t *testing.T, ctx context.Context, txn *sql.Tx, tab tables
t.Fatalf("expected %d state events, got %d", expectCount, gotCount)
}
// same as above, but with existing NotTypes defined
- notTypes := []string{gomatrixserverlib.MRoomMember}
+ notTypes := []string{spec.MRoomMember}
filter.NotTypes = &notTypes
evs, err = tab.SelectCurrentState(ctx, txn, room.ID, &filter, nil)
if err != nil {
diff --git a/syncapi/storage/tables/interface.go b/syncapi/storage/tables/interface.go
index 94c9c402..6384fb91 100644
--- a/syncapi/storage/tables/interface.go
+++ b/syncapi/storage/tables/interface.go
@@ -19,6 +19,7 @@ import (
"database/sql"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/matrix-org/dendrite/internal/eventutil"
"github.com/matrix-org/dendrite/roomserver/api"
@@ -183,7 +184,7 @@ type Filter interface {
}
type Receipts interface {
- UpsertReceipt(ctx context.Context, txn *sql.Tx, roomId, receiptType, userId, eventId string, timestamp gomatrixserverlib.Timestamp) (pos types.StreamPosition, err error)
+ UpsertReceipt(ctx context.Context, txn *sql.Tx, roomId, receiptType, userId, eventId string, timestamp spec.Timestamp) (pos types.StreamPosition, err error)
SelectRoomReceiptsAfter(ctx context.Context, txn *sql.Tx, roomIDs []string, streamPos types.StreamPosition) (types.StreamPosition, []types.OutputReceiptEvent, error)
SelectMaxReceiptID(ctx context.Context, txn *sql.Tx) (id int64, err error)
PurgeReceipts(ctx context.Context, txn *sql.Tx, roomID string) error
@@ -214,7 +215,7 @@ type Ignores interface {
}
type Presence interface {
- UpsertPresence(ctx context.Context, txn *sql.Tx, userID string, statusMsg *string, presence types.Presence, lastActiveTS gomatrixserverlib.Timestamp, fromSync bool) (pos types.StreamPosition, err error)
+ UpsertPresence(ctx context.Context, txn *sql.Tx, userID string, statusMsg *string, presence types.Presence, lastActiveTS spec.Timestamp, fromSync bool) (pos types.StreamPosition, err error)
GetPresenceForUsers(ctx context.Context, txn *sql.Tx, userIDs []string) (presence []*types.PresenceInternal, err error)
GetMaxPresenceID(ctx context.Context, txn *sql.Tx) (pos types.StreamPosition, err error)
GetPresenceAfter(ctx context.Context, txn *sql.Tx, after types.StreamPosition, filter synctypes.EventFilter) (presences map[string]*types.PresenceInternal, err error)
diff --git a/syncapi/storage/tables/memberships_test.go b/syncapi/storage/tables/memberships_test.go
index df593ae7..2e8375c3 100644
--- a/syncapi/storage/tables/memberships_test.go
+++ b/syncapi/storage/tables/memberships_test.go
@@ -7,6 +7,7 @@ import (
"time"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/setup/config"
@@ -65,7 +66,7 @@ func TestMembershipsTable(t *testing.T) {
u := test.NewUser(t)
users = append(users, u.ID)
- ev := room.CreateAndInsert(t, u, gomatrixserverlib.MRoomMember, map[string]interface{}{
+ ev := room.CreateAndInsert(t, u, spec.MRoomMember, map[string]interface{}{
"membership": "join",
}, test.WithStateKey(u.ID))
userEvents = append(userEvents, ev)
@@ -92,7 +93,7 @@ func TestMembershipsTable(t *testing.T) {
func testMembershipCount(t *testing.T, ctx context.Context, table tables.Memberships, room *test.Room) {
t.Run("membership counts are correct", func(t *testing.T) {
// After 10 events, we should have 6 users (5 create related [incl. one member event], 5 member events = 6 users)
- count, err := table.SelectMembershipCount(ctx, nil, room.ID, gomatrixserverlib.Join, 10)
+ count, err := table.SelectMembershipCount(ctx, nil, room.ID, spec.Join, 10)
if err != nil {
t.Fatalf("failed to get membership count: %s", err)
}
@@ -102,7 +103,7 @@ func testMembershipCount(t *testing.T, ctx context.Context, table tables.Members
}
// After 100 events, we should have all 11 users
- count, err = table.SelectMembershipCount(ctx, nil, room.ID, gomatrixserverlib.Join, 100)
+ count, err = table.SelectMembershipCount(ctx, nil, room.ID, spec.Join, 100)
if err != nil {
t.Fatalf("failed to get membership count: %s", err)
}
@@ -126,12 +127,12 @@ func testUpsert(t *testing.T, ctx context.Context, table tables.Memberships, mem
if pos != expectedPos {
t.Fatalf("expected pos to be %d, got %d", expectedPos, pos)
}
- if membership != gomatrixserverlib.Join {
+ if membership != spec.Join {
t.Fatalf("expected membership to be join, got %s", membership)
}
// Create a new event which gets upserted and should not cause issues
- ev := room.CreateAndInsert(t, user, gomatrixserverlib.MRoomMember, map[string]interface{}{
- "membership": gomatrixserverlib.Join,
+ ev := room.CreateAndInsert(t, user, spec.MRoomMember, map[string]interface{}{
+ "membership": spec.Join,
}, test.WithStateKey(user.ID))
// Insert the same event again, but with different positions, which should get updated
if err = table.UpsertMembership(ctx, nil, ev, 2, 2); err != nil {
@@ -147,7 +148,7 @@ func testUpsert(t *testing.T, ctx context.Context, table tables.Memberships, mem
if pos != expectedPos {
t.Fatalf("expected pos to be %d, got %d", expectedPos, pos)
}
- if membership != gomatrixserverlib.Join {
+ if membership != spec.Join {
t.Fatalf("expected membership to be join, got %s", membership)
}
@@ -155,7 +156,7 @@ func testUpsert(t *testing.T, ctx context.Context, table tables.Memberships, mem
if membership, _, err = table.SelectMembershipForUser(ctx, nil, room.ID, user.ID, 1); err != nil {
t.Fatalf("failed to select membership: %s", err)
}
- if membership != gomatrixserverlib.Leave {
+ if membership != spec.Leave {
t.Fatalf("expected membership to be leave, got %s", membership)
}
})
diff --git a/syncapi/storage/tables/output_room_events_test.go b/syncapi/storage/tables/output_room_events_test.go
index 69587800..9b755dc8 100644
--- a/syncapi/storage/tables/output_room_events_test.go
+++ b/syncapi/storage/tables/output_room_events_test.go
@@ -15,6 +15,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/synctypes"
"github.com/matrix-org/dendrite/test"
"github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/gomatrixserverlib/spec"
)
func newOutputRoomEventsTable(t *testing.T, dbType test.DBType) (tables.Events, *sql.DB, func()) {
@@ -110,11 +111,11 @@ func TestReindex(t *testing.T) {
alice := test.NewUser(t)
room := test.NewRoom(t, alice)
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomName, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomName, map[string]interface{}{
"name": "my new room name",
}, test.WithStateKey(""))
- room.CreateAndInsert(t, alice, gomatrixserverlib.MRoomTopic, map[string]interface{}{
+ room.CreateAndInsert(t, alice, spec.MRoomTopic, map[string]interface{}{
"topic": "my new room topic",
}, test.WithStateKey(""))
@@ -141,8 +142,8 @@ func TestReindex(t *testing.T) {
}
events, err := tab.ReIndex(ctx, nil, 10, 0, []string{
- gomatrixserverlib.MRoomName,
- gomatrixserverlib.MRoomTopic,
+ spec.MRoomName,
+ spec.MRoomTopic,
"m.room.message"})
if err != nil {
t.Fatal(err)
diff --git a/syncapi/storage/tables/presence_table_test.go b/syncapi/storage/tables/presence_table_test.go
index cb7a4dee..d8161836 100644
--- a/syncapi/storage/tables/presence_table_test.go
+++ b/syncapi/storage/tables/presence_table_test.go
@@ -7,8 +7,6 @@ import (
"testing"
"time"
- "github.com/matrix-org/gomatrixserverlib"
-
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/syncapi/storage/postgres"
@@ -17,6 +15,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/synctypes"
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/dendrite/test"
+ "github.com/matrix-org/gomatrixserverlib/spec"
)
func mustPresenceTable(t *testing.T, dbType test.DBType) (tables.Presence, func()) {
@@ -52,7 +51,7 @@ func TestPresence(t *testing.T) {
ctx := context.Background()
statusMsg := "Hello World!"
- timestamp := gomatrixserverlib.AsTimestamp(time.Now())
+ timestamp := spec.AsTimestamp(time.Now())
var txn *sql.Tx
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {