Documentation ¶
Index ¶
- Variables
- func SetRandomSeed() int64
- type CQueue
- type Config
- type MemStore
- func (s *MemStore) Channel(channelId string) (*model.Channel, error)
- func (s *MemStore) ChannelMember(channelId, userId string) (model.ChannelMember, error)
- func (s *MemStore) ChannelMembers(channelId string) (model.ChannelMembers, error)
- func (s *MemStore) ChannelPosts(channelId string) ([]*model.Post, error)
- func (s *MemStore) ChannelPostsSorted(channelId string, asc bool) ([]*model.Post, error)
- func (s *MemStore) ChannelStats(channelId string) (*model.ChannelStats, error)
- func (s *MemStore) ChannelView(channelId string) (int64, error)
- func (s *MemStore) Channels(teamId string) ([]model.Channel, error)
- func (s *MemStore) Clear()
- func (s *MemStore) ClientConfig() map[string]string
- func (s *MemStore) Config() model.Config
- func (s *MemStore) CurrentChannel() (*model.Channel, error)
- func (s *MemStore) CurrentTeam() (*model.Team, error)
- func (s *MemStore) DeletePost(postId string) error
- func (s *MemStore) DeleteReaction(reaction *model.Reaction) (bool, error)
- func (s *MemStore) Email() string
- func (s *MemStore) FeatureFlags() map[string]bool
- func (s *MemStore) FileInfoForPost(postId string) ([]*model.FileInfo, error)
- func (s *MemStore) GetUser(userId string) (model.User, error)
- func (s *MemStore) Id() string
- func (s *MemStore) IsTeamMember(teamId, userId string) bool
- func (s *MemStore) MarkAllThreadsInTeamAsRead(teamId string) error
- func (s *MemStore) Password() string
- func (s *MemStore) Post(postId string) (*model.Post, error)
- func (s *MemStore) PostsIdsSince(ts int64) ([]string, error)
- func (s *MemStore) PostsWithAckRequests() ([]string, error)
- func (s *MemStore) Preferences() (model.Preferences, error)
- func (s *MemStore) ProfileImageLastUpdated(userId string) (int, error)
- func (s *MemStore) RandomCategory(teamID string) (model.SidebarCategoryWithChannels, error)
- func (s *MemStore) RandomChannel(teamId string, st store.SelectionType) (model.Channel, error)
- func (s *MemStore) RandomChannelMember(channelId string) (model.ChannelMember, error)
- func (s *MemStore) RandomDraftForTeam(teamId string) (string, error)
- func (s *MemStore) RandomEmoji() (model.Emoji, error)
- func (s *MemStore) RandomPost(st store.SelectionType) (model.Post, error)
- func (s *MemStore) RandomPostForChannel(channelId string) (model.Post, error)
- func (s *MemStore) RandomPostForChannelByUser(channelId, userId string) (model.Post, error)
- func (s *MemStore) RandomReplyPostForChannel(channelId string) (model.Post, error)
- func (s *MemStore) RandomTeam(st store.SelectionType) (model.Team, error)
- func (s *MemStore) RandomTeamMember(teamId string) (model.TeamMember, error)
- func (s *MemStore) RandomThread() (model.ThreadResponse, error)
- func (s *MemStore) RandomUser() (model.User, error)
- func (s *MemStore) RandomUsers(n int) ([]model.User, error)
- func (s *MemStore) Reactions(postId string) ([]model.Reaction, error)
- func (s *MemStore) RemoveChannelMember(channelId string, userId string) error
- func (s *MemStore) RemoveTeamMember(teamId string, userId string) error
- func (s *MemStore) Roles() ([]model.Role, error)
- func (s *MemStore) ServerVersion() (string, error)
- func (s *MemStore) SetCategories(teamID string, sidebarCategories *model.OrderedSidebarCategories) error
- func (s *MemStore) SetChannel(channel *model.Channel) error
- func (s *MemStore) SetChannelMember(channelId string, channelMember *model.ChannelMember) error
- func (s *MemStore) SetChannelMembers(channelMembers model.ChannelMembers) error
- func (s *MemStore) SetChannelStats(channelId string, stats *model.ChannelStats) error
- func (s *MemStore) SetChannelView(channelId string) error
- func (s *MemStore) SetChannels(channels []*model.Channel) error
- func (s *MemStore) SetClientConfig(config map[string]string)
- func (s *MemStore) SetConfig(config *model.Config)
- func (s *MemStore) SetCurrentChannel(channel *model.Channel) error
- func (s *MemStore) SetCurrentTeam(team *model.Team) error
- func (s *MemStore) SetDraft(teamId, id string, draft *model.Draft) error
- func (s *MemStore) SetDrafts(teamId string, drafts []*model.Draft) error
- func (s *MemStore) SetEmojis(emoji []*model.Emoji) error
- func (s *MemStore) SetLicense(license map[string]string) error
- func (s *MemStore) SetPost(post *model.Post) error
- func (s *MemStore) SetPosts(posts []*model.Post) error
- func (s *MemStore) SetPreferences(preferences model.Preferences) error
- func (s *MemStore) SetProfileImage(userId string, lastPictureUpdate int) error
- func (s *MemStore) SetReaction(reaction *model.Reaction) error
- func (s *MemStore) SetRoles(roles []*model.Role) error
- func (s *MemStore) SetServerVersion(version string) error
- func (s *MemStore) SetStatus(userId string, status *model.Status) error
- func (s *MemStore) SetTeam(team *model.Team) error
- func (s *MemStore) SetTeamMember(teamId string, teamMember *model.TeamMember) error
- func (s *MemStore) SetTeamMembers(teamId string, teamMembers []*model.TeamMember) error
- func (s *MemStore) SetTeams(teams []*model.Team) error
- func (s *MemStore) SetThread(thread *model.ThreadResponse) error
- func (s *MemStore) SetThreads(trs []*model.ThreadResponse) error
- func (s *MemStore) SetUser(user *model.User) error
- func (s *MemStore) SetUsers(users []*model.User) error
- func (s *MemStore) Status(userId string) (model.Status, error)
- func (s *MemStore) Team(teamId string) (*model.Team, error)
- func (s *MemStore) TeamMember(teamId, userId string) (model.TeamMember, error)
- func (s *MemStore) Teams() ([]model.Team, error)
- func (s *MemStore) Thread(threadId string) (*model.ThreadResponse, error)
- func (s *MemStore) ThreadsSorted(unreadOnly, asc bool) ([]*model.ThreadResponse, error)
- func (s *MemStore) User() (*model.User, error)
- func (s *MemStore) UserForPost(postId string) (string, error)
- func (s *MemStore) Username() string
- func (s *MemStore) Users() ([]model.User, error)
- func (s *MemStore) UsersIdsForPostsIds(postIds []string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyMap = errors.New("memstore: cannot select from an empty map") ErrEmptySlice = errors.New("memstore: cannot select from an empty slice") ErrLenMismatch = errors.New("memstore: cannot select from a map, not enough elements") ErrTeamNotFound = errors.New("memstore: team not found") ErrUserNotSet = errors.New("memstore: user is not set") ErrTeamStoreEmpty = errors.New("memstore: team store is empty") ErrChannelStoreEmpty = errors.New("memstore: channel store is empty") ErrChannelNotFound = errors.New("memstore: channel not found") ErrPostNotFound = errors.New("memstore: post not found") ErrInvalidData = errors.New("memstore: invalid data found") ErrThreadNotFound = errors.New("memstore: thread not found") ErrMaxAttempts = errors.New("memstore: maximum number of attempts tried") ErrDraftNotFound = errors.New("memstore: draft not found") )
Functions ¶
func SetRandomSeed ¶
func SetRandomSeed() int64
SetRandomSeed sets the global random seed and returns it's value.
Types ¶
type CQueue ¶
type CQueue[T any] struct { // contains filtered or unexported fields }
CQueue is a basic implementation of a circular queue of fixed size.
type Config ¶
type Config struct { MaxStoredPosts int // The maximum number of posts to be stored. MaxStoredUsers int // The maximum number of users to be stored. MaxStoredChannelMembers int // The maximum number of channel members to be stored. MaxStoredStatuses int // The maximum number of statuses to be stored. MaxStoredThreads int // The maximum number of statuses to be stored. MaxStoredReactions int // The maximum number of reactions to be stored. }
Config holds information used to create a new MemStore.
func (*Config) IsValid ¶
IsValid checks whether a Config is valid or not. Returns an error if the validation fails.
func (*Config) SetDefaults ¶
func (c *Config) SetDefaults()
SetDefaults sets default values to the config.
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
MemStore is a simple implementation of MutableUserStore which holds all data in memory.
func New ¶
New returns a new instance of MemStore with the given config. If config is nil, defaults will be used.
func (*MemStore) ChannelMember ¶
func (s *MemStore) ChannelMember(channelId, userId string) (model.ChannelMember, error)
ChannelMember returns the channel member for the given channelId and userId.
func (*MemStore) ChannelMembers ¶
func (s *MemStore) ChannelMembers(channelId string) (model.ChannelMembers, error)
ChannelMembers returns a list of members for the specified channel.
func (*MemStore) ChannelPosts ¶
ChannelPosts returns all posts for the specified channel.
func (*MemStore) ChannelPostsSorted ¶
ChannelPostsSorted returns all posts for specified channel, sorted by CreateAt.
func (*MemStore) ChannelStats ¶ added in v1.3.0
func (s *MemStore) ChannelStats(channelId string) (*model.ChannelStats, error)
ChannelStats returns statistics for the given channelId.
func (*MemStore) ChannelView ¶
ChannelView returns the timestamp of the last view for the given channelId.
func (*MemStore) Channels ¶
Channels returns all the channels for a team. This means no DM/GM channels are returned.
func (*MemStore) Clear ¶
func (s *MemStore) Clear()
Clear resets the store and removes all entries with the exception of the user object and state information (current team/channel) which are preserved.
func (*MemStore) ClientConfig ¶ added in v1.3.0
ClientConfig returns the limited server configuration settings for user.
func (*MemStore) CurrentChannel ¶
GetCurrentChannel returns the channel the user is currently viewing.
func (*MemStore) CurrentTeam ¶
GetCurrentTeam returns the currently selected team for the user.
func (*MemStore) DeletePost ¶
DeletePost deletes the specified post.
func (*MemStore) DeleteReaction ¶
DeleteReaction deletes the given reaction. It returns whether or not the reaction was deleted.
func (*MemStore) FeatureFlags ¶ added in v1.10.0
FeatureFlags returns a map of the features flags stored in the client config.
func (*MemStore) FileInfoForPost ¶
FileInfoForPost returns the FileInfo for the specified post, if any.
func (*MemStore) IsTeamMember ¶ added in v1.10.0
IsTeamMember returns whether the user is part of the team.
func (*MemStore) MarkAllThreadsInTeamAsRead ¶ added in v1.5.0
MarkAllThreadsInTeamAsRead marks all threads in the given team as read
func (*MemStore) PostsIdsSince ¶
PostsIdsSince returns a list of post ids for posts created after a specified timestamp in milliseconds.
func (*MemStore) PostsWithAckRequests ¶ added in v1.10.0
PostsWithAckRequests returns IDs of the posts that asked for acknowledgment.
func (*MemStore) Preferences ¶
func (s *MemStore) Preferences() (model.Preferences, error)
Preferences returns the preferences for the stored user.
func (*MemStore) ProfileImageLastUpdated ¶ added in v1.10.0
ProfileImageLastUpdated returns the etag returned by the server when first fetched, which is the last time the picture was updated, or zero if the image is not stored.
func (*MemStore) RandomCategory ¶ added in v1.5.0
func (s *MemStore) RandomCategory(teamID string) (model.SidebarCategoryWithChannels, error)
func (*MemStore) RandomChannel ¶
RandomChannel returns a random channel for the given teamId for the current user.
func (*MemStore) RandomChannelMember ¶
func (s *MemStore) RandomChannelMember(channelId string) (model.ChannelMember, error)
RandomChannelMember returns a random channel member for a channel.
func (*MemStore) RandomDraftForTeam ¶ added in v1.20.0
RandomDraftForTeam returns a random draft id for the given team
func (*MemStore) RandomEmoji ¶
RandomEmoji returns a random emoji.
func (*MemStore) RandomPost ¶
RandomPost returns a random post.
func (*MemStore) RandomPostForChannel ¶
RandomPostForChannel returns a random post for the given channel.
func (*MemStore) RandomPostForChannelByUser ¶
RandomPostForChannelForUser returns a random post for the given channel made by the given user.
func (*MemStore) RandomReplyPostForChannel ¶ added in v1.5.0
RandomReplyPostForChannel returns a random reply post for the given channel.
func (*MemStore) RandomTeam ¶
RandomTeam returns a random team for the current user.
func (*MemStore) RandomTeamMember ¶
func (s *MemStore) RandomTeamMember(teamId string) (model.TeamMember, error)
RandomTeamMember returns a random team member for a team.
func (*MemStore) RandomThread ¶ added in v1.5.0
func (s *MemStore) RandomThread() (model.ThreadResponse, error)
RandomThread returns a random post.
func (*MemStore) RandomUser ¶
RandomUser returns a random user from the set of users.
func (*MemStore) RandomUsers ¶
RandomUsers returns N random users from the set of users.
func (*MemStore) RemoveChannelMember ¶
RemoveChannelMember removes the channel member for the specified channel and user.
func (*MemStore) RemoveTeamMember ¶
RemoveTeamMember removes the team member for the specified team and user..
func (*MemStore) ServerVersion ¶ added in v1.2.0
ServerVersion returns the server version string.
func (*MemStore) SetCategories ¶ added in v1.5.0
func (s *MemStore) SetCategories(teamID string, sidebarCategories *model.OrderedSidebarCategories) error
func (*MemStore) SetChannel ¶
SetChannel stores the given channel.
func (*MemStore) SetChannelMember ¶
func (s *MemStore) SetChannelMember(channelId string, channelMember *model.ChannelMember) error
SetChannelMember stores the given channel member.
func (*MemStore) SetChannelMembers ¶
func (s *MemStore) SetChannelMembers(channelMembers model.ChannelMembers) error
SetChannelMembers stores the given channel members in the store.
func (*MemStore) SetChannelStats ¶ added in v1.3.0
func (s *MemStore) SetChannelStats(channelId string, stats *model.ChannelStats) error
SetChannelStats stores statistics for the given channelId.
func (*MemStore) SetChannelView ¶
SetChannelView marks the given channel as viewed and updates the store with the current timestamp.
func (*MemStore) SetChannels ¶
SetChannels adds the given channels to the store.
func (*MemStore) SetClientConfig ¶ added in v1.3.0
Set ClientConfig stores the given limited configuration settings.
func (*MemStore) SetCurrentChannel ¶
SetCurrentChannel stores the channel the user is currently viewing.
func (*MemStore) SetCurrentTeam ¶
SetCurrentTeam sets the currently selected team for the user.
func (*MemStore) SetDraft ¶ added in v1.20.0
SetDraft stores the draft for the given teamId, and channelId or rootId.
func (*MemStore) SetLicense ¶
SetLicense stores the given license in the store.
func (*MemStore) SetPreferences ¶
func (s *MemStore) SetPreferences(preferences model.Preferences) error
Preferences stores the preferences for the stored user.
func (*MemStore) SetProfileImage ¶
SetProfileImage sets as stored the profile image for the given user.
func (*MemStore) SetReaction ¶
SetReaction stores the given reaction.
func (*MemStore) SetServerVersion ¶ added in v1.2.0
SetServerVersion stores the given server version.
func (*MemStore) SetTeamMember ¶
func (s *MemStore) SetTeamMember(teamId string, teamMember *model.TeamMember) error
SetTeamMember stores the given team member.
func (*MemStore) SetTeamMembers ¶
func (s *MemStore) SetTeamMembers(teamId string, teamMembers []*model.TeamMember) error
SetTeamMembers stores the given team members.
func (*MemStore) SetThread ¶ added in v1.5.0
func (s *MemStore) SetThread(thread *model.ThreadResponse) error
SetThread stores the given thread reponse.
func (*MemStore) SetThreads ¶ added in v1.5.0
func (s *MemStore) SetThreads(trs []*model.ThreadResponse) error
SetThreads stores the given thread response as a thread.
func (*MemStore) TeamMember ¶
func (s *MemStore) TeamMember(teamId, userId string) (model.TeamMember, error)
TeamMember returns the team member for the given teamId and userId.
func (*MemStore) Thread ¶ added in v1.5.0
func (s *MemStore) Thread(threadId string) (*model.ThreadResponse, error)
Thread returns the thread for the given the threadId.
func (*MemStore) ThreadsSorted ¶ added in v1.5.0
func (s *MemStore) ThreadsSorted(unreadOnly, asc bool) ([]*model.ThreadResponse, error)
ThreadsSorted returns all threads, sorted by LastReplyAt
func (*MemStore) UserForPost ¶
UserForPost returns the userId for the user who created the specified post.