CalculateAndStoreStateBeforeEvent calculates a snapshot of the state of a room before an event. Stores the snapshot of the state in the database. Returns a numeric ID for the snapshot of the state before the event.
( ctx context.Context, event *gomatrixserverlib.Event, isRejected bool, )
| 591 | // Stores the snapshot of the state in the database. |
| 592 | // Returns a numeric ID for the snapshot of the state before the event. |
| 593 | func (v *StateResolution) CalculateAndStoreStateBeforeEvent( |
| 594 | ctx context.Context, |
| 595 | event *gomatrixserverlib.Event, |
| 596 | isRejected bool, |
| 597 | ) (types.StateSnapshotNID, error) { |
| 598 | span, ctx := opentracing.StartSpanFromContext(ctx, "StateResolution.CalculateAndStoreStateBeforeEvent") |
| 599 | defer span.Finish() |
| 600 | |
| 601 | // Load the state at the prev events. |
| 602 | prevStates, err := v.db.StateAtEventIDs(ctx, event.PrevEventIDs()) |
| 603 | if err != nil { |
| 604 | return 0, err |
| 605 | } |
| 606 | |
| 607 | // The state before this event will be the state after the events that came before it. |
| 608 | return v.CalculateAndStoreStateAfterEvents(ctx, prevStates) |
| 609 | } |
| 610 | |
| 611 | // CalculateAndStoreStateAfterEvents finds the room state after the given events. |
| 612 | // Stores the resulting state in the database and returns a numeric ID for that snapshot. |
no test coverage detected