helpers

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: Apache-2.0 Imports: 14 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, error)

func IsServerCurrentlyInRoom

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

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 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, error)

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

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 *gomatrixserverlib.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