From b4dbd24da5cbc46f2a45f5035c42ac84682df408 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 3 Aug 2022 16:36:49 +0100 Subject: [PATCH] Revert changes to room updater --- roomserver/storage/shared/room_updater.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/roomserver/storage/shared/room_updater.go b/roomserver/storage/shared/room_updater.go index 85b86b311..4497b58c4 100644 --- a/roomserver/storage/shared/room_updater.go +++ b/roomserver/storage/shared/room_updater.go @@ -11,11 +11,12 @@ import ( type RoomUpdater struct { transaction - d *Database - roomInfo *types.RoomInfo - latestEvents []types.StateAtEventAndReference - lastEventIDSent string - roomExists bool + d *Database + roomInfo *types.RoomInfo + latestEvents []types.StateAtEventAndReference + lastEventIDSent string + currentStateSnapshotNID types.StateSnapshotNID + roomExists bool } func rollback(txn *sql.Tx) { @@ -33,11 +34,11 @@ func NewRoomUpdater(ctx context.Context, d *Database, txn *sql.Tx, roomInfo *typ // succeed, processing a create event which creates the room, or it won't. if roomInfo == nil { return &RoomUpdater{ - transaction{ctx, txn}, d, nil, nil, "", false, + transaction{ctx, txn}, d, nil, nil, "", 0, false, }, nil } - eventNIDs, lastEventNIDSent, _, err := + eventNIDs, lastEventNIDSent, currentStateSnapshotNID, err := d.RoomsTable.SelectLatestEventsNIDsForUpdate(ctx, txn, roomInfo.RoomNID) if err != nil { rollback(txn) @@ -57,7 +58,7 @@ func NewRoomUpdater(ctx context.Context, d *Database, txn *sql.Tx, roomInfo *typ } } return &RoomUpdater{ - transaction{ctx, txn}, d, roomInfo, stateAndRefs, lastEventIDSent, true, + transaction{ctx, txn}, d, roomInfo, stateAndRefs, lastEventIDSent, currentStateSnapshotNID, true, }, nil } @@ -99,7 +100,7 @@ func (u *RoomUpdater) LastEventIDSent() string { // CurrentStateSnapshotNID implements types.RoomRecentEventsUpdater func (u *RoomUpdater) CurrentStateSnapshotNID() types.StateSnapshotNID { - return u.roomInfo.StateSnapshotNID() + return u.currentStateSnapshotNID } // StorePreviousEvents implements types.RoomRecentEventsUpdater - This must be called from a Writer