userentity

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The URL of the Mattermost web server.
	ServerURL string
	// The URL of the mattermost WebSocket server.
	WebSocketURL string
	// The username to be used by the entity.
	Username string
	// The email to be used by the entity.
	Email string
	// The password to be used by the entity.
	Password string
}

Config holds necessary information required by a UserEntity.

type Setup

type Setup struct {
	// The store to be used to save user's data.
	Store store.MutableUserStore
	// The transport to be used to execute API calls.
	Transport http.RoundTripper
	// An optional object used to collect metrics.
	Metrics *performance.UserEntityMetrics
}

Setup contains data used to create a new instance of UserEntity.

type UserEntity

type UserEntity struct {
	// contains filtered or unexported fields
}

UserEntity is an implementation of the User interface which provides methods to interact with the Mattermost server.

func New

func New(setup Setup, config Config) *UserEntity

New returns a new instance of a UserEntity.

func (*UserEntity) AddChannelMember

func (ue *UserEntity) AddChannelMember(channelId, userId string) error

AddChannelMember adds the specified user to the specified channel.

func (*UserEntity) AddTeamMember

func (ue *UserEntity) AddTeamMember(teamId, userId string) error

AddTeamMember adds the specified user to the specified team.

func (*UserEntity) AddTeamMemberFromInvite

func (ue *UserEntity) AddTeamMemberFromInvite(token, inviteId string) error

AddTeamMemberFromInvite adds a user to a team using the given token and inviteId.

func (*UserEntity) AutocompleteChannelsForTeam

func (ue *UserEntity) AutocompleteChannelsForTeam(teamId, name string) error

AutocompleteChannelsForTeam fetches and stores an ordered list of channels for a given name in a specified team.

func (*UserEntity) AutocompleteChannelsForTeamForSearch added in v1.1.0

func (ue *UserEntity) AutocompleteChannelsForTeamForSearch(teamId, name string) (map[string]bool, error)

AutocompleteChannelsForTeamForSearch fetches and stores an ordered list of the user's channels autocomplete suggestions. It returns a map of found channel names.

func (*UserEntity) AutocompleteUsersInChannel added in v1.1.0

func (ue *UserEntity) AutocompleteUsersInChannel(teamId, channelId, username string, limit int) (map[string]bool, error)

AutocompleteUsersInChannel performs autocomplete of a username in a specified team and channel. It returns the users in the system based on the given username.

func (*UserEntity) AutocompleteUsersInTeam added in v1.1.0

func (ue *UserEntity) AutocompleteUsersInTeam(teamId, username string, limit int) (map[string]bool, error)

AutoCompleteUsersInTeam performs autocomplete of a username in a specified team. It returns the users in the system based on the given username.

func (*UserEntity) ClearUserData

func (ue *UserEntity) ClearUserData()

ClearUserData calls the Clear method on the underlying UserStore.

func (*UserEntity) Connect

func (ue *UserEntity) Connect() (<-chan error, error)

Connect creates a WebSocket connection to the server and starts listening for messages.

func (*UserEntity) CreateChannel

func (ue *UserEntity) CreateChannel(channel *model.Channel) (string, error)

CreateChannel creates and stores a new channel with the given information. It returns the channel's id.

func (*UserEntity) CreateDirectChannel

func (ue *UserEntity) CreateDirectChannel(otherUserId string) (string, error)

CreateGroupChannel creates and stores a new direct channel with the given user. It returns the channel's id.

func (*UserEntity) CreateGroupChannel

func (ue *UserEntity) CreateGroupChannel(memberIds []string) (string, error)

CreateGroupChannel creates and stores a new group channel with the given members. It returns the channel's id.

func (*UserEntity) CreatePost

func (ue *UserEntity) CreatePost(post *model.Post) (string, error)

CreatePost creates and stores a new post made by the user.

func (*UserEntity) CreateTeam

func (ue *UserEntity) CreateTeam(team *model.Team) (string, error)

CreateTeam creates a new team with the given information.

func (*UserEntity) CreateUser

func (ue *UserEntity) CreateUser(user *model.User) (string, error)

CreateUser creates a new user with the given information.

func (*UserEntity) DeleteReaction

func (ue *UserEntity) DeleteReaction(reaction *model.Reaction) error

DeleteReaction deletes the given reaction.

func (*UserEntity) Disconnect

func (ue *UserEntity) Disconnect() error

Disconnect closes the WebSocket connection.

func (*UserEntity) Events

func (ue *UserEntity) Events() <-chan *model.WebSocketEvent

Events returns the WebSocket event chan for the controller to listen and react to events.

func (*UserEntity) FetchStaticAssets

func (ue *UserEntity) FetchStaticAssets() error

FetchStaticAssets parses index.html and fetches static assets mentioned in link/script tags.

func (*UserEntity) GetAllTeams

func (ue *UserEntity) GetAllTeams(page, perPage int) ([]string, error)

GetAllTeams returns all teams based on permissions. It returns a list of team ids.

func (*UserEntity) GetAnalytics

func (ue *UserEntity) GetAnalytics() error

GetAnalytics fetches the system analytics.

func (*UserEntity) GetChannel

func (ue *UserEntity) GetChannel(channelId string) error

GetChannel fetches and stores the specified channel.

func (*UserEntity) GetChannelMember

func (ue *UserEntity) GetChannelMember(channelId, userId string) error

GetChannelMember fetches and stores the channel member for the specified user in the specified channel.

func (*UserEntity) GetChannelMembers

func (ue *UserEntity) GetChannelMembers(channelId string, page, perPage int) error

GetChannelMembers fetches and stores channel members for the specified channel.

func (*UserEntity) GetChannelMembersForUser

func (ue *UserEntity) GetChannelMembersForUser(userId, teamId string) error

GetChannelMembersForUser gets the channel members for the specified user in the specified team.

func (*UserEntity) GetChannelStats

func (ue *UserEntity) GetChannelStats(channelId string) error

GetChannelStats fetches statistics for the specified channel.

func (*UserEntity) GetChannelUnread

func (ue *UserEntity) GetChannelUnread(channelId string) (*model.ChannelUnread, error)

GetChannelUnread fetches and returns information about the specified channel's unread messages.

func (*UserEntity) GetChannelsForTeam

func (ue *UserEntity) GetChannelsForTeam(teamId string, includeDeleted bool) error

GetChannelsForTeam fetches and stores channels in the specified team.

func (*UserEntity) GetChannelsForTeamForUser

func (ue *UserEntity) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, error)

GetChannelsForTeamForUser fetches and stores chanels for the specified user in the specified team. It returns a list of those channels.

func (*UserEntity) GetClientConfig added in v1.3.0

func (ue *UserEntity) GetClientConfig() error

GetClientConfig fetches and stores the limited server's configuration for logged in user.

func (*UserEntity) GetClientLicense

func (ue *UserEntity) GetClientLicense() error

GetClientLicense fetched and stores the client license. It returns the client license in the old format.

func (*UserEntity) GetClusterStatus

func (ue *UserEntity) GetClusterStatus() error

GetClusterStatus fetches the cluster status.

func (*UserEntity) GetConfig

func (ue *UserEntity) GetConfig() error

GetConfig fetches and stores the server's configuration.

func (*UserEntity) GetEmojiImage

func (ue *UserEntity) GetEmojiImage(emojiId string) error

GetEmojiImage fetches the image for a given emoji.

func (*UserEntity) GetEmojiList

func (ue *UserEntity) GetEmojiList(page, perPage int) error

GetEmojiList fetches and stores a list of custom emoji.

func (*UserEntity) GetFileInfosForPost

func (ue *UserEntity) GetFileInfosForPost(postId string) ([]*model.FileInfo, error)

GetFileInfosForPost returns file information for the specified post.

func (*UserEntity) GetFilePreview

func (ue *UserEntity) GetFilePreview(fileId string) error

GetFilePreview fetches the preview for the specified file.

func (*UserEntity) GetFileThumbnail

func (ue *UserEntity) GetFileThumbnail(fileId string) error

GetFileThumbnail fetches the thumbnail for the specified file.

func (*UserEntity) GetLogs

func (ue *UserEntity) GetLogs(page, perPage int) error

GetLogs fetches the server logs.

func (*UserEntity) GetMe

func (ue *UserEntity) GetMe() (string, error)

GetMe loads user's information into the store and returns its id.

func (*UserEntity) GetPinnedPosts

func (ue *UserEntity) GetPinnedPosts(channelId string) (*model.PostList, error)

GetPinnedPosts fetches and returns pinned posts in a given channelId.

func (*UserEntity) GetPluginStatuses

func (ue *UserEntity) GetPluginStatuses() error

GetPluginStatuses fetches the plugin statuses.

func (*UserEntity) GetPostsAfter

func (ue *UserEntity) GetPostsAfter(channelId, postId string, page, perPage int, collapsedThreads bool) error

GetPostsAfter fetches and stores posts in a given channelId that were made after a given postId.

func (*UserEntity) GetPostsAroundLastUnread

func (ue *UserEntity) GetPostsAroundLastUnread(channelId string, limitBefore, limitAfter int, collapsedThreads bool) ([]string, error)

GetPostsAroundLastUnread fetches and stores the posts made around last unread in a given channelId. It returns a list of posts ids.

func (*UserEntity) GetPostsBefore

func (ue *UserEntity) GetPostsBefore(channelId, postId string, page, perPage int, collapsedThreads bool) ([]string, error)

GetPostsBefore fetches and stores posts in a given channelId that were made before a given postId. It returns a list of posts ids.

func (*UserEntity) GetPostsForChannel

func (ue *UserEntity) GetPostsForChannel(channelId string, page, perPage int, collapsedThreads bool) error

GetPostsForChannel fetches and stores posts in a given channelId.

func (*UserEntity) GetPostsSince

func (ue *UserEntity) GetPostsSince(channelId string, time int64, collapsedThreads bool) ([]string, error)

GetPostsSince fetches and stores posts in a given channelId that were made since the given time. It returns a list of posts ids.

func (*UserEntity) GetPreferences

func (ue *UserEntity) GetPreferences() error

GetPreferences fetches and store the user's preferences.

func (*UserEntity) GetProfileImage

func (ue *UserEntity) GetProfileImage() error

GetProfileImage fetches the profile image for the user.

func (*UserEntity) GetProfileImageForUser

func (ue *UserEntity) GetProfileImageForUser(userId string) error

GetProfileImageForUser fetches and stores the profile imagine for the specified user.

func (*UserEntity) GetPublicChannelsForTeam

func (ue *UserEntity) GetPublicChannelsForTeam(teamId string, page, perPage int) error

GetPublicChannelsForTeam fetches and stores public channels in the specified team.

func (*UserEntity) GetReactions

func (ue *UserEntity) GetReactions(postId string) error

GetReactions fetches and stores reactions to the specified post.

func (*UserEntity) GetRolesByNames

func (ue *UserEntity) GetRolesByNames(roleNames []string) ([]string, error)

GetRolesByName fetches and stores roles for the given names. It returns a list of role ids.

func (*UserEntity) GetTeam

func (ue *UserEntity) GetTeam(teamId string) error

GetTeam fetches and returns the specified team.

func (*UserEntity) GetTeamMembers

func (ue *UserEntity) GetTeamMembers(teamId string, page, perPage int) error

GetTeamMembers fetches and stores team members for the specified team.

func (*UserEntity) GetTeamMembersForUser

func (ue *UserEntity) GetTeamMembersForUser(userId string) error

GetTeamMembersForUser fetches and stores team members for the specified user.

func (*UserEntity) GetTeamStats

func (ue *UserEntity) GetTeamStats(teamId string) error

GetTeamStats fetches statistics for the specified team.

func (*UserEntity) GetTeamsForUser

func (ue *UserEntity) GetTeamsForUser(userId string) ([]string, error)

GetTeamsForUser fetches and stores the teams for the specified user. It returns a list of team ids.

func (*UserEntity) GetTeamsUnread

func (ue *UserEntity) GetTeamsUnread(teamIdToExclude string) ([]*model.TeamUnread, error)

GetTeamsUnread fetches and returns information about unreads messages for the user in the teams it belongs to.

func (*UserEntity) GetUserStatus

func (ue *UserEntity) GetUserStatus() error

GetUserStatus fetches and stores the status for the user.

func (*UserEntity) GetUsers

func (ue *UserEntity) GetUsers(page, perPage int) ([]string, error)

GetUsers fetches and stores all users. It returns a list of those users' ids.

func (*UserEntity) GetUsersByIds

func (ue *UserEntity) GetUsersByIds(userIds []string) ([]string, error)

GetUsersByIds fetches and stores the specified users. It returns a list of those users' ids.

func (*UserEntity) GetUsersByUsernames

func (ue *UserEntity) GetUsersByUsernames(usernames []string) ([]string, error)

GetUsersByUsername fetches and stores users for the given usernames. It returns a list of those users' ids.

func (*UserEntity) GetUsersInChannel

func (ue *UserEntity) GetUsersInChannel(channelId string, page, perPage int) error

GetUsersInChannel fetches and stores users in the specified channel.

func (*UserEntity) GetUsersNotInChannel added in v1.3.0

func (ue *UserEntity) GetUsersNotInChannel(teamId, channelId string, page, perPage int) ([]string, error)

GetUsersNotInChannel returns a list of user ids not in a given channel.

func (*UserEntity) GetUsersStatusesByIds

func (ue *UserEntity) GetUsersStatusesByIds(userIds []string) error

GetUsersStatusesByIds fetches and stores statuses for the specified users.

func (*UserEntity) GetWebappPlugins

func (ue *UserEntity) GetWebappPlugins() error

GetWebappPlugins fetches webapp plugins.

func (*UserEntity) IsSysAdmin

func (ue *UserEntity) IsSysAdmin() (bool, error)

IsSysAdmin returns whether the user is a system admin or not.

func (*UserEntity) IsTeamAdmin

func (ue *UserEntity) IsTeamAdmin() (bool, error)

IsTeamAdmin returns whether the user is a team admin or not.

func (*UserEntity) Login

func (ue *UserEntity) Login() error

Login logs the user in. It authenticates a user and starts a new session.

func (*UserEntity) Logout

func (ue *UserEntity) Logout() (bool, error)

Logout logs the user out. It terminates the current user's session.

func (*UserEntity) MessageExport added in v1.3.0

func (ue *UserEntity) MessageExport() error

MessageExport creates a job for a compliance message export

func (*UserEntity) PatchPost

func (ue *UserEntity) PatchPost(postId string, patch *model.PostPatch) (string, error)

PatchPost modifies a post for the given postId and stores the updated result.

func (*UserEntity) PatchUser

func (ue *UserEntity) PatchUser(userId string, patch *model.UserPatch) error

PatchUser patches a given user with the given information.

func (*UserEntity) RemoveTeamMember

func (ue *UserEntity) RemoveTeamMember(teamId, userId string) error

RemoveTeamMember removes the specified user from the specified team.

func (*UserEntity) RemoveUserFromChannel

func (ue *UserEntity) RemoveUserFromChannel(channelId, userId string) (bool, error)

RemoveUserFromChannel removes the specified user from the specified channel. It returns whether the user was successfully removed or not.

func (*UserEntity) SaveReaction

func (ue *UserEntity) SaveReaction(reaction *model.Reaction) error

SaveReaction stores the given reaction.

func (*UserEntity) SearchChannels

func (ue *UserEntity) SearchChannels(teamId string, search *model.ChannelSearch) ([]*model.Channel, error)

SearchChannels performs a search for channels in the specified team. It returns channels that matches the search.

func (*UserEntity) SearchGroupChannels added in v1.1.0

func (ue *UserEntity) SearchGroupChannels(search *model.ChannelSearch) ([]*model.Channel, error)

SearchGroupChannels performs a search for group channels. It returns channels whose members' usernames match the search term.

func (*UserEntity) SearchPosts

func (ue *UserEntity) SearchPosts(teamId, terms string, isOrSearch bool) (*model.PostList, error)

SearchPosts performs a search for posts in the given teamId with the given terms.

func (*UserEntity) SearchUsers

func (ue *UserEntity) SearchUsers(search *model.UserSearch) ([]*model.User, error)

SearchUsers performs a user search. It returns a list of users that matched.

func (*UserEntity) SendTypingEvent

func (ue *UserEntity) SendTypingEvent(channelId, parentId string) error

SendTypingEvent will push a user_typing event out to all connected users who are in the specified channel.

func (*UserEntity) SetCurrentChannel

func (ue *UserEntity) SetCurrentChannel(channel *model.Channel) error

SetCurrentChannel sets the given channel as the current channel for the user.

func (*UserEntity) SetCurrentTeam

func (ue *UserEntity) SetCurrentTeam(team *model.Team) error

SetCurrentTeam sets the given team as the current team for the user.

func (*UserEntity) SetProfileImage

func (ue *UserEntity) SetProfileImage(data []byte) error

SetProfileImage sets the profile image for the user.

func (*UserEntity) SignUp

func (ue *UserEntity) SignUp(email, username, password string) error

SignUp signs up the user with the given credentials.

func (*UserEntity) Store

func (ue *UserEntity) Store() store.UserStore

Store returns the underlying store of the user.

func (*UserEntity) UpdateConfig

func (ue *UserEntity) UpdateConfig(cfg *model.Config) error

UpdateConfig updates the config with cfg.

func (*UserEntity) UpdatePreferences

func (ue *UserEntity) UpdatePreferences(pref *model.Preferences) error

UpdatePreferences updates the user's preferences.

func (*UserEntity) UpdateTeam

func (ue *UserEntity) UpdateTeam(team *model.Team) error

UpdateTeam updates and stores the given team.

func (*UserEntity) UpdateUser

func (ue *UserEntity) UpdateUser(user *model.User) error

UpdateUser updates the given user with the given information.

func (*UserEntity) UpdateUserRoles

func (ue *UserEntity) UpdateUserRoles(userId, roles string) error

UpdateUserRoles updates the given userId with the given role ids.

func (*UserEntity) UploadFile

func (ue *UserEntity) UploadFile(data []byte, channelId, filename string) (*model.FileUploadResponse, error)

UploadFile uploads the given data in the specified channel.

func (*UserEntity) ViewChannel

func (ue *UserEntity) ViewChannel(view *model.ChannelView) (*model.ChannelViewResponse, error)

ViewChannels performs a channel view for the user.

Jump to

Keyboard shortcuts

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