shared

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	DB                  *sql.DB
	Cache               caching.RoomServerCaches
	Writer              sqlutil.Writer
	EventsTable         tables.Events
	EventJSONTable      tables.EventJSON
	EventTypesTable     tables.EventTypes
	EventStateKeysTable tables.EventStateKeys
	RoomsTable          tables.Rooms
	StateSnapshotTable  tables.StateSnapshot
	StateBlockTable     tables.StateBlock
	RoomAliasesTable    tables.RoomAliases
	PrevEventsTable     tables.PreviousEvents
	InvitesTable        tables.Invites
	MembershipTable     tables.Membership
	PublishedTable      tables.Published
	RedactionsTable     tables.Redactions
	GetRoomUpdaterFn    func(ctx context.Context, roomInfo *types.RoomInfo) (*RoomUpdater, error)
}

func (*Database) AddState

func (d *Database) AddState(
	ctx context.Context,
	roomNID types.RoomNID,
	stateBlockNIDs []types.StateBlockNID,
	state []types.StateEntry,
) (stateNID types.StateSnapshotNID, err error)

func (*Database) EventIDs

func (d *Database) EventIDs(
	ctx context.Context, eventNIDs []types.EventNID,
) (map[types.EventNID]string, error)

func (*Database) EventNIDs

func (d *Database) EventNIDs(
	ctx context.Context, eventIDs []string,
) (map[string]types.EventNID, error)

func (*Database) EventStateKeyNIDs

func (d *Database) EventStateKeyNIDs(
	ctx context.Context, eventStateKeys []string,
) (map[string]types.EventStateKeyNID, error)

func (*Database) EventStateKeys

func (d *Database) EventStateKeys(
	ctx context.Context, eventStateKeyNIDs []types.EventStateKeyNID,
) (map[types.EventStateKeyNID]string, error)

func (*Database) EventTypeNIDs

func (d *Database) EventTypeNIDs(
	ctx context.Context, eventTypes []string,
) (map[string]types.EventTypeNID, error)

func (*Database) Events

func (d *Database) Events(
	ctx context.Context, eventNIDs []types.EventNID,
) ([]types.Event, error)

func (*Database) EventsFromIDs

func (d *Database) EventsFromIDs(ctx context.Context, eventIDs []string) ([]types.Event, error)

func (*Database) ForgetRoom added in v0.3.0

func (d *Database) ForgetRoom(ctx context.Context, userID, roomID string, forget bool) error

ForgetRoom sets a users room to forgotten

func (*Database) GetAliasesForRoomID

func (d *Database) GetAliasesForRoomID(ctx context.Context, roomID string) ([]string, error)

func (*Database) GetBulkStateContent

func (d *Database) GetBulkStateContent(ctx context.Context, roomIDs []string, tuples []gomatrixserverlib.StateKeyTuple, allowWildcards bool) ([]tables.StrippedEvent, error)

GetBulkStateContent returns all state events which match a given room ID and a given state key tuple. Both must be satisfied for a match. If a tuple has the StateKey of '*' and allowWildcards=true then all state events with the EventType should be returned.

func (*Database) GetCreatorIDForAlias

func (d *Database) GetCreatorIDForAlias(
	ctx context.Context, alias string,
) (string, error)

func (*Database) GetInvitesForUser

func (d *Database) GetInvitesForUser(
	ctx context.Context,
	roomNID types.RoomNID,
	targetUserNID types.EventStateKeyNID,
) (senderUserIDs []types.EventStateKeyNID, eventIDs []string, err error)

func (*Database) GetKnownRooms

func (d *Database) GetKnownRooms(ctx context.Context) ([]string, error)

GetKnownRooms returns a list of all rooms we know about.

func (*Database) GetKnownUsers

func (d *Database) GetKnownUsers(ctx context.Context, userID, searchString string, limit int) ([]string, error)

GetKnownUsers searches all users that userID knows about.

func (*Database) GetLocalServerInRoom added in v0.4.0

func (d *Database) GetLocalServerInRoom(ctx context.Context, roomNID types.RoomNID) (bool, error)

GetLocalServerInRoom returns true if we think we're in a given room or false otherwise.

func (*Database) GetMembership

func (d *Database) GetMembership(ctx context.Context, roomNID types.RoomNID, requestSenderUserID string) (membershipEventNID types.EventNID, stillInRoom, isRoomforgotten bool, err error)

func (*Database) GetMembershipEventNIDsForRoom

func (d *Database) GetMembershipEventNIDsForRoom(
	ctx context.Context, roomNID types.RoomNID, joinOnly bool, localOnly bool,
) ([]types.EventNID, error)

func (*Database) GetPublishedRoom added in v0.7.0

func (d *Database) GetPublishedRoom(ctx context.Context, roomID string) (bool, error)

func (*Database) GetPublishedRooms

func (d *Database) GetPublishedRooms(ctx context.Context) ([]string, error)

func (*Database) GetRoomIDForAlias

func (d *Database) GetRoomIDForAlias(ctx context.Context, alias string) (string, error)

func (*Database) GetRoomUpdater added in v0.6.1

func (d *Database) GetRoomUpdater(
	ctx context.Context, roomInfo *types.RoomInfo,
) (*RoomUpdater, error)

func (*Database) GetRoomsByMembership

func (d *Database) GetRoomsByMembership(ctx context.Context, userID, membership string) ([]string, error)

GetRoomsByMembership returns a list of room IDs matching the provided membership and user ID (as state_key).

func (*Database) GetServerInRoom added in v0.4.1

func (d *Database) GetServerInRoom(ctx context.Context, roomNID types.RoomNID, serverName gomatrixserverlib.ServerName) (bool, error)

GetServerInRoom returns true if we think a server is in a given room or false otherwise.

func (*Database) GetStateEvent

func (d *Database) GetStateEvent(ctx context.Context, roomID, evType, stateKey string) (*gomatrixserverlib.HeaderedEvent, error)

GetStateEvent returns the current state event of a given type for a given room with a given state key If no event could be found, returns nil If there was an issue during the retrieval, returns an error

func (*Database) GetStateEventsWithEventType added in v0.6.5

func (d *Database) GetStateEventsWithEventType(ctx context.Context, roomID, evType string) ([]*gomatrixserverlib.HeaderedEvent, error)

Same as GetStateEvent but returns all matching state events with this event type. Returns no error if there are no events with this event type.

func (*Database) JoinedUsersSetInRooms

func (d *Database) JoinedUsersSetInRooms(ctx context.Context, roomIDs, userIDs []string) (map[string]int, error)

JoinedUsersSetInRooms returns a map of how many times the given users appear in the specified rooms.

func (*Database) LatestEventIDs

func (d *Database) LatestEventIDs(
	ctx context.Context, roomNID types.RoomNID,
) (references []gomatrixserverlib.EventReference, currentStateSnapshotNID types.StateSnapshotNID, depth int64, err error)

func (*Database) MembershipUpdater

func (d *Database) MembershipUpdater(
	ctx context.Context, roomID, targetUserID string,
	targetLocal bool, roomVersion gomatrixserverlib.RoomVersion,
) (*MembershipUpdater, error)

func (*Database) MissingAuthPrevEvents added in v0.6.5

func (d *Database) MissingAuthPrevEvents(
	ctx context.Context, e *gomatrixserverlib.Event,
) (missingAuth, missingPrev []string, err error)

func (*Database) PublishRoom

func (d *Database) PublishRoom(ctx context.Context, roomID string, publish bool) error

func (*Database) RemoveRoomAlias

func (d *Database) RemoveRoomAlias(ctx context.Context, alias string) error

func (*Database) RoomInfo

func (d *Database) RoomInfo(ctx context.Context, roomID string) (*types.RoomInfo, error)

func (*Database) SetRoomAlias

func (d *Database) SetRoomAlias(ctx context.Context, alias string, roomID string, creatorUserID string) error

func (*Database) SetState

func (d *Database) SetState(
	ctx context.Context, eventNID types.EventNID, stateNID types.StateSnapshotNID,
) error

func (*Database) SnapshotNIDFromEventID

func (d *Database) SnapshotNIDFromEventID(
	ctx context.Context, eventID string,
) (types.StateSnapshotNID, error)

func (*Database) StateAtEventIDs

func (d *Database) StateAtEventIDs(
	ctx context.Context, eventIDs []string,
) ([]types.StateAtEvent, error)

func (*Database) StateBlockNIDs

func (d *Database) StateBlockNIDs(
	ctx context.Context, stateNIDs []types.StateSnapshotNID,
) ([]types.StateBlockNIDList, error)

func (*Database) StateEntries

func (d *Database) StateEntries(
	ctx context.Context, stateBlockNIDs []types.StateBlockNID,
) ([]types.StateEntryList, error)

func (*Database) StateEntriesForEventIDs

func (d *Database) StateEntriesForEventIDs(
	ctx context.Context, eventIDs []string,
) ([]types.StateEntry, error)

func (*Database) StateEntriesForTuples

func (d *Database) StateEntriesForTuples(
	ctx context.Context,
	stateBlockNIDs []types.StateBlockNID,
	stateKeyTuples []types.StateKeyTuple,
) ([]types.StateEntryList, error)

func (*Database) StoreEvent

func (d *Database) StoreEvent(
	ctx context.Context, event *gomatrixserverlib.Event,
	authEventNIDs []types.EventNID, isRejected bool,
) (types.EventNID, types.RoomNID, types.StateAtEvent, *gomatrixserverlib.Event, string, error)

func (*Database) SupportsConcurrentRoomInputs

func (d *Database) SupportsConcurrentRoomInputs() bool

type MembershipUpdater

type MembershipUpdater struct {
	// contains filtered or unexported fields
}

func NewMembershipUpdater

func NewMembershipUpdater(
	ctx context.Context, d *Database, txn *sql.Tx, roomID, targetUserID string,
	targetLocal bool, roomVersion gomatrixserverlib.RoomVersion,
) (*MembershipUpdater, error)

func (*MembershipUpdater) Commit

func (t *MembershipUpdater) Commit() error

Commit implements types.Transaction

func (*MembershipUpdater) IsInvite

func (u *MembershipUpdater) IsInvite() bool

IsInvite implements types.MembershipUpdater

func (*MembershipUpdater) IsJoin

func (u *MembershipUpdater) IsJoin() bool

IsJoin implements types.MembershipUpdater

func (*MembershipUpdater) IsKnock added in v0.4.1

func (u *MembershipUpdater) IsKnock() bool

IsKnock implements types.MembershipUpdater

func (*MembershipUpdater) IsLeave

func (u *MembershipUpdater) IsLeave() bool

IsLeave implements types.MembershipUpdater

func (*MembershipUpdater) Rollback

func (t *MembershipUpdater) Rollback() error

Rollback implements types.Transaction

func (*MembershipUpdater) SetToInvite

func (u *MembershipUpdater) SetToInvite(event *gomatrixserverlib.Event) (bool, error)

SetToInvite implements types.MembershipUpdater

func (*MembershipUpdater) SetToJoin

func (u *MembershipUpdater) SetToJoin(senderUserID string, eventID string, isUpdate bool) ([]string, error)

SetToJoin implements types.MembershipUpdater

func (*MembershipUpdater) SetToKnock added in v0.4.1

func (u *MembershipUpdater) SetToKnock(event *gomatrixserverlib.Event) (bool, error)

SetToKnock implements types.MembershipUpdater

func (*MembershipUpdater) SetToLeave

func (u *MembershipUpdater) SetToLeave(senderUserID string, eventID string) ([]string, error)

SetToLeave implements types.MembershipUpdater

type RoomUpdater added in v0.6.1

type RoomUpdater struct {
	// contains filtered or unexported fields
}

func NewRoomUpdater added in v0.6.1

func NewRoomUpdater(ctx context.Context, d *Database, txn *sql.Tx, roomInfo *types.RoomInfo) (*RoomUpdater, error)

func (*RoomUpdater) AddState added in v0.6.1

func (u *RoomUpdater) AddState(
	ctx context.Context,
	roomNID types.RoomNID,
	stateBlockNIDs []types.StateBlockNID,
	state []types.StateEntry,
) (stateNID types.StateSnapshotNID, err error)

func (*RoomUpdater) Commit added in v0.6.1

func (u *RoomUpdater) Commit() error

Implements sqlutil.Transaction

func (*RoomUpdater) CurrentStateSnapshotNID added in v0.6.1

func (u *RoomUpdater) CurrentStateSnapshotNID() types.StateSnapshotNID

CurrentStateSnapshotNID implements types.RoomRecentEventsUpdater

func (*RoomUpdater) EventIDs added in v0.6.1

func (u *RoomUpdater) EventIDs(
	ctx context.Context, eventNIDs []types.EventNID,
) (map[types.EventNID]string, error)

func (*RoomUpdater) EventStateKeyNIDs added in v0.6.1

func (u *RoomUpdater) EventStateKeyNIDs(
	ctx context.Context, eventStateKeys []string,
) (map[string]types.EventStateKeyNID, error)

func (*RoomUpdater) EventTypeNIDs added in v0.6.1

func (u *RoomUpdater) EventTypeNIDs(
	ctx context.Context, eventTypes []string,
) (map[string]types.EventTypeNID, error)

func (*RoomUpdater) Events added in v0.6.1

func (u *RoomUpdater) Events(
	ctx context.Context, eventNIDs []types.EventNID,
) ([]types.Event, error)

func (*RoomUpdater) EventsFromIDs added in v0.6.1

func (u *RoomUpdater) EventsFromIDs(ctx context.Context, eventIDs []string) ([]types.Event, error)

func (*RoomUpdater) HasEventBeenSent added in v0.6.1

func (u *RoomUpdater) HasEventBeenSent(eventNID types.EventNID) (bool, error)

HasEventBeenSent implements types.RoomRecentEventsUpdater

func (*RoomUpdater) IsReferenced added in v0.6.1

func (u *RoomUpdater) IsReferenced(eventReference gomatrixserverlib.EventReference) (bool, error)

IsReferenced implements types.RoomRecentEventsUpdater

func (*RoomUpdater) LastEventIDSent added in v0.6.1

func (u *RoomUpdater) LastEventIDSent() string

LastEventIDSent implements types.RoomRecentEventsUpdater

func (*RoomUpdater) LatestEvents added in v0.6.1

func (u *RoomUpdater) LatestEvents() []types.StateAtEventAndReference

LatestEvents implements types.RoomRecentEventsUpdater

func (*RoomUpdater) MarkEventAsSent added in v0.6.1

func (u *RoomUpdater) MarkEventAsSent(eventNID types.EventNID) error

MarkEventAsSent implements types.RoomRecentEventsUpdater

func (*RoomUpdater) MembershipUpdater added in v0.6.1

func (u *RoomUpdater) MembershipUpdater(targetUserNID types.EventStateKeyNID, targetLocal bool) (*MembershipUpdater, error)

func (*RoomUpdater) Rollback added in v0.6.1

func (u *RoomUpdater) Rollback() error

Implements sqlutil.Transaction

func (*RoomUpdater) RoomExists added in v0.6.4

func (u *RoomUpdater) RoomExists() bool

RoomExists returns true if the room exists and false otherwise.

func (*RoomUpdater) RoomInfo added in v0.6.1

func (u *RoomUpdater) RoomInfo(ctx context.Context, roomID string) (*types.RoomInfo, error)

func (*RoomUpdater) RoomVersion added in v0.6.1

func (u *RoomUpdater) RoomVersion() (version gomatrixserverlib.RoomVersion)

RoomVersion implements types.RoomRecentEventsUpdater

func (*RoomUpdater) SetLatestEvents added in v0.6.1

func (u *RoomUpdater) SetLatestEvents(
	roomNID types.RoomNID, latest []types.StateAtEventAndReference, lastEventNIDSent types.EventNID,
	currentStateSnapshotNID types.StateSnapshotNID,
) error

SetLatestEvents implements types.RoomRecentEventsUpdater

func (*RoomUpdater) SetState added in v0.6.1

func (u *RoomUpdater) SetState(
	ctx context.Context, eventNID types.EventNID, stateNID types.StateSnapshotNID,
) error

func (*RoomUpdater) SnapshotNIDFromEventID added in v0.6.1

func (u *RoomUpdater) SnapshotNIDFromEventID(
	ctx context.Context, eventID string,
) (types.StateSnapshotNID, error)

func (*RoomUpdater) StateAtEventIDs added in v0.6.1

func (u *RoomUpdater) StateAtEventIDs(
	ctx context.Context, eventIDs []string,
) ([]types.StateAtEvent, error)

func (*RoomUpdater) StateBlockNIDs added in v0.6.1

func (u *RoomUpdater) StateBlockNIDs(
	ctx context.Context, stateNIDs []types.StateSnapshotNID,
) ([]types.StateBlockNIDList, error)

func (*RoomUpdater) StateEntries added in v0.6.1

func (u *RoomUpdater) StateEntries(
	ctx context.Context, stateBlockNIDs []types.StateBlockNID,
) ([]types.StateEntryList, error)

func (*RoomUpdater) StateEntriesForTuples added in v0.6.1

func (u *RoomUpdater) StateEntriesForTuples(
	ctx context.Context,
	stateBlockNIDs []types.StateBlockNID,
	stateKeyTuples []types.StateKeyTuple,
) ([]types.StateEntryList, error)

func (*RoomUpdater) StorePreviousEvents added in v0.6.1

func (u *RoomUpdater) StorePreviousEvents(eventNID types.EventNID, previousEventReferences []gomatrixserverlib.EventReference) error

StorePreviousEvents implements types.RoomRecentEventsUpdater - This must be called from a Writer

func (*RoomUpdater) UnsentEventsFromIDs added in v0.6.4

func (u *RoomUpdater) UnsentEventsFromIDs(ctx context.Context, eventIDs []string) ([]types.Event, error)

type StatementList

type StatementList []struct {
	Statement **sql.Stmt
	SQL       string
}

StatementList is a list of SQL statements to prepare and a pointer to where to store the resulting prepared statement.

func (StatementList) Prepare

func (s StatementList) Prepare(db *sql.DB) (err error)

Prepare the SQL for each statement in the list and assign the result to the prepared statement.

type UnsentFilter added in v0.6.4

type UnsentFilter bool
const (
	NoFilter         UnsentFilter = false
	FilterUnsentOnly UnsentFilter = true
)

Jump to

Keyboard shortcuts

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