helpers

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForSoftFail

func CheckForSoftFail(
	ctx context.Context,
	db storage.RoomDatabase,
	roomInfo *types.RoomInfo,
	event *types.HeaderedEvent,
	stateEventIDs []string,
	querier api.QuerySenderIDAPI,
) (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, roomID string, eventID string, serverName spec.ServerName, isServerInRoom bool, querier api.QuerySenderIDAPI,
) (bool, error)

func GetAuthEvents

GetAuthEvents returns the numeric IDs for the auth events.

func GetMembershipsAtState

func GetMembershipsAtState(
	ctx context.Context, db storage.RoomDatabase, roomInfo *types.RoomInfo, 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 string, senderID spec.SenderID,
) (bool, spec.SenderID, string, gomatrixserverlib.PDU, error)

func IsServerCurrentlyInRoom

func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, querier api.QuerySenderIDAPI, serverName spec.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.RoomDatabase, roomInfo *types.RoomInfo, eventNIDs []types.EventNID,
) ([]gomatrixserverlib.PDU, error)

func LoadStateEvents

func LoadStateEvents(
	ctx context.Context, db storage.RoomDatabase, roomInfo *types.RoomInfo, stateEntries []types.StateEntry,
) ([]gomatrixserverlib.PDU, error)

func MembershipAtEvent

func MembershipAtEvent(ctx context.Context, db storage.RoomDatabase, info *types.RoomInfo, eventIDs []string, stateKeyNID types.EventStateKeyNID, querier api.QuerySenderIDAPI) (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 spec.ServerName, querier api.QuerySenderIDAPI,
) ([]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, querier api.QuerySenderIDAPI) ([]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