mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
Rename to PurgeRoom
This commit is contained in:
parent
ae998c17e2
commit
a571989495
|
|
@ -145,15 +145,8 @@ func (s *OutputRoomEventConsumer) onNewRoomEvent(
|
||||||
}
|
}
|
||||||
|
|
||||||
if msg.RewritesState {
|
if msg.RewritesState {
|
||||||
err = s.db.RewriteState(
|
if err = s.db.PurgeRoom(ctx, ev.RoomID()); err != nil {
|
||||||
ctx,
|
return fmt.Errorf("s.db.PurgeRoom: %w", err)
|
||||||
&ev,
|
|
||||||
addsStateEvents,
|
|
||||||
msg.AddsStateEventIDs,
|
|
||||||
msg.TransactionID,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("s.db.RewriteState: %w", err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ type Database interface {
|
||||||
// Returns an error if there was a problem inserting this event.
|
// Returns an error if there was a problem inserting this event.
|
||||||
WriteEvent(ctx context.Context, ev *gomatrixserverlib.HeaderedEvent, addStateEvents []gomatrixserverlib.HeaderedEvent,
|
WriteEvent(ctx context.Context, ev *gomatrixserverlib.HeaderedEvent, addStateEvents []gomatrixserverlib.HeaderedEvent,
|
||||||
addStateEventIDs []string, removeStateEventIDs []string, transactionID *api.TransactionID, excludeFromSync bool) (types.StreamPosition, error)
|
addStateEventIDs []string, removeStateEventIDs []string, transactionID *api.TransactionID, excludeFromSync bool) (types.StreamPosition, error)
|
||||||
// RewriteState rewrites a current room state event. If the state event is a create event then all existing
|
// PurgeRoom completely purges room state from the sync API. This is done when
|
||||||
// state in the room will be deleted before rewriting the event.
|
// receiving an output event that completely resets the state.
|
||||||
RewriteState(ctx context.Context, ev *gomatrixserverlib.HeaderedEvent, addStateEvents []gomatrixserverlib.HeaderedEvent, addStateEventIDs []string, transactionID *api.TransactionID) error
|
PurgeRoom(ctx context.Context, roomID string) error
|
||||||
// GetStateEvent returns the Matrix state event of a given type for a given room with a given state key
|
// GetStateEvent returns the Matrix state event of a given type for a given room with a given state key
|
||||||
// If no event could be found, returns nil
|
// If no event could be found, returns nil
|
||||||
// If there was an issue during the retrieval, returns an error
|
// If there was an issue during the retrieval, returns an error
|
||||||
|
|
|
||||||
|
|
@ -241,39 +241,25 @@ func (d *Database) handleBackwardExtremities(ctx context.Context, txn *sql.Tx, e
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Database) RewriteState(
|
func (d *Database) PurgeRoom(
|
||||||
ctx context.Context,
|
ctx context.Context, roomID string,
|
||||||
ev *gomatrixserverlib.HeaderedEvent,
|
|
||||||
addStateEvents []gomatrixserverlib.HeaderedEvent,
|
|
||||||
addStateEventIDs []string,
|
|
||||||
transactionID *api.TransactionID,
|
|
||||||
) error {
|
) error {
|
||||||
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
||||||
// If the event is a create event then we'll delete all of the existing
|
// If the event is a create event then we'll delete all of the existing
|
||||||
// data for the room. The only reason that a create event would be replayed
|
// data for the room. The only reason that a create event would be replayed
|
||||||
// to us in this way is if we're about to receive the entire room state.
|
// to us in this way is if we're about to receive the entire room state.
|
||||||
if ev.Type() == gomatrixserverlib.MRoomCreate {
|
if err := d.CurrentRoomState.DeleteRoomStateForRoom(ctx, txn, roomID); err != nil {
|
||||||
if err := d.CurrentRoomState.DeleteRoomStateForRoom(ctx, txn, ev.RoomID()); err != nil {
|
return fmt.Errorf("d.CurrentRoomState.DeleteRoomStateForRoom: %w", err)
|
||||||
return fmt.Errorf("d.CurrentRoomState.DeleteRoomStateForRoom: %w", err)
|
}
|
||||||
}
|
if err := d.OutputEvents.DeleteEventsForRoom(ctx, txn, roomID); err != nil {
|
||||||
if err := d.OutputEvents.DeleteEventsForRoom(ctx, txn, ev.RoomID()); err != nil {
|
return fmt.Errorf("d.Events.DeleteEventsForRoom: %w", err)
|
||||||
return fmt.Errorf("d.Events.DeleteEventsForRoom: %w", err)
|
}
|
||||||
}
|
if err := d.Topology.DeleteTopologyForRoom(ctx, txn, roomID); err != nil {
|
||||||
if err := d.Topology.DeleteTopologyForRoom(ctx, txn, ev.RoomID()); err != nil {
|
return fmt.Errorf("d.Topology.DeleteTopologyForRoom: %w", err)
|
||||||
return fmt.Errorf("d.Topology.DeleteTopologyForRoom: %w", err)
|
}
|
||||||
}
|
if err := d.BackwardExtremities.DeleteBackwardExtremitiesForRoom(ctx, txn, roomID); err != nil {
|
||||||
if err := d.BackwardExtremities.DeleteBackwardExtremitiesForRoom(ctx, txn, ev.RoomID()); err != nil {
|
return fmt.Errorf("d.BackwardExtremities.DeleteBackwardExtremitiesForRoom: %w", err)
|
||||||
return fmt.Errorf("d.BackwardExtremities.DeleteBackwardExtremitiesForRoom: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if err := d.handleBackwardExtremities(ctx, txn, ev); err != nil {
|
|
||||||
return fmt.Errorf("d.handleBackwardExtremities: %w", err)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// TODO: is there something better here that we can do instead of giving stream position 0?
|
|
||||||
//return d.updateRoomState(ctx, txn, []string{}, addStateEvents, types.StreamPosition(0))
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue