Documentation
¶
Index ¶
- func NextId() string
- type MatrixTransaction
- type PersistentStorage
- type PostgresStorage
- func (s *PostgresStorage) BeginMatrixTransaction(ctx context.Context, destination string) (*MatrixTransaction, Transaction, error)
- func (s *PostgresStorage) Close() error
- func (s *PostgresStorage) CreateCommunity(ctx context.Context, name string) (*StoredCommunity, error)
- func (s *PostgresStorage) DeleteRoom(ctx context.Context, roomId string) error
- func (s *PostgresStorage) GetAllRooms(ctx context.Context) ([]*StoredRoom, error)
- func (s *PostgresStorage) GetCommunity(ctx context.Context, communityId string) (*StoredCommunity, error)
- func (s *PostgresStorage) GetCommunityByAccessToken(ctx context.Context, accessToken string) (*StoredCommunity, error)
- func (s *PostgresStorage) GetDestinationsNeedingCatchup(ctx context.Context) ([]string, error)
- func (s *PostgresStorage) GetEventResult(ctx context.Context, eventId string) (*StoredEventResult, error)
- func (s *PostgresStorage) GetKeywordTemplate(ctx context.Context, name string) (*StoredKeywordTemplate, error)
- func (s *PostgresStorage) GetMediaClassification(ctx context.Context, mxcUri string, communityId string) (*StoredMediaClassification, error)
- func (s *PostgresStorage) GetRoom(ctx context.Context, roomId string) (*StoredRoom, error)
- func (s *PostgresStorage) GetTrustData(ctx context.Context, sourceName string, key string, data any) error
- func (s *PostgresStorage) GetUserIdsAndDisplayNamesByRoomId(ctx context.Context, roomId string) ([]string, []string, error)
- func (s *PostgresStorage) InsertEdu(ctx context.Context, edu *StoredEdu) error
- func (s *PostgresStorage) IsUserBannedInList(ctx context.Context, listRoomId string, userId string) (bool, error)
- func (s *PostgresStorage) PopStateLearnQueue(ctx context.Context) (*StateLearnQueueItem, Transaction, error)
- func (s *PostgresStorage) PushStateLearnQueue(ctx context.Context, item *StateLearnQueueItem) error
- func (s *PostgresStorage) SendNotify(ctx context.Context, channel string, msg string) error
- func (s *PostgresStorage) SetListBanRules(ctx context.Context, listRoomId string, entityToEntityType map[string]string) error
- func (s *PostgresStorage) SetTrustData(ctx context.Context, sourceName string, key string, data any) error
- func (s *PostgresStorage) SetUserIdsAndDisplayNamesByRoomId(ctx context.Context, roomId string, userIds []string, displayNames []string) error
- func (s *PostgresStorage) UpsertCommunity(ctx context.Context, community *StoredCommunity) error
- func (s *PostgresStorage) UpsertEventResult(ctx context.Context, event *StoredEventResult) error
- func (s *PostgresStorage) UpsertKeywordTemplate(ctx context.Context, template *StoredKeywordTemplate) error
- func (s *PostgresStorage) UpsertMediaClassification(ctx context.Context, mediaClassification *StoredMediaClassification) error
- func (s *PostgresStorage) UpsertRoom(ctx context.Context, room *StoredRoom) error
- type PostgresStorageConfig
- type PostgresStorageConnectionConfig
- type StateLearnQueueItem
- type StoredClassifications
- type StoredCommunity
- type StoredEdu
- type StoredEventResult
- type StoredKeywordTemplate
- type StoredMediaClassification
- type StoredRoom
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MatrixTransaction ¶ added in v1.4.0
type MatrixTransaction struct {
TransactionId string
Destination string
Edus []gomatrixserverlib.EDU
}
type PersistentStorage ¶
type PersistentStorage interface {
Close() error
GetAllRooms(ctx context.Context) ([]*StoredRoom, error)
GetRoom(ctx context.Context, roomId string) (*StoredRoom, error)
UpsertRoom(ctx context.Context, room *StoredRoom) error
DeleteRoom(ctx context.Context, roomId string) error
GetEventResult(ctx context.Context, eventId string) (*StoredEventResult, error)
UpsertEventResult(ctx context.Context, event *StoredEventResult) error
// GetUserIdsAndDisplayNamesByRoomId - returns (userIds, displayNames, error) for user IDs joined to the room.
// Values are deduplicated.
GetUserIdsAndDisplayNamesByRoomId(ctx context.Context, roomId string) ([]string, []string, error)
// SetUserIdsAndDisplayNamesByRoomId - replaces the stored user IDs and display names for a given room. The supplied
// slices MUST be the same length, and ordered against the user IDs slice.
SetUserIdsAndDisplayNamesByRoomId(ctx context.Context, roomId string, userIds []string, displayNames []string) error
IsUserBannedInList(ctx context.Context, listRoomId string, userId string) (bool, error)
// SetListBanRules - sets the listRoomId's ban rules to the entityToEntityType map.
// Example entityToEntityMap: {"@user:example.org":"m.policy.rule.user"}
SetListBanRules(ctx context.Context, listRoomId string, entityToEntityType map[string]string) error
CreateCommunity(ctx context.Context, name string) (*StoredCommunity, error)
UpsertCommunity(ctx context.Context, community *StoredCommunity) error
GetCommunity(ctx context.Context, id string) (*StoredCommunity, error)
GetCommunityByAccessToken(ctx context.Context, accessToken string) (*StoredCommunity, error)
// PopStateLearnQueue - returns the next item in the state learn queue, or nil if the queue is empty.
// The caller is responsible for calling Commit() on the returned Transaction, completing the operation.
PopStateLearnQueue(ctx context.Context) (*StateLearnQueueItem, Transaction, error)
PushStateLearnQueue(ctx context.Context, item *StateLearnQueueItem) error
// SetTrustData - stores arbitrary "trust" data under a given key. The key is scoped to the sourceName, and may be
// an empty string. The data is stored as JSON and must be serializable.
SetTrustData(ctx context.Context, sourceName string, key string, data any) error
GetTrustData(ctx context.Context, sourceName string, key string, result any) error
UpsertKeywordTemplate(ctx context.Context, template *StoredKeywordTemplate) error
GetKeywordTemplate(ctx context.Context, name string) (*StoredKeywordTemplate, error)
UpsertMediaClassification(ctx context.Context, classification *StoredMediaClassification) error
GetMediaClassification(ctx context.Context, mxcUri string, communityId string) (*StoredMediaClassification, error)
// BeginMatrixTransaction - pulls the data required to send (over federation) a transaction of data to a destination.
// The caller is responsible for calling Commit() on the returned SQL Transaction to indicate that the MatrixTransaction
// was successfully sent. This locks the destination to prevent concurrent sends. If no data is to be sent to the destination,
// then this returns an sql.ErrNoRows error (with a nil Transaction and nil MatrixTransaction).
BeginMatrixTransaction(ctx context.Context, destination string) (*MatrixTransaction, Transaction, error)
InsertEdu(ctx context.Context, edu *StoredEdu) error // note: not an Upsert operation
GetDestinationsNeedingCatchup(ctx context.Context) ([]string, error)
}
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
func NewPostgresStorage ¶
func NewPostgresStorage(config *PostgresStorageConfig) (*PostgresStorage, error)
func (*PostgresStorage) BeginMatrixTransaction ¶ added in v1.4.0
func (s *PostgresStorage) BeginMatrixTransaction(ctx context.Context, destination string) (*MatrixTransaction, Transaction, error)
func (*PostgresStorage) Close ¶
func (s *PostgresStorage) Close() error
func (*PostgresStorage) CreateCommunity ¶
func (s *PostgresStorage) CreateCommunity(ctx context.Context, name string) (*StoredCommunity, error)
func (*PostgresStorage) DeleteRoom ¶
func (s *PostgresStorage) DeleteRoom(ctx context.Context, roomId string) error
func (*PostgresStorage) GetAllRooms ¶
func (s *PostgresStorage) GetAllRooms(ctx context.Context) ([]*StoredRoom, error)
func (*PostgresStorage) GetCommunity ¶
func (s *PostgresStorage) GetCommunity(ctx context.Context, communityId string) (*StoredCommunity, error)
func (*PostgresStorage) GetCommunityByAccessToken ¶ added in v1.2.0
func (s *PostgresStorage) GetCommunityByAccessToken(ctx context.Context, accessToken string) (*StoredCommunity, error)
func (*PostgresStorage) GetDestinationsNeedingCatchup ¶ added in v1.4.0
func (s *PostgresStorage) GetDestinationsNeedingCatchup(ctx context.Context) ([]string, error)
func (*PostgresStorage) GetEventResult ¶
func (s *PostgresStorage) GetEventResult(ctx context.Context, eventId string) (*StoredEventResult, error)
func (*PostgresStorage) GetKeywordTemplate ¶ added in v1.1.0
func (s *PostgresStorage) GetKeywordTemplate(ctx context.Context, name string) (*StoredKeywordTemplate, error)
func (*PostgresStorage) GetMediaClassification ¶ added in v1.4.0
func (s *PostgresStorage) GetMediaClassification(ctx context.Context, mxcUri string, communityId string) (*StoredMediaClassification, error)
func (*PostgresStorage) GetRoom ¶
func (s *PostgresStorage) GetRoom(ctx context.Context, roomId string) (*StoredRoom, error)
func (*PostgresStorage) GetTrustData ¶
func (*PostgresStorage) GetUserIdsAndDisplayNamesByRoomId ¶
func (*PostgresStorage) InsertEdu ¶ added in v1.4.0
func (s *PostgresStorage) InsertEdu(ctx context.Context, edu *StoredEdu) error
func (*PostgresStorage) IsUserBannedInList ¶
func (*PostgresStorage) PopStateLearnQueue ¶
func (s *PostgresStorage) PopStateLearnQueue(ctx context.Context) (*StateLearnQueueItem, Transaction, error)
func (*PostgresStorage) PushStateLearnQueue ¶
func (s *PostgresStorage) PushStateLearnQueue(ctx context.Context, item *StateLearnQueueItem) error
func (*PostgresStorage) SendNotify ¶
func (*PostgresStorage) SetListBanRules ¶
func (*PostgresStorage) SetTrustData ¶
func (*PostgresStorage) SetUserIdsAndDisplayNamesByRoomId ¶
func (*PostgresStorage) UpsertCommunity ¶
func (s *PostgresStorage) UpsertCommunity(ctx context.Context, community *StoredCommunity) error
func (*PostgresStorage) UpsertEventResult ¶
func (s *PostgresStorage) UpsertEventResult(ctx context.Context, event *StoredEventResult) error
func (*PostgresStorage) UpsertKeywordTemplate ¶ added in v1.1.0
func (s *PostgresStorage) UpsertKeywordTemplate(ctx context.Context, template *StoredKeywordTemplate) error
func (*PostgresStorage) UpsertMediaClassification ¶ added in v1.4.0
func (s *PostgresStorage) UpsertMediaClassification(ctx context.Context, mediaClassification *StoredMediaClassification) error
func (*PostgresStorage) UpsertRoom ¶
func (s *PostgresStorage) UpsertRoom(ctx context.Context, room *StoredRoom) error
type PostgresStorageConfig ¶
type PostgresStorageConfig struct {
// Read/Write Database connection config
RWDatabase *PostgresStorageConnectionConfig
// Readonly Database connection config. If nil, the RW database will be used for RO operations
RODatabase *PostgresStorageConnectionConfig
// File path to the directory containing migrations
MigrationsPath string
}
type StateLearnQueueItem ¶
type StoredClassifications ¶ added in v1.4.0
type StoredClassifications []classification.Classification
StoredClassifications implements the SQL driver interface for scanning/setting values. Note that the Value() and Scan() functions are on different receivers - this is because the Value() is not going to be on a pointer (see StoredMediaClassification), but Scan() will always be called on a pointer. If Scan() was changed to use a value (non-pointer) receiver instead, the value we read from the database would never actually leave the function call, confusing the calling code.
func (*StoredClassifications) Scan ¶ added in v1.4.0
func (c *StoredClassifications) Scan(src interface{}) error
type StoredCommunity ¶
type StoredEdu ¶ added in v1.4.0
type StoredEdu struct {
Destination string
Payload gomatrixserverlib.EDU
}
type StoredEventResult ¶
type StoredEventResult struct {
EventId string `json:"event_id"`
IsProbablySpam bool `json:"is_probably_spam"`
ConfidenceVectors confidence.Vectors `json:"confidence_vectors"`
}
type StoredKeywordTemplate ¶ added in v1.1.0
type StoredMediaClassification ¶ added in v1.4.0
type StoredMediaClassification struct {
MxcUri string
CommunityId string
Classifications StoredClassifications
}
type StoredRoom ¶
type Transaction ¶
Click to show internal directories.
Click to hide internal directories.