helpers

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuthEvents

func CheckAuthEvents(
	ctx context.Context,
	db storage.Database,
	event *gomatrixserverlib.HeaderedEvent,
	authEventIDs []string,
) ([]types.EventNID, error)

CheckAuthEvents checks that the event passes authentication checks Returns the numeric IDs for the auth events.

func CheckForSoftFail

func CheckForSoftFail(
	ctx context.Context,
	db storage.Database,
	event *gomatrixserverlib.HeaderedEvent,
	stateEventIDs []string,
) (bool, error)

CheckForSoftFail returns true if the event should be soft-failed and false otherwise. The return error value should be checked before the soft-fail bool.

func CheckServerAllowedToSeeEvent

func CheckServerAllowedToSeeEvent(
	ctx context.Context, db storage.Database, info *types.RoomInfo, eventID string, serverName gomatrixserverlib.ServerName, isServerInRoom bool,
) (bool, error)

func GetMembershipsAtState

func GetMembershipsAtState(
	ctx context.Context, db storage.Database, stateEntries []types.StateEntry, joinedOnly bool,
) ([]types.Event, error)

GetMembershipsAtState filters the state events to only keep the "m.room.member" events with a "join" membership. These events are returned. Returns an error if there was an issue fetching the events.

func IsInvitePending

func IsInvitePending(
	ctx context.Context, db storage.Database,
	roomID, userID string,
) (bool, string, string, *gomatrixserverlib.Event, error)

func IsServerCurrentlyInRoom

func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, serverName gomatrixserverlib.ServerName, roomID string) (bool, error)

IsServerCurrentlyInRoom checks if a server is in a given room, based on the room memberships. If the servername is not supplied then the local server will be checked instead using a faster code path. TODO: This should probably be replaced by an API call.

func LoadEvents

func LoadEvents(
	ctx context.Context, db storage.Database, eventNIDs []types.EventNID,
) ([]*gomatrixserverlib.Event, error)

func LoadStateEvents

func LoadStateEvents(
	ctx context.Context, db storage.Database, stateEntries []types.StateEntry,
) ([]*gomatrixserverlib.Event, error)

func MembershipAtEvent added in v0.9.2

func MembershipAtEvent(ctx context.Context, db storage.Database, info *types.RoomInfo, eventIDs []string, stateKeyNID types.EventStateKeyNID) (map[string][]types.StateEntry, error)

func ScanEventTree

func ScanEventTree(
	ctx context.Context, db storage.Database, info *types.RoomInfo, front []string, visited map[string]bool, limit int,
	serverName gomatrixserverlib.ServerName,
) ([]types.EventNID, map[string]struct{}, error)

TODO: Remove this when we have tests to assert correctness of this function

func StateBeforeEvent

func StateBeforeEvent(ctx context.Context, db storage.Database, info *types.RoomInfo, eventNID types.EventNID) ([]types.StateEntry, error)

func UpdateToInviteMembership

func UpdateToInviteMembership(
	mu *shared.MembershipUpdater, add *types.Event, updates []api.OutputEvent,
	roomVersion gomatrixserverlib.RoomVersion,
) ([]api.OutputEvent, error)

Types

type EventMap

type EventMap []types.Event

Map from numeric event ID to event. Implemented using binary search on a sorted array.

func (EventMap) Lookup

func (m EventMap) Lookup(eventNID types.EventNID) (event *types.Event, ok bool)

lookup an entry in the event map.

Jump to

Keyboard shortcuts

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