store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MutableUserStore

type MutableUserStore interface {
	UserStore

	// Clear resets the store and removes all entries with the exception of the
	// user object and state information (current team/channel) which are preserved.
	Clear()

	// server
	// SetConfig stores the given configuration settings.
	SetConfig(*model.Config)

	// users
	// SetUser stores the given user.
	SetUser(user *model.User) error
	// User returns the stored user.
	User() (*model.User, error)
	// SetUsers stores the given users.
	SetUsers(users []*model.User) error

	// statuses
	// SetStatus stores the status for the given userId.
	SetStatus(userId string, status *model.Status) error

	// posts
	// SetPost stores the given post.
	SetPost(post *model.Post) error
	// DeletePost deletes the specified post.
	DeletePost(postId string) error
	// SetPosts stores the given posts.
	SetPosts(posts []*model.Post) error

	// reactions
	// SetReactions stores the given reactions for the specified post.
	SetReactions(postId string, reactions []*model.Reaction) error
	// SetReaction stores the given reaction.
	SetReaction(reaction *model.Reaction) error
	// DeleteReaction deletes the given reaction.
	// It returns whether or not the reaction was deleted.
	DeleteReaction(reaction *model.Reaction) (bool, error)

	// preferences
	// Preferences stores the preferences for the stored user.
	SetPreferences(preferences *model.Preferences) error

	// channels
	SetChannel(channel *model.Channel) error
	// SetChannels adds the given channels to the store.
	SetChannels(channels []*model.Channel) error
	// SetCurrentChannel stores the channel the user is currently viewing.
	SetCurrentChannel(channel *model.Channel) error
	// SetChannelView marks the given channel as viewed and updates the store with the
	// current timestamp.
	SetChannelView(channelId string) error
	// SetChannelMembers stores the given channel members in the store.
	SetChannelMembers(channelMembers *model.ChannelMembers) error
	// ChannelMembers returns a list of members for the specified channel.
	ChannelMembers(channelId string) (*model.ChannelMembers, error)
	// SetChannelMember stores the given channel member.
	SetChannelMember(channelId string, channelMember *model.ChannelMember) error
	// RemoveChannelMember removes the channel member for the specified channel and user.
	RemoveChannelMember(channelId string, userId string) error

	// teams
	SetTeam(team *model.Team) error
	// Team returns the team for the given teamId.
	Team(teamId string) (*model.Team, error)
	// SetTeams stores the given teams.
	SetTeams(teams []*model.Team) error
	// SetCurrentTeam sets the currently selected team for the user.
	SetCurrentTeam(team *model.Team) error
	// SetTeamMember stores the given team member.
	SetTeamMember(teamId string, teamMember *model.TeamMember) error
	// RemoveTeamMember removes the team member for the specified team and user..
	RemoveTeamMember(teamId, memberId string) error
	// SetTeamMembers stores the given team members.
	SetTeamMembers(teamId string, teamMember []*model.TeamMember) error

	// roles
	// SetRoles stores the given roles.
	SetRoles(roles []*model.Role) error

	// emoji
	// SetEmojis stores the given emojis.
	SetEmojis(emoji []*model.Emoji) error

	// license
	// SetLicense stores the given license in the store.
	SetLicense(license map[string]string) error

	// profile
	// SetProfileImage sets as stored the profile image for the given user.
	SetProfileImage(userId string) error
}

MutableUserStore is a super-set of UserStore which, apart from providing read access, also allows to edit the data of a user.

type SelectionType

type SelectionType uint8

SelectionType is the selection parameter for a store entity.

const (
	SelectMemberOf    SelectionType = 1 << iota // Select all cases where the user is a member.
	SelectNotMemberOf                           // Select cases where the user is not a member.
	SelectNotCurrent                            // When set the selection won't return current team/channel.
	SelectNotPublic                             // Don't include public channels in selection.
	SelectNotPrivate                            // Don't include private channels in selection.
	SelectNotDirect                             // Don't include direct channels in selection.
	SelectNotGroup                              // Don't include group channels in selection.

	SelectAny = SelectMemberOf | SelectNotMemberOf
)

Defines the membership rules for a store entity.

type UserStore

type UserStore interface {
	// Id returns the id for the stored user.
	Id() string
	// Username returns the username for the stored user.
	Username() string
	// Email returns the email for the stored user.
	Email() string
	// Password returns the password for the stored user.
	Password() string

	// Config returns the server configuration settings.
	Config() model.Config
	// Channel returns the channel for the given channelId.
	Channel(channelId string) (*model.Channel, error)
	// Channels returns the channels for a team.
	Channels(teamId string) ([]model.Channel, error)
	// CurrentChannel gets the channel the user is currently viewing.
	CurrentChannel() (*model.Channel, error)
	// ChannelMember returns the ChannelMember for the given channelId and userId.
	ChannelMember(channelId, userId string) (model.ChannelMember, error)
	// ChannelPosts returns all posts for the specified channel.
	ChannelPosts(channelId string) ([]*model.Post, error)
	// ChannelPostsSorted returns all posts for specified channel, sorted by CreateAt.
	ChannelPostsSorted(channelId string, asc bool) ([]*model.Post, error)
	// ChannelView returns the timestamp of the last view for the given channelId.
	ChannelView(channelId string) (int64, error)

	// GetUser returns the user for the given userId.
	GetUser(userId string) (model.User, error)

	// Status returns the status for the given userId.
	Status(userId string) (model.Status, error)

	// teams
	// Teams returns the teams a user belong to.
	Teams() ([]model.Team, error)
	// CurrentTeam gets the currently selected team for the user.
	CurrentTeam() (*model.Team, error)
	// TeamMember returns the TeamMember for the given teamId and userId.
	TeamMember(teamdId, userId string) (model.TeamMember, error)

	// Preferences returns the preferences for the stored user.
	Preferences() (model.Preferences, error)
	// Roles returns the roles of the user.
	Roles() ([]model.Role, error)

	// Reactions returns the reactions for the specified post.
	Reactions(postId string) ([]model.Reaction, error)

	// random utils
	// RandomChannel returns a random channel for the given teamId
	// for the current user.
	RandomChannel(teamId string, st SelectionType) (model.Channel, error)
	// RandomTeam returns a random team for the current user.
	RandomTeam(st SelectionType) (model.Team, error)
	// RandomUser returns a random user from the set of users.
	RandomUser() (model.User, error)
	// RandomUsers returns N random users from the set of users.
	RandomUsers(n int) ([]model.User, error)
	// RandomPost returns a random post.
	RandomPost() (model.Post, error)
	// RandomPostForChannel returns a random post for the given channel.
	RandomPostForChannel(channelId string) (model.Post, error)
	// RandomPostForChanneByUser returns a random post for the given channel made
	// by the given user.
	RandomPostForChannelByUser(channelId, userId string) (model.Post, error)
	// RandomEmoji returns a random emoji.
	RandomEmoji() (model.Emoji, error)
	// RandomChannelMember returns a random channel member for a channel.
	RandomChannelMember(channelId string) (model.ChannelMember, error)
	// RandomTeamMember returns a random team member for a team.
	RandomTeamMember(teamId string) (model.TeamMember, error)

	// profile
	// ProfileImage returns whether the profile image for the given user has been
	// stored.
	ProfileImage(userId string) (bool, error)

	// posts
	// Post returns the post for the given postId.
	Post(postId string) (*model.Post, error)
	// UserForPost returns the userId for the user who created the specified post.
	UserForPost(postId string) (string, error)
	// FileInfoForPost returns the FileInfo for the specified post, if any.
	FileInfoForPost(postId string) ([]*model.FileInfo, error)
	// PostsIdsSince returns a list of post ids for posts created
	// after a specified timestamp in milliseconds.
	PostsIdsSince(ts int64) ([]string, error)
}

UserStore is a read-only interface which provides access to various data belonging to a user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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