Documentation
¶
Index ¶
- func NextId() string
- type PersistentStorage
- type PostgresStorage
- 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) GetEventResult(ctx context.Context, eventId string) (*StoredEventResult, 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) 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) UpsertRoom(ctx context.Context, room *StoredRoom) error
- type PostgresStorageConfig
- type PostgresStorageConnectionConfig
- type StateLearnQueueItem
- type StoredCommunity
- type StoredEventResult
- type StoredRoom
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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)
// 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
}
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
func NewPostgresStorage ¶
func NewPostgresStorage(config *PostgresStorageConfig) (*PostgresStorage, 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) GetEventResult ¶
func (s *PostgresStorage) GetEventResult(ctx context.Context, eventId string) (*StoredEventResult, error)
func (*PostgresStorage) GetRoom ¶
func (s *PostgresStorage) GetRoom(ctx context.Context, roomId string) (*StoredRoom, error)
func (*PostgresStorage) GetTrustData ¶
func (*PostgresStorage) GetUserIdsAndDisplayNamesByRoomId ¶
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) 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 StoredCommunity ¶
type StoredCommunity struct {
CommunityId string `json:"community_id"`
Name string `json:"name"`
Config *config.CommunityConfig `json:"config"`
}
type StoredEventResult ¶
type StoredEventResult struct {
EventId string `json:"event_id"`
IsProbablySpam bool `json:"is_probably_spam"`
ConfidenceVectors confidence.Vectors `json:"confidence_vectors"`
}
type StoredRoom ¶
type Transaction ¶
Click to show internal directories.
Click to hide internal directories.