mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Emit Invalidation payloads
This commit is contained in:
parent
777cb357fe
commit
f4555f3c22
@ -321,6 +321,10 @@ type AccumulateResult struct {
|
||||
// TODO: is this redundant---identical to len(TimelineNIDs)?
|
||||
NumNew int
|
||||
TimelineNIDs []int64
|
||||
// ReloadSnapshot is set to the snapshot ID representing the current state of the room, if this Accumulate has
|
||||
// changed state in a non-incremental fashion. If so, the application should reload its view of this room from the
|
||||
// given snapshot. Otherwise this is 0.
|
||||
ReloadFromSnapshot int64
|
||||
}
|
||||
|
||||
// Accumulate internal state from a user's sync response. The timeline order MUST be in the order
|
||||
@ -507,6 +511,13 @@ func (a *Accumulator) Accumulate(txn *sqlx.Tx, userID, roomID string, prevBatch
|
||||
}
|
||||
}
|
||||
|
||||
if len(redactTheseEventIDs) > 0 {
|
||||
// TODO: this is going to send out a cache invalidation when someone redacts a
|
||||
// message event, which is unnecessary. Can we get eventsTable.Redact to tell us
|
||||
// if it redacted any state events, and only include a snapID here if so?
|
||||
result.ReloadFromSnapshot = snapID
|
||||
}
|
||||
|
||||
if err = a.spacesTable.HandleSpaceUpdates(txn, newEvents); err != nil {
|
||||
return AccumulateResult{}, fmt.Errorf("HandleSpaceUpdates: %s", err)
|
||||
}
|
||||
|
@ -301,6 +301,14 @@ func (h *Handler) Accumulate(ctx context.Context, userID, deviceID, roomID, prev
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: does the ordering of this versus V2Accumulate matter here?
|
||||
if accResult.ReloadFromSnapshot > 0 {
|
||||
h.v2Pub.Notify(pubsub.ChanV2, &pubsub.V2InvalidateRoom{
|
||||
RoomID: roomID,
|
||||
SnapshotID: accResult.ReloadFromSnapshot,
|
||||
})
|
||||
}
|
||||
|
||||
// We've updated the database. Now tell any pubsub listeners what we learned.
|
||||
if accResult.NumNew != 0 {
|
||||
h.v2Pub.Notify(pubsub.ChanV2, &pubsub.V2Accumulate{
|
||||
|
Loading…
x
Reference in New Issue
Block a user