state

package
v0.13.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqueStateSnapshotNIDs added in v0.3.6

func UniqueStateSnapshotNIDs(nids []types.StateSnapshotNID) []types.StateSnapshotNID

Types

type PowerLevelResolver added in v0.12.0

type PowerLevelResolver interface {
	Resolve(ctx context.Context, eventID string) (*gomatrixserverlib.PowerLevelContent, error)
}

type StateResolution

type StateResolution struct {
	Querier api.QuerySenderIDAPI
	// contains filtered or unexported fields
}

func NewStateResolution

func NewStateResolution(db StateResolutionStorage, roomInfo *types.RoomInfo, querier api.QuerySenderIDAPI) StateResolution

func (*StateResolution) CalculateAndStoreStateAfterEvents

func (v *StateResolution) CalculateAndStoreStateAfterEvents(
	ctx context.Context,
	prevStates []types.StateAtEvent,
) (types.StateSnapshotNID, error)

CalculateAndStoreStateAfterEvents finds the room state after the given events. Stores the resulting state in the database and returns a numeric ID for that snapshot.

func (*StateResolution) CalculateAndStoreStateBeforeEvent

func (v *StateResolution) CalculateAndStoreStateBeforeEvent(
	ctx context.Context,
	event gomatrixserverlib.PDU,
	isRejected bool,
) (types.StateSnapshotNID, error)

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.

func (*StateResolution) DifferenceBetweeenStateSnapshots

func (v *StateResolution) DifferenceBetweeenStateSnapshots(
	ctx context.Context, oldStateNID, newStateNID types.StateSnapshotNID,
) (removed, added []types.StateEntry, err error)

DifferenceBetweeenStateSnapshots works out which state entries have been added and removed between two snapshots.

func (*StateResolution) LoadCombinedStateAfterEvents

func (v *StateResolution) LoadCombinedStateAfterEvents(
	ctx context.Context, prevStates []types.StateAtEvent,
) ([]types.StateEntry, error)

LoadCombinedStateAfterEvents loads a snapshot of the state after each of the events and combines those snapshots together into a single list. At this point it is possible to run into duplicate (type, state key) tuples.

func (*StateResolution) LoadMembershipAtEvent added in v0.9.2

func (v *StateResolution) LoadMembershipAtEvent(
	ctx context.Context, eventIDs []string, stateKeyNID types.EventStateKeyNID,
) (map[string][]types.StateEntry, error)

func (*StateResolution) LoadStateAfterEventsForStringTuples

func (v *StateResolution) LoadStateAfterEventsForStringTuples(
	ctx context.Context,
	prevStates []types.StateAtEvent,
	stateKeyTuples []gomatrixserverlib.StateKeyTuple,
) ([]types.StateEntry, error)

LoadStateAfterEventsForStringTuples loads the state for a list of event type and state key pairs after list of events. This is used when we only want to load a subset of the room state after a list of events. If there is no entry for a given event type and state key pair then it will be discarded. This is typically the state before an event. Returns a sorted list of state entries or an error if there was a problem talking to the database.

func (*StateResolution) LoadStateAtEvent

func (v *StateResolution) LoadStateAtEvent(
	ctx context.Context, eventID string,
) ([]types.StateEntry, error)

LoadStateAtEvent loads the full state of a room before a particular event.

func (*StateResolution) LoadStateAtEventForHistoryVisibility added in v0.9.0

func (v *StateResolution) LoadStateAtEventForHistoryVisibility(
	ctx context.Context, eventID string,
) ([]types.StateEntry, error)

LoadStateAtEvent loads the full state of a room before a particular event.

func (*StateResolution) LoadStateAtSnapshot

func (v *StateResolution) LoadStateAtSnapshot(
	ctx context.Context, stateNID types.StateSnapshotNID,
) ([]types.StateEntry, error)

LoadStateAtSnapshot loads the full state of a room at a particular snapshot. This is typically the state before an event or the current state of a room. Returns a sorted list of state entries or an error if there was a problem talking to the database.

func (*StateResolution) LoadStateAtSnapshotForStringTuples

func (v *StateResolution) LoadStateAtSnapshotForStringTuples(
	ctx context.Context,
	stateNID types.StateSnapshotNID,
	stateKeyTuples []gomatrixserverlib.StateKeyTuple,
) ([]types.StateEntry, error)

LoadStateAtSnapshotForStringTuples loads the state for a list of event type and state key pairs at a snapshot. This is used when we only want to load a subset of the room state at a snapshot. If there is no entry for a given event type and state key pair then it will be discarded. This is typically the state before an event or the current state of a room. Returns a sorted list of state entries or an error if there was a problem talking to the database.

func (*StateResolution) Resolve added in v0.12.0

type StateResolutionStorage added in v0.6.1

type StateResolutionStorage interface {
	EventTypeNIDs(ctx context.Context, eventTypes []string) (map[string]types.EventTypeNID, error)
	EventStateKeyNIDs(ctx context.Context, eventStateKeys []string) (map[string]types.EventStateKeyNID, error)
	StateBlockNIDs(ctx context.Context, stateNIDs []types.StateSnapshotNID) ([]types.StateBlockNIDList, error)
	StateEntries(ctx context.Context, stateBlockNIDs []types.StateBlockNID) ([]types.StateEntryList, error)
	SnapshotNIDFromEventID(ctx context.Context, eventID string) (types.StateSnapshotNID, error)
	BulkSelectSnapshotsFromEventIDs(ctx context.Context, eventIDs []string) (map[types.StateSnapshotNID][]string, error)
	StateEntriesForTuples(ctx context.Context, stateBlockNIDs []types.StateBlockNID, stateKeyTuples []types.StateKeyTuple) ([]types.StateEntryList, error)
	StateAtEventIDs(ctx context.Context, eventIDs []string) ([]types.StateAtEvent, error)
	AddState(ctx context.Context, roomNID types.RoomNID, stateBlockNIDs []types.StateBlockNID, state []types.StateEntry) (types.StateSnapshotNID, error)
	Events(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, eventNIDs []types.EventNID) ([]types.Event, error)
	EventsFromIDs(ctx context.Context, roomInfo *types.RoomInfo, eventIDs []string) ([]types.Event, error)
	IsEventRejected(ctx context.Context, roomNID types.RoomNID, eventID string) (bool, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL