Create previous event references in StoreEvent

This commit is contained in:
Neil Alexander 2020-10-07 11:58:43 +01:00
parent 994be80b7a
commit 4e96930f55
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 7 additions and 8 deletions

View file

@ -117,7 +117,6 @@ type latestEventsUpdater struct {
}
func (u *latestEventsUpdater) doUpdateLatestEvents() error {
prevEvents := u.event.PrevEvents()
u.lastEventIDSent = u.updater.LastEventIDSent()
u.oldStateNID = u.updater.CurrentStateSnapshotNID()
@ -141,12 +140,6 @@ func (u *latestEventsUpdater) doUpdateLatestEvents() error {
return nil
}
// Update the roomserver_previous_events table with references. This
// is effectively tracking the structure of the DAG.
if err = u.updater.StorePreviousEvents(u.stateAtEvent.EventNID, prevEvents); err != nil {
return fmt.Errorf("u.updater.StorePreviousEvents: %w", err)
}
// Work out what the latest events are. This will include the new
// event if it is not already referenced.
u.calculateLatest(

View file

@ -468,6 +468,11 @@ func (d *Database) StoreEvent(
if !isRejected { // ignore rejected redaction events
redactionEvent, redactedEventID, err = d.handleRedactions(ctx, txn, eventNID, event)
}
for _, prev := range event.PrevEvents() {
if err = d.PrevEventsTable.InsertPreviousEvent(ctx, txn, prev.EventID, prev.EventSHA256, eventNID); err != nil {
return fmt.Errorf("d.PrevEventsTable.InsertPreviousEvent: %w", err)
}
}
return nil
})
if err != nil {

View file

@ -473,4 +473,5 @@ Inbound federation rejects invites which include invalid JSON for room version 6
Inbound federation rejects invite rejections which include invalid JSON for room version 6
GET /capabilities is present and well formed for registered user
m.room.history_visibility == "joined" allows/forbids appropriately for Guest users
m.room.history_visibility == "joined" allows/forbids appropriately for Real users
m.room.history_visibility == "joined" allows/forbids appropriately for Real users
Users cannot kick users who have already left a room