Improve variable name?

This commit is contained in:
David Robertson 2023-10-10 18:27:27 +01:00
parent 9b9da2a8e9
commit 32bc415472
No known key found for this signature in database
GPG Key ID: 903ECE108A39DEDD

View File

@ -433,7 +433,9 @@ func (a *Accumulator) Accumulate(txn *sqlx.Tx, userID, roomID string, timeline s
}
var latestNID int64
newEventsByID := make([]Event, 0, len(eventIDToNID))
// postInsertEvents matches newEvents, but a) it has NIDs, and b) state events have
// the IsState field hacked to true so we don't insert them into the timeline.
postInsertEvents := make([]Event, 0, len(eventIDToNID))
redactTheseEventIDs := make(map[string]*Event)
for i, ev := range newEvents {
nid, ok := eventIDToNID[ev.ID]
@ -461,7 +463,7 @@ func (a *Accumulator) Accumulate(txn *sqlx.Tx, userID, roomID string, timeline s
redactTheseEventIDs[redactsEventID] = &newEvents[i]
}
}
newEventsByID = append(newEventsByID, ev)
postInsertEvents = append(postInsertEvents, ev)
result.TimelineNIDs = append(result.TimelineNIDs, ev.NID)
}
}
@ -487,7 +489,7 @@ func (a *Accumulator) Accumulate(txn *sqlx.Tx, userID, roomID string, timeline s
}
}
for _, ev := range newEventsByID {
for _, ev := range postInsertEvents {
var replacesNID int64
// the snapshot ID we assign to this event is unaffected by whether /this/ event is state or not,
// as this is the before snapshot ID.
@ -543,12 +545,12 @@ func (a *Accumulator) Accumulate(txn *sqlx.Tx, userID, roomID string, timeline s
result.RequiresReload = currentStateRedactions > 0
}
if err = a.spacesTable.HandleSpaceUpdates(txn, newEventsByID); err != nil {
if err = a.spacesTable.HandleSpaceUpdates(txn, postInsertEvents); err != nil {
return AccumulateResult{}, fmt.Errorf("HandleSpaceUpdates: %s", err)
}
// the last fetched snapshot ID is the current one
info := a.roomInfoDelta(roomID, newEventsByID)
info := a.roomInfoDelta(roomID, postInsertEvents)
if err = a.roomsTable.Upsert(txn, info, snapID, latestNID); err != nil {
return AccumulateResult{}, fmt.Errorf("failed to UpdateCurrentSnapshotID to %d: %w", snapID, err)
}