Documentation ¶
Index ¶
- type Database
- func (d *Database) AddInviteEvent(ctx context.Context, inviteEvent *gomatrixserverlib.HeaderedEvent) (sp types.StreamPosition, err error)
- func (d *Database) AddPeek(ctx context.Context, roomID, userID, deviceID string) (sp types.StreamPosition, err error)
- func (d *Database) AllJoinedUsersInRoom(ctx context.Context, roomIDs []string) (map[string][]string, error)
- func (d *Database) AllJoinedUsersInRooms(ctx context.Context) (map[string][]string, error)
- func (d *Database) AllPeekingDevicesInRooms(ctx context.Context) (map[string][]types.PeekingDevice, error)
- func (d *Database) BackwardExtremitiesForRoom(ctx context.Context, roomID string) (backwardExtremities map[string][]string, err error)
- func (d *Database) CleanSendToDeviceUpdates(ctx context.Context, userID, deviceID string, before types.StreamPosition) (err error)
- func (d *Database) CurrentState(ctx context.Context, roomID string, ...) ([]*gomatrixserverlib.HeaderedEvent, error)
- func (d *Database) DeletePeek(ctx context.Context, roomID, userID, deviceID string) (sp types.StreamPosition, err error)
- func (d *Database) DeletePeeks(ctx context.Context, roomID, userID string) (sp types.StreamPosition, err error)
- func (d *Database) EventPositionInTopology(ctx context.Context, eventID string) (types.TopologyToken, error)
- func (d *Database) Events(ctx context.Context, eventIDs []string) ([]*gomatrixserverlib.HeaderedEvent, error)
- func (d *Database) GetAccountDataInRange(ctx context.Context, userID string, r types.Range, ...) (map[string][]string, types.StreamPosition, error)
- func (d *Database) GetBackwardTopologyPos(ctx context.Context, events []types.StreamEvent) (types.TopologyToken, error)
- func (d *Database) GetEventsInTopologicalRange(ctx context.Context, from, to *types.TopologyToken, roomID string, ...) (events []types.StreamEvent, err error)
- func (d *Database) GetFilter(ctx context.Context, target *gomatrixserverlib.Filter, localpart string, ...) error
- func (d *Database) GetPresence(ctx context.Context, userID string) (*types.PresenceInternal, error)
- func (d *Database) GetRoomHeroes(ctx context.Context, roomID, userID string, memberships []string) ([]string, error)
- func (d *Database) GetRoomReceipts(ctx context.Context, roomIDs []string, streamPos types.StreamPosition) ([]types.OutputReceiptEvent, error)
- func (d *Database) GetStateDeltas(ctx context.Context, device *userapi.Device, r types.Range, userID string, ...) (deltas []types.StateDelta, joinedRoomsIDs []string, err error)
- func (d *Database) GetStateDeltasForFullStateSync(ctx context.Context, device *userapi.Device, r types.Range, userID string, ...) ([]types.StateDelta, []string, error)
- func (d *Database) GetStateEvent(ctx context.Context, roomID, evType, stateKey string) (*gomatrixserverlib.HeaderedEvent, error)
- func (d *Database) GetStateEventsForRoom(ctx context.Context, roomID string, stateFilter *gomatrixserverlib.StateFilter) (stateEvents []*gomatrixserverlib.HeaderedEvent, err error)
- func (d *Database) GetUserUnreadNotificationCounts(ctx context.Context, userID string, from, to types.StreamPosition) (map[string]*eventutil.NotificationData, error)
- func (d *Database) IgnoresForUser(ctx context.Context, userID string) (*types.IgnoredUsers, error)
- func (d *Database) InviteEventsInRange(ctx context.Context, targetUserID string, r types.Range) (map[string]*gomatrixserverlib.HeaderedEvent, ...)
- func (d *Database) MaxStreamPositionForAccountData(ctx context.Context) (types.StreamPosition, error)
- func (d *Database) MaxStreamPositionForInvites(ctx context.Context) (types.StreamPosition, error)
- func (d *Database) MaxStreamPositionForNotificationData(ctx context.Context) (types.StreamPosition, error)
- func (d *Database) MaxStreamPositionForPDUs(ctx context.Context) (types.StreamPosition, error)
- func (d *Database) MaxStreamPositionForPresence(ctx context.Context) (types.StreamPosition, error)
- func (d *Database) MaxStreamPositionForReceipts(ctx context.Context) (types.StreamPosition, error)
- func (d *Database) MaxStreamPositionForSendToDeviceMessages(ctx context.Context) (types.StreamPosition, error)
- func (d *Database) MaxTopologicalPosition(ctx context.Context, roomID string) (types.TopologyToken, error)
- func (d *Database) MembershipCount(ctx context.Context, roomID, membership string, pos types.StreamPosition) (int, error)
- func (d *Database) PeeksInRange(ctx context.Context, userID, deviceID string, r types.Range) (peeks []types.Peek, err error)
- func (d *Database) PositionInTopology(ctx context.Context, eventID string) (pos types.StreamPosition, spos types.StreamPosition, err error)
- func (d *Database) PresenceAfter(ctx context.Context, after types.StreamPosition, ...) (map[string]*types.PresenceInternal, error)
- func (d *Database) PurgeRoomState(ctx context.Context, roomID string) error
- func (d *Database) PutFilter(ctx context.Context, localpart string, filter *gomatrixserverlib.Filter) (string, error)
- func (d *Database) RecentEvents(ctx context.Context, roomID string, r types.Range, ...) ([]types.StreamEvent, bool, error)
- func (d *Database) RedactEvent(ctx context.Context, redactedEventID string, ...) error
- func (d *Database) RetireInviteEvent(ctx context.Context, inviteEventID string) (sp types.StreamPosition, err error)
- func (d *Database) RoomIDsWithMembership(ctx context.Context, userID string, membership string) ([]string, error)
- func (d *Database) RoomReceiptsAfter(ctx context.Context, roomIDs []string, streamPos types.StreamPosition) (types.StreamPosition, []types.OutputReceiptEvent, error)
- func (d *Database) SelectContextAfterEvent(ctx context.Context, id int, roomID string, ...) (int, []*gomatrixserverlib.HeaderedEvent, error)
- func (d *Database) SelectContextBeforeEvent(ctx context.Context, id int, roomID string, ...) ([]*gomatrixserverlib.HeaderedEvent, error)
- func (d *Database) SelectContextEvent(ctx context.Context, roomID, eventID string) (int, gomatrixserverlib.HeaderedEvent, error)
- func (d *Database) SelectMembershipForUser(ctx context.Context, roomID, userID string, pos int64) (membership string, topologicalPos int, err error)
- func (d *Database) SendToDeviceUpdatesForSync(ctx context.Context, userID, deviceID string, from, to types.StreamPosition) (types.StreamPosition, []types.SendToDeviceEvent, error)
- func (d *Database) SharedUsers(ctx context.Context, userID string, otherUserIDs []string) ([]string, error)
- func (d *Database) StoreNewSendForDeviceMessage(ctx context.Context, userID, deviceID string, ...) (newPos types.StreamPosition, err error)
- func (d *Database) StoreReceipt(ctx context.Context, roomId, receiptType, userId, eventId string, ...) (pos types.StreamPosition, err error)
- func (d *Database) StreamEventsToEvents(device *userapi.Device, in []types.StreamEvent) []*gomatrixserverlib.HeaderedEvent
- func (d *Database) StreamToTopologicalPosition(ctx context.Context, roomID string, streamPos types.StreamPosition, ...) (types.TopologyToken, error)
- func (d *Database) UpdateIgnoresForUser(ctx context.Context, userID string, ignores *types.IgnoredUsers) error
- func (d *Database) UpdatePresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, ...) (types.StreamPosition, error)
- func (d *Database) UpsertAccountData(ctx context.Context, userID, roomID, dataType string) (sp types.StreamPosition, err error)
- func (d *Database) UpsertRoomUnreadNotificationCounts(ctx context.Context, userID, roomID string, ...) (pos types.StreamPosition, err error)
- func (d *Database) WriteEvent(ctx context.Context, ev *gomatrixserverlib.HeaderedEvent, ...) (pduPosition types.StreamPosition, returnErr error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct { DB *sql.DB Writer sqlutil.Writer Invites tables.Invites Peeks tables.Peeks AccountData tables.AccountData OutputEvents tables.Events Topology tables.Topology CurrentRoomState tables.CurrentRoomState BackwardExtremities tables.BackwardsExtremities SendToDevice tables.SendToDevice Filter tables.Filter Receipts tables.Receipts Memberships tables.Memberships NotificationData tables.NotificationData Ignores tables.Ignores Presence tables.Presence }
Database is a temporary struct until we have made syncserver.go the same for both pq/sqlite For now this contains the shared functions
func (*Database) AddInviteEvent ¶
func (d *Database) AddInviteEvent( ctx context.Context, inviteEvent *gomatrixserverlib.HeaderedEvent, ) (sp types.StreamPosition, err error)
AddInviteEvent stores a new invite event for a user. If the invite was successfully stored this returns the stream ID it was stored at. Returns an error if there was a problem communicating with the database.
func (*Database) AddPeek ¶
func (d *Database) AddPeek( ctx context.Context, roomID, userID, deviceID string, ) (sp types.StreamPosition, err error)
AddPeek tracks the fact that a user has started peeking. If the peek was successfully stored this returns the stream ID it was stored at. Returns an error if there was a problem communicating with the database.
func (*Database) AllJoinedUsersInRoom ¶ added in v0.8.3
func (*Database) AllJoinedUsersInRooms ¶
func (*Database) AllPeekingDevicesInRooms ¶
func (*Database) BackwardExtremitiesForRoom ¶
func (*Database) CleanSendToDeviceUpdates ¶
func (*Database) CurrentState ¶ added in v0.3.5
func (d *Database) CurrentState(ctx context.Context, roomID string, stateFilterPart *gomatrixserverlib.StateFilter, excludeEventIDs []string) ([]*gomatrixserverlib.HeaderedEvent, error)
func (*Database) DeletePeek ¶ added in v0.3.3
func (d *Database) DeletePeek( ctx context.Context, roomID, userID, deviceID string, ) (sp types.StreamPosition, err error)
DeletePeek tracks the fact that a user has stopped peeking from the specified device. If the peeks was successfully deleted this returns the stream ID it was stored at. Returns an error if there was a problem communicating with the database.
func (*Database) DeletePeeks ¶
func (d *Database) DeletePeeks( ctx context.Context, roomID, userID string, ) (sp types.StreamPosition, err error)
DeletePeeks tracks the fact that a user has stopped peeking from all devices If the peeks was successfully deleted this returns the stream ID it was stored at. Returns an error if there was a problem communicating with the database.
func (*Database) EventPositionInTopology ¶
func (*Database) Events ¶
func (d *Database) Events(ctx context.Context, eventIDs []string) ([]*gomatrixserverlib.HeaderedEvent, error)
Events lookups a list of event by their event ID. Returns a list of events matching the requested IDs found in the database. If an event is not found in the database then it will be omitted from the list. Returns an error if there was a problem talking with the database. Does not include any transaction IDs in the returned events.
func (*Database) GetAccountDataInRange ¶
func (d *Database) GetAccountDataInRange( ctx context.Context, userID string, r types.Range, accountDataFilterPart *gomatrixserverlib.EventFilter, ) (map[string][]string, types.StreamPosition, error)
GetAccountDataInRange returns all account data for a given user inserted or updated between two given positions Returns a map following the format data[roomID] = []dataTypes If no data is retrieved, returns an empty map If there was an issue with the retrieval, returns an error
func (*Database) GetBackwardTopologyPos ¶ added in v0.3.5
func (d *Database) GetBackwardTopologyPos( ctx context.Context, events []types.StreamEvent, ) (types.TopologyToken, error)
GetBackwardTopologyPos retrieves the backward topology position, i.e. the position of the oldest event in the room's topology.
func (*Database) GetEventsInTopologicalRange ¶
func (d *Database) GetEventsInTopologicalRange( ctx context.Context, from, to *types.TopologyToken, roomID string, filter *gomatrixserverlib.RoomEventFilter, backwardOrdering bool, ) (events []types.StreamEvent, err error)
func (*Database) GetPresence ¶ added in v0.8.0
func (*Database) GetRoomHeroes ¶ added in v0.8.2
func (*Database) GetRoomReceipts ¶ added in v0.3.0
func (d *Database) GetRoomReceipts(ctx context.Context, roomIDs []string, streamPos types.StreamPosition) ([]types.OutputReceiptEvent, error)
func (*Database) GetStateDeltas ¶ added in v0.3.5
func (d *Database) GetStateDeltas( ctx context.Context, device *userapi.Device, r types.Range, userID string, stateFilter *gomatrixserverlib.StateFilter, ) (deltas []types.StateDelta, joinedRoomsIDs []string, err error)
GetStateDeltas returns the state deltas between fromPos and toPos, exclusive of oldPos, inclusive of newPos, for the rooms in which the user has new membership events. A list of joined room IDs is also returned in case the caller needs it.
func (*Database) GetStateDeltasForFullStateSync ¶ added in v0.3.5
func (d *Database) GetStateDeltasForFullStateSync( ctx context.Context, device *userapi.Device, r types.Range, userID string, stateFilter *gomatrixserverlib.StateFilter, ) ([]types.StateDelta, []string, error)
GetStateDeltasForFullStateSync is a variant of getStateDeltas used for /sync requests with full_state=true. Fetches full state for all joined rooms and uses selectStateInRange to get updates for other rooms.
func (*Database) GetStateEvent ¶
func (d *Database) GetStateEvent( ctx context.Context, roomID, evType, stateKey string, ) (*gomatrixserverlib.HeaderedEvent, error)
func (*Database) GetStateEventsForRoom ¶
func (d *Database) GetStateEventsForRoom( ctx context.Context, roomID string, stateFilter *gomatrixserverlib.StateFilter, ) (stateEvents []*gomatrixserverlib.HeaderedEvent, err error)
func (*Database) GetUserUnreadNotificationCounts ¶ added in v0.6.5
func (d *Database) GetUserUnreadNotificationCounts(ctx context.Context, userID string, from, to types.StreamPosition) (map[string]*eventutil.NotificationData, error)
func (*Database) IgnoresForUser ¶ added in v0.8.0
func (*Database) InviteEventsInRange ¶ added in v0.3.5
func (d *Database) InviteEventsInRange(ctx context.Context, targetUserID string, r types.Range) (map[string]*gomatrixserverlib.HeaderedEvent, map[string]*gomatrixserverlib.HeaderedEvent, error)
func (*Database) MaxStreamPositionForAccountData ¶ added in v0.3.5
func (*Database) MaxStreamPositionForInvites ¶ added in v0.3.5
func (*Database) MaxStreamPositionForNotificationData ¶ added in v0.6.5
func (*Database) MaxStreamPositionForPDUs ¶ added in v0.3.5
func (*Database) MaxStreamPositionForPresence ¶ added in v0.8.0
func (*Database) MaxStreamPositionForReceipts ¶ added in v0.3.5
func (*Database) MaxStreamPositionForSendToDeviceMessages ¶ added in v0.3.6
func (*Database) MaxTopologicalPosition ¶
func (*Database) MembershipCount ¶ added in v0.8.0
func (*Database) PeeksInRange ¶ added in v0.3.5
func (*Database) PositionInTopology ¶ added in v0.3.5
func (d *Database) PositionInTopology(ctx context.Context, eventID string) (pos types.StreamPosition, spos types.StreamPosition, err error)
func (*Database) PresenceAfter ¶ added in v0.8.0
func (d *Database) PresenceAfter(ctx context.Context, after types.StreamPosition, filter gomatrixserverlib.EventFilter) (map[string]*types.PresenceInternal, error)
func (*Database) PurgeRoomState ¶ added in v0.2.1
func (*Database) RecentEvents ¶ added in v0.3.5
func (d *Database) RecentEvents(ctx context.Context, roomID string, r types.Range, eventFilter *gomatrixserverlib.RoomEventFilter, chronologicalOrder bool, onlySyncEvents bool) ([]types.StreamEvent, bool, error)
func (*Database) RedactEvent ¶
func (d *Database) RedactEvent(ctx context.Context, redactedEventID string, redactedBecause *gomatrixserverlib.HeaderedEvent) error
func (*Database) RetireInviteEvent ¶
func (d *Database) RetireInviteEvent( ctx context.Context, inviteEventID string, ) (sp types.StreamPosition, err error)
RetireInviteEvent removes an old invite event from the database. Returns an error if there was a problem communicating with the database.
func (*Database) RoomIDsWithMembership ¶ added in v0.3.5
func (*Database) RoomReceiptsAfter ¶ added in v0.3.5
func (d *Database) RoomReceiptsAfter(ctx context.Context, roomIDs []string, streamPos types.StreamPosition) (types.StreamPosition, []types.OutputReceiptEvent, error)
func (*Database) SelectContextAfterEvent ¶ added in v0.6.4
func (d *Database) SelectContextAfterEvent(ctx context.Context, id int, roomID string, filter *gomatrixserverlib.RoomEventFilter) (int, []*gomatrixserverlib.HeaderedEvent, error)
func (*Database) SelectContextBeforeEvent ¶ added in v0.6.4
func (d *Database) SelectContextBeforeEvent(ctx context.Context, id int, roomID string, filter *gomatrixserverlib.RoomEventFilter) ([]*gomatrixserverlib.HeaderedEvent, error)
func (*Database) SelectContextEvent ¶ added in v0.6.4
func (d *Database) SelectContextEvent(ctx context.Context, roomID, eventID string) (int, gomatrixserverlib.HeaderedEvent, error)
func (*Database) SelectMembershipForUser ¶ added in v0.9.2
func (*Database) SendToDeviceUpdatesForSync ¶
func (d *Database) SendToDeviceUpdatesForSync( ctx context.Context, userID, deviceID string, from, to types.StreamPosition, ) (types.StreamPosition, []types.SendToDeviceEvent, error)
func (*Database) SharedUsers ¶ added in v0.9.0
func (*Database) StoreNewSendForDeviceMessage ¶
func (d *Database) StoreNewSendForDeviceMessage( ctx context.Context, userID, deviceID string, event gomatrixserverlib.SendToDeviceEvent, ) (newPos types.StreamPosition, err error)
func (*Database) StoreReceipt ¶ added in v0.3.0
func (d *Database) StoreReceipt(ctx context.Context, roomId, receiptType, userId, eventId string, timestamp gomatrixserverlib.Timestamp) (pos types.StreamPosition, err error)
StoreReceipt stores user receipts
func (*Database) StreamEventsToEvents ¶
func (d *Database) StreamEventsToEvents(device *userapi.Device, in []types.StreamEvent) []*gomatrixserverlib.HeaderedEvent
func (*Database) StreamToTopologicalPosition ¶ added in v0.7.0
func (d *Database) StreamToTopologicalPosition( ctx context.Context, roomID string, streamPos types.StreamPosition, backwardOrdering bool, ) (types.TopologyToken, error)
func (*Database) UpdateIgnoresForUser ¶ added in v0.8.0
func (*Database) UpdatePresence ¶ added in v0.8.0
func (*Database) UpsertAccountData ¶
func (d *Database) UpsertAccountData( ctx context.Context, userID, roomID, dataType string, ) (sp types.StreamPosition, err error)
UpsertAccountData keeps track of new or updated account data, by saving the type of the new/updated data, and the user ID and room ID the data is related to (empty) room ID means the data isn't specific to any room) If no data with the given type, user ID and room ID exists in the database, creates a new row, else update the existing one Returns an error if there was an issue with the upsert
func (*Database) UpsertRoomUnreadNotificationCounts ¶ added in v0.6.5
func (*Database) WriteEvent ¶
func (d *Database) WriteEvent( ctx context.Context, ev *gomatrixserverlib.HeaderedEvent, addStateEvents []*gomatrixserverlib.HeaderedEvent, addStateEventIDs, removeStateEventIDs []string, transactionID *api.TransactionID, excludeFromSync bool, historyVisibility gomatrixserverlib.HistoryVisibility, ) (pduPosition types.StreamPosition, returnErr error)