@@ -203,7 +203,7 @@ func (a *App) TestSiteURL(siteURL string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) TestEmail(userId string, cfg *model.Config) *model.AppError {
|
||||
func (a *App) TestEmail(userID string, cfg *model.Config) *model.AppError {
|
||||
if *cfg.EmailSettings.SMTPServer == "" {
|
||||
return model.NewAppError("testEmail", "api.admin.test_email.missing_server", nil, utils.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}), http.StatusBadRequest)
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func (a *App) TestEmail(userId string, cfg *model.Config) *model.AppError {
|
||||
return model.NewAppError("testEmail", "api.admin.test_email.reenter_password", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
user, err := a.GetUser(userId)
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
MonthMilliseconds = 31 * DayMilliseconds
|
||||
)
|
||||
|
||||
func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppError) {
|
||||
func (a *App) GetAnalytics(name string, teamID string) (model.AnalyticsRows, *model.AppError) {
|
||||
skipIntensiveQueries := false
|
||||
var systemUserCount int64
|
||||
systemUserCount, err := a.Srv().Store.User().Count(model.UserCountOptions{})
|
||||
@@ -46,19 +46,19 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
openChan := make(chan store.StoreResult, 1)
|
||||
privateChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
count, err2 := a.Srv().Store.Channel().AnalyticsTypeCount(teamID, model.CHANNEL_OPEN)
|
||||
openChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(openChan)
|
||||
}()
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
count, err2 := a.Srv().Store.Channel().AnalyticsTypeCount(teamID, model.CHANNEL_PRIVATE)
|
||||
privateChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(privateChan)
|
||||
}()
|
||||
|
||||
var userChan chan store.StoreResult
|
||||
var userInactiveChan chan store.StoreResult
|
||||
if teamId == "" {
|
||||
if teamID == "" {
|
||||
userInactiveChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.User().AnalyticsGetInactiveUsersCount()
|
||||
@@ -68,7 +68,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
} else {
|
||||
userChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.User().Count(model.UserCountOptions{TeamId: teamId})
|
||||
count, err2 := a.Srv().Store.User().Count(model.UserCountOptions{TeamId: teamID})
|
||||
userChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(userChan)
|
||||
}()
|
||||
@@ -78,7 +78,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
if !skipIntensiveQueries {
|
||||
postChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamId, false, false)
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamID, false, false)
|
||||
postChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(postChan)
|
||||
}()
|
||||
@@ -199,7 +199,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
return rows, nil
|
||||
}
|
||||
analyticsRows, nErr := a.Srv().Store.Post().AnalyticsPostCountsByDay(&model.AnalyticsPostCountsOptions{
|
||||
TeamId: teamId,
|
||||
TeamId: teamID,
|
||||
BotsOnly: true,
|
||||
YesterdayOnly: false,
|
||||
})
|
||||
@@ -214,7 +214,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
return rows, nil
|
||||
}
|
||||
analyticsRows, nErr := a.Srv().Store.Post().AnalyticsPostCountsByDay(&model.AnalyticsPostCountsOptions{
|
||||
TeamId: teamId,
|
||||
TeamId: teamID,
|
||||
BotsOnly: false,
|
||||
YesterdayOnly: false,
|
||||
})
|
||||
@@ -229,7 +229,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
analyticsRows, nErr := a.Srv().Store.Post().AnalyticsUserCountsWithPostsByDay(teamId)
|
||||
analyticsRows, nErr := a.Srv().Store.Post().AnalyticsUserCountsWithPostsByDay(teamID)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.post.analytics_user_counts_posts_by_day.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -246,21 +246,21 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
|
||||
iHookChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
c, err2 := a.Srv().Store.Webhook().AnalyticsIncomingCount(teamId)
|
||||
c, err2 := a.Srv().Store.Webhook().AnalyticsIncomingCount(teamID)
|
||||
iHookChan <- store.StoreResult{Data: c, NErr: err2}
|
||||
close(iHookChan)
|
||||
}()
|
||||
|
||||
oHookChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
c, err2 := a.Srv().Store.Webhook().AnalyticsOutgoingCount(teamId)
|
||||
c, err2 := a.Srv().Store.Webhook().AnalyticsOutgoingCount(teamID)
|
||||
oHookChan <- store.StoreResult{Data: c, NErr: err2}
|
||||
close(oHookChan)
|
||||
}()
|
||||
|
||||
commandChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
c, nErr := a.Srv().Store.Command().AnalyticsCommandCount(teamId)
|
||||
c, nErr := a.Srv().Store.Command().AnalyticsCommandCount(teamID)
|
||||
commandChan <- store.StoreResult{Data: c, NErr: nErr}
|
||||
close(commandChan)
|
||||
}()
|
||||
@@ -278,14 +278,14 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
if !skipIntensiveQueries {
|
||||
fileChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamId, true, false)
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamID, true, false)
|
||||
fileChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(fileChan)
|
||||
}()
|
||||
|
||||
hashtagChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamId, false, true)
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamID, false, true)
|
||||
hashtagChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(hashtagChan)
|
||||
}()
|
||||
@@ -341,8 +341,8 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *App) GetRecentlyActiveUsersForTeam(teamId string) (map[string]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetRecentlyActiveUsersForTeam(teamId, 0, 100, nil)
|
||||
func (a *App) GetRecentlyActiveUsersForTeam(teamID string) (map[string]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetRecentlyActiveUsersForTeam(teamID, 0, 100, nil)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetRecentlyActiveUsersForTeam", "app.user.get_recently_active_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -356,8 +356,8 @@ func (a *App) GetRecentlyActiveUsersForTeam(teamId string) (map[string]*model.Us
|
||||
return userMap, nil
|
||||
}
|
||||
|
||||
func (a *App) GetRecentlyActiveUsersForTeamPage(teamId string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetRecentlyActiveUsersForTeam(teamId, page*perPage, perPage, viewRestrictions)
|
||||
func (a *App) GetRecentlyActiveUsersForTeamPage(teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetRecentlyActiveUsersForTeam(teamID, page*perPage, perPage, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetRecentlyActiveUsersForTeamPage", "app.user.get_recently_active_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -365,8 +365,8 @@ func (a *App) GetRecentlyActiveUsersForTeamPage(teamId string, page, perPage int
|
||||
return a.sanitizeProfiles(users, asAdmin), nil
|
||||
}
|
||||
|
||||
func (a *App) GetNewUsersForTeamPage(teamId string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetNewUsersForTeam(teamId, page*perPage, perPage, viewRestrictions)
|
||||
func (a *App) GetNewUsersForTeamPage(teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetNewUsersForTeam(teamID, page*perPage, perPage, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetNewUsersForTeamPage", "app.user.get_new_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
476
app/app_iface.go
476
app/app_iface.go
@@ -37,11 +37,11 @@ import (
|
||||
type AppIface interface {
|
||||
// @openTracingParams args
|
||||
ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError)
|
||||
// @openTracingParams teamId
|
||||
// @openTracingParams teamID
|
||||
// previous ListCommands now ListAutocompleteCommands
|
||||
ListAutocompleteCommands(teamId string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError)
|
||||
// @openTracingParams teamId, skipSlackParsing
|
||||
CreateCommandPost(post *model.Post, teamId string, response *model.CommandResponse, skipSlackParsing bool) (*model.Post, *model.AppError)
|
||||
ListAutocompleteCommands(teamID string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError)
|
||||
// @openTracingParams teamID, skipSlackParsing
|
||||
CreateCommandPost(post *model.Post, teamID string, response *model.CommandResponse, skipSlackParsing bool) (*model.Post, *model.AppError)
|
||||
// AddCursorIdsForPostList adds NextPostId and PrevPostId as cursor to the PostList.
|
||||
// The conditional blocks ensure that it sets those cursor IDs immediately as afterPost, beforePost or empty,
|
||||
// and only query to database whenever necessary.
|
||||
@@ -126,10 +126,10 @@ type AppIface interface {
|
||||
FillInPostProps(post *model.Post, channel *model.Channel) *model.AppError
|
||||
// FilterNonGroupChannelMembers returns the subset of the given user IDs of the users who are not members of groups
|
||||
// associated to the channel excluding bots
|
||||
FilterNonGroupChannelMembers(userIds []string, channel *model.Channel) ([]string, error)
|
||||
FilterNonGroupChannelMembers(userIDs []string, channel *model.Channel) ([]string, error)
|
||||
// FilterNonGroupTeamMembers returns the subset of the given user IDs of the users who are not members of groups
|
||||
// associated to the team excluding bots.
|
||||
FilterNonGroupTeamMembers(userIds []string, team *model.Team) ([]string, error)
|
||||
FilterNonGroupTeamMembers(userIDs []string, team *model.Team) ([]string, error)
|
||||
// GetAllLdapGroupsPage retrieves all LDAP groups under the configured base DN using the default or configured group
|
||||
// filter.
|
||||
GetAllLdapGroupsPage(page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError)
|
||||
@@ -155,7 +155,7 @@ type AppIface interface {
|
||||
// GetFilteredUsersStats is used to get a count of users based on the set of filters supported by UserCountOptions.
|
||||
GetFilteredUsersStats(options *model.UserCountOptions) (*model.UsersStats, *model.AppError)
|
||||
// GetGroupsByTeam returns the paged list and the total count of group associated to the given team.
|
||||
GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, int, *model.AppError)
|
||||
GetGroupsByTeam(teamID string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, int, *model.AppError)
|
||||
// GetKnownUsers returns the list of user ids of users with any direct
|
||||
// relationship with a user. That means any user sharing any channel, including
|
||||
// direct and group channels.
|
||||
@@ -178,7 +178,7 @@ type AppIface interface {
|
||||
// lock instead.
|
||||
GetPluginsEnvironment() *plugin.Environment
|
||||
// GetProductNotices is called from the frontend to fetch the product notices that are relevant to the caller
|
||||
GetProductNotices(userId, teamId string, client model.NoticeClientType, clientVersion string, locale string) (model.NoticeMessages, *model.AppError)
|
||||
GetProductNotices(userID, teamID string, client model.NoticeClientType, clientVersion string, locale string) (model.NoticeMessages, *model.AppError)
|
||||
// GetPublicKey will return the actual public key saved in the `name` file.
|
||||
GetPublicKey(name string) ([]byte, *model.AppError)
|
||||
// GetSanitizedConfig gets the configuration for a system admin without any secrets.
|
||||
@@ -193,7 +193,7 @@ type AppIface interface {
|
||||
// GetTeamGroupUsers returns the users who are associated to the team via GroupTeams and GroupMembers.
|
||||
GetTeamGroupUsers(teamID string) ([]*model.User, *model.AppError)
|
||||
// GetTeamSchemeChannelRoles Checks if a team has an override scheme and returns the scheme channel role names or default channel role names.
|
||||
GetTeamSchemeChannelRoles(teamId string) (guestRoleName string, userRoleName string, adminRoleName string, err *model.AppError)
|
||||
GetTeamSchemeChannelRoles(teamID string) (guestRoleName string, userRoleName string, adminRoleName string, err *model.AppError)
|
||||
// GetTotalUsersStats is used for the DM list total
|
||||
GetTotalUsersStats(viewRestrictions *model.ViewUsersRestrictions) (*model.UsersStats, *model.AppError)
|
||||
// HubRegister registers a connection to a hub.
|
||||
@@ -223,10 +223,10 @@ type AppIface interface {
|
||||
MarkChannelAsUnreadFromPost(postID string, userID string) (*model.ChannelUnreadAt, *model.AppError)
|
||||
// MentionsToPublicChannels returns all the mentions to public channels,
|
||||
// linking them to their channels
|
||||
MentionsToPublicChannels(message, teamId string) model.ChannelMentionMap
|
||||
MentionsToPublicChannels(message, teamID string) model.ChannelMentionMap
|
||||
// MentionsToTeamMembers returns all the @ mentions found in message that
|
||||
// belong to users in the specified team, linking them to their users
|
||||
MentionsToTeamMembers(message, teamId string) model.UserMentionMap
|
||||
MentionsToTeamMembers(message, teamID string) model.UserMentionMap
|
||||
// MoveChannel method is prone to data races if someone joins to channel during the move process. However this
|
||||
// function is only exposed to sysadmins and the possibility of this edge case is relatively small.
|
||||
MoveChannel(team *model.Team, channel *model.Channel, user *model.User) *model.AppError
|
||||
@@ -289,7 +289,7 @@ type AppIface interface {
|
||||
// SetStatusLastActivityAt sets the last activity at for a user on the local app server and updates
|
||||
// status to away if needed. Used by the WS to set status to away if an 'online' device disconnects
|
||||
// while an 'away' device is still connected
|
||||
SetStatusLastActivityAt(userId string, activityAt int64)
|
||||
SetStatusLastActivityAt(userID string, activityAt int64)
|
||||
// SyncPlugins synchronizes the plugins installed locally
|
||||
// with the plugin bundles available in the file store.
|
||||
SyncPlugins() *model.AppError
|
||||
@@ -324,10 +324,10 @@ type AppIface interface {
|
||||
// UpdateProductNotices is called periodically from a scheduled worker to fetch new notices and update the cache
|
||||
UpdateProductNotices() *model.AppError
|
||||
// UpdateViewedProductNotices is called from the frontend to mark a set of notices as 'viewed' by user
|
||||
UpdateViewedProductNotices(userId string, noticeIds []string) *model.AppError
|
||||
UpdateViewedProductNotices(userID string, noticeIds []string) *model.AppError
|
||||
// UpdateViewedProductNoticesForNewUser is called when new user is created to mark all current notices for this
|
||||
// user as viewed in order to avoid showing them imminently on first login
|
||||
UpdateViewedProductNoticesForNewUser(userId string)
|
||||
UpdateViewedProductNoticesForNewUser(userID string)
|
||||
// UpdateWebConnUserActivity sets the LastUserActivityAt of the hub for the given session.
|
||||
UpdateWebConnUserActivity(session model.Session, activityAt int64)
|
||||
// UploadFile uploads a single file in form of a completely constructed byte array for a channel.
|
||||
@@ -341,20 +341,20 @@ type AppIface interface {
|
||||
// Uploads some files to the given team and channel as the given user. files and filenames should have
|
||||
// the same length. clientIds should either not be provided or have the same length as files and filenames.
|
||||
// The provided files should be closed by the caller so that they are not leaked.
|
||||
UploadFiles(teamId string, channelId string, userId string, files []io.ReadCloser, filenames []string, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError)
|
||||
UploadFiles(teamID string, channelId string, userID string, files []io.ReadCloser, filenames []string, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError)
|
||||
// UserIsInAdminRoleGroup returns true at least one of the user's groups are configured to set the members as
|
||||
// admins in the given syncable.
|
||||
UserIsInAdminRoleGroup(userID, syncableID string, syncableType model.GroupSyncableType) (bool, *model.AppError)
|
||||
// VerifyPlugin checks that the given signature corresponds to the given plugin and matches a trusted certificate.
|
||||
VerifyPlugin(plugin, signature io.ReadSeeker) *model.AppError
|
||||
//GetUserStatusesByIds used by apiV4
|
||||
GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError)
|
||||
GetUserStatusesByIds(userIDs []string) ([]*model.Status, *model.AppError)
|
||||
AcceptLanguage() string
|
||||
AccountMigration() einterfaces.AccountMigrationInterface
|
||||
ActivateMfa(userId, token string) *model.AppError
|
||||
AddChannelMember(userId string, channel *model.Channel, userRequestorId string, postRootId string) (*model.ChannelMember, *model.AppError)
|
||||
ActivateMfa(userID, token string) *model.AppError
|
||||
AddChannelMember(userID string, channel *model.Channel, userRequestorId string, postRootId string) (*model.ChannelMember, *model.AppError)
|
||||
AddConfigListener(listener func(*model.Config, *model.Config)) string
|
||||
AddDirectChannels(teamId string, user *model.User) *model.AppError
|
||||
AddDirectChannels(teamID string, user *model.User) *model.AppError
|
||||
AddLdapPrivateCertificate(fileData *multipart.FileHeader) *model.AppError
|
||||
AddLdapPublicCertificate(fileData *multipart.FileHeader) *model.AppError
|
||||
AddSamlIdpCertificate(fileData *multipart.FileHeader) *model.AppError
|
||||
@@ -363,27 +363,27 @@ type AppIface interface {
|
||||
AddSessionToCache(session *model.Session)
|
||||
AddStatusCache(status *model.Status)
|
||||
AddStatusCacheSkipClusterSend(status *model.Status)
|
||||
AddTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError)
|
||||
AddTeamMemberByInviteId(inviteId, userId string) (*model.TeamMember, *model.AppError)
|
||||
AddTeamMemberByToken(userId, tokenId string) (*model.TeamMember, *model.AppError)
|
||||
AddTeamMembers(teamId string, userIds []string, userRequestorId string, graceful bool) ([]*model.TeamMemberWithError, *model.AppError)
|
||||
AddTeamMember(teamID, userID string) (*model.TeamMember, *model.AppError)
|
||||
AddTeamMemberByInviteId(inviteId, userID string) (*model.TeamMember, *model.AppError)
|
||||
AddTeamMemberByToken(userID, tokenID string) (*model.TeamMember, *model.AppError)
|
||||
AddTeamMembers(teamID string, userIDs []string, userRequestorId string, graceful bool) ([]*model.TeamMemberWithError, *model.AppError)
|
||||
AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelMember, *model.AppError)
|
||||
AddUserToTeam(teamId string, userId string, userRequestorId string) (*model.Team, *model.AppError)
|
||||
AddUserToTeamByInviteId(inviteId string, userId string) (*model.Team, *model.AppError)
|
||||
AddUserToTeamByTeamId(teamId string, user *model.User) *model.AppError
|
||||
AddUserToTeamByToken(userId string, tokenId string) (*model.Team, *model.AppError)
|
||||
AddUserToTeam(teamID string, userID string, userRequestorId string) (*model.Team, *model.AppError)
|
||||
AddUserToTeamByInviteId(inviteId string, userID string) (*model.Team, *model.AppError)
|
||||
AddUserToTeamByTeamId(teamID string, user *model.User) *model.AppError
|
||||
AddUserToTeamByToken(userID string, tokenID string) (*model.Team, *model.AppError)
|
||||
AdjustImage(file io.Reader) (*bytes.Buffer, *model.AppError)
|
||||
AllowOAuthAppAccessToUser(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError)
|
||||
AllowOAuthAppAccessToUser(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError)
|
||||
AppendFile(fr io.Reader, path string) (int64, *model.AppError)
|
||||
AsymmetricSigningKey() *ecdsa.PrivateKey
|
||||
AttachDeviceId(sessionId string, deviceId string, expiresAt int64) *model.AppError
|
||||
AttachSessionCookies(w http.ResponseWriter, r *http.Request)
|
||||
AuthenticateUserForLogin(id, loginId, password, mfaToken, cwsToken string, ldapOnly bool) (user *model.User, err *model.AppError)
|
||||
AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectUri string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError)
|
||||
AutocompleteChannels(teamId string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteChannelsForSearch(teamId string, userId string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError)
|
||||
AutocompleteUsersInTeam(teamId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError)
|
||||
AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteUsersInChannel(teamID string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError)
|
||||
AutocompleteUsersInTeam(teamID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError)
|
||||
BroadcastStatus(status *model.Status)
|
||||
BuildPostReactions(postId string) (*[]ReactionImportData, *model.AppError)
|
||||
BuildPushNotificationMessage(contentsConfig string, post *model.Post, user *model.User, channel *model.Channel, channelName string, senderName string, explicitMention bool, channelWideMention bool, replyToThreadType string) (*model.PushNotification, *model.AppError)
|
||||
@@ -407,8 +407,8 @@ type AppIface interface {
|
||||
ClearChannelMembersCache(channelID string)
|
||||
ClearSessionCacheForAllUsers()
|
||||
ClearSessionCacheForAllUsersSkipClusterSend()
|
||||
ClearSessionCacheForUser(userId string)
|
||||
ClearSessionCacheForUserSkipClusterSend(userId string)
|
||||
ClearSessionCacheForUser(userID string)
|
||||
ClearSessionCacheForUserSkipClusterSend(userID string)
|
||||
ClearTeamMembersCache(teamID string)
|
||||
ClientConfig() map[string]string
|
||||
ClientConfigHash() string
|
||||
@@ -416,72 +416,72 @@ type AppIface interface {
|
||||
Cluster() einterfaces.ClusterInterface
|
||||
CompareAndDeletePluginKey(pluginId string, key string, oldValue []byte) (bool, *model.AppError)
|
||||
CompareAndSetPluginKey(pluginId string, key string, oldValue, newValue []byte) (bool, *model.AppError)
|
||||
CompleteOAuth(service string, body io.ReadCloser, teamId string, props map[string]string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||
CompleteOAuth(service string, body io.ReadCloser, teamID string, props map[string]string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||
CompleteSwitchWithOAuth(service string, userData io.Reader, email string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||
Compliance() einterfaces.ComplianceInterface
|
||||
Config() *model.Config
|
||||
Context() context.Context
|
||||
CopyFileInfos(userId string, fileIds []string) ([]string, *model.AppError)
|
||||
CopyFileInfos(userID string, fileIds []string) ([]string, *model.AppError)
|
||||
CreateChannel(channel *model.Channel, addMember bool) (*model.Channel, *model.AppError)
|
||||
CreateChannelWithUser(channel *model.Channel, userId string) (*model.Channel, *model.AppError)
|
||||
CreateChannelWithUser(channel *model.Channel, userID string) (*model.Channel, *model.AppError)
|
||||
CreateCommand(cmd *model.Command) (*model.Command, *model.AppError)
|
||||
CreateCommandWebhook(commandId string, args *model.CommandArgs) (*model.CommandWebhook, *model.AppError)
|
||||
CreateCommandWebhook(commandID string, args *model.CommandArgs) (*model.CommandWebhook, *model.AppError)
|
||||
CreateEmoji(sessionUserId string, emoji *model.Emoji, multiPartImageData *multipart.Form) (*model.Emoji, *model.AppError)
|
||||
CreateGroup(group *model.Group) (*model.Group, *model.AppError)
|
||||
CreateGroupChannel(userIds []string, creatorId string) (*model.Channel, *model.AppError)
|
||||
CreateGroupChannel(userIDs []string, creatorId string) (*model.Channel, *model.AppError)
|
||||
CreateIncomingWebhookForChannel(creatorId string, channel *model.Channel, hook *model.IncomingWebhook) (*model.IncomingWebhook, *model.AppError)
|
||||
CreateJob(job *model.Job) (*model.Job, *model.AppError)
|
||||
CreateOAuthApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError)
|
||||
CreateOAuthStateToken(extra string) (*model.Token, *model.AppError)
|
||||
CreateOAuthUser(service string, userData io.Reader, teamId string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||
CreateOAuthUser(service string, userData io.Reader, teamID string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||
CreateOutgoingWebhook(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||
CreatePasswordRecoveryToken(userId, email string) (*model.Token, *model.AppError)
|
||||
CreatePasswordRecoveryToken(userID, email string) (*model.Token, *model.AppError)
|
||||
CreatePost(post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError)
|
||||
CreatePostAsUser(post *model.Post, currentSessionId string, setOnline bool) (*model.Post, *model.AppError)
|
||||
CreatePostMissingChannel(post *model.Post, triggerWebhooks bool) (*model.Post, *model.AppError)
|
||||
CreateRole(role *model.Role) (*model.Role, *model.AppError)
|
||||
CreateScheme(scheme *model.Scheme) (*model.Scheme, *model.AppError)
|
||||
CreateSession(session *model.Session) (*model.Session, *model.AppError)
|
||||
CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
CreateSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
CreateTeam(team *model.Team) (*model.Team, *model.AppError)
|
||||
CreateTeamWithUser(team *model.Team, userId string) (*model.Team, *model.AppError)
|
||||
CreateTermsOfService(text, userId string) (*model.TermsOfService, *model.AppError)
|
||||
CreateTeamWithUser(team *model.Team, userID string) (*model.Team, *model.AppError)
|
||||
CreateTermsOfService(text, userID string) (*model.TermsOfService, *model.AppError)
|
||||
CreateUploadSession(us *model.UploadSession) (*model.UploadSession, *model.AppError)
|
||||
CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError)
|
||||
CreateUserAsAdmin(user *model.User, redirect string) (*model.User, *model.AppError)
|
||||
CreateUserFromSignup(user *model.User, redirect string) (*model.User, *model.AppError)
|
||||
CreateUserWithInviteId(user *model.User, inviteId, redirect string) (*model.User, *model.AppError)
|
||||
CreateUserWithToken(user *model.User, token *model.Token) (*model.User, *model.AppError)
|
||||
CreateWebhookPost(userId string, channel *model.Channel, text, overrideUsername, overrideIconUrl, overrideIconEmoji string, props model.StringInterface, postType string, postRootId string) (*model.Post, *model.AppError)
|
||||
CreateWebhookPost(userID string, channel *model.Channel, text, overrideUsername, overrideIconURL, overrideIconEmoji string, props model.StringInterface, postType string, postRootId string) (*model.Post, *model.AppError)
|
||||
DBHealthCheckDelete() error
|
||||
DBHealthCheckWrite() error
|
||||
DataRetention() einterfaces.DataRetentionInterface
|
||||
DeactivateGuests() *model.AppError
|
||||
DeactivateMfa(userId string) *model.AppError
|
||||
DeauthorizeOAuthAppForUser(userId, appId string) *model.AppError
|
||||
DeactivateMfa(userID string) *model.AppError
|
||||
DeauthorizeOAuthAppForUser(userID, appId string) *model.AppError
|
||||
DeleteAllExpiredPluginKeys() *model.AppError
|
||||
DeleteAllKeysForPlugin(pluginId string) *model.AppError
|
||||
DeleteBrandImage() *model.AppError
|
||||
DeleteChannel(channel *model.Channel, userId string) *model.AppError
|
||||
DeleteCommand(commandId string) *model.AppError
|
||||
DeleteChannel(channel *model.Channel, userID string) *model.AppError
|
||||
DeleteCommand(commandID string) *model.AppError
|
||||
DeleteEmoji(emoji *model.Emoji) *model.AppError
|
||||
DeleteEphemeralPost(userId, postId string)
|
||||
DeleteEphemeralPost(userID, postId string)
|
||||
DeleteFlaggedPosts(postId string)
|
||||
DeleteGroup(groupID string) (*model.Group, *model.AppError)
|
||||
DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError)
|
||||
DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError)
|
||||
DeleteIncomingWebhook(hookId string) *model.AppError
|
||||
DeleteIncomingWebhook(hookID string) *model.AppError
|
||||
DeleteOAuthApp(appId string) *model.AppError
|
||||
DeleteOutgoingWebhook(hookId string) *model.AppError
|
||||
DeleteOutgoingWebhook(hookID string) *model.AppError
|
||||
DeletePluginKey(pluginId string, key string) *model.AppError
|
||||
DeletePost(postId, deleteByID string) (*model.Post, *model.AppError)
|
||||
DeletePostFiles(post *model.Post)
|
||||
DeletePreferences(userId string, preferences model.Preferences) *model.AppError
|
||||
DeletePreferences(userID string, preferences model.Preferences) *model.AppError
|
||||
DeleteReactionForPost(reaction *model.Reaction) *model.AppError
|
||||
DeleteScheme(schemeId string) (*model.Scheme, *model.AppError)
|
||||
DeleteSidebarCategory(userId, teamId, categoryId string) *model.AppError
|
||||
DeleteSidebarCategory(userID, teamID, categoryId string) *model.AppError
|
||||
DeleteToken(token *model.Token) *model.AppError
|
||||
DisableAutoResponder(userId string, asAdmin bool) *model.AppError
|
||||
DisableAutoResponder(userID string, asAdmin bool) *model.AppError
|
||||
DisableUserAccessToken(token *model.UserAccessToken) *model.AppError
|
||||
DoAppMigrations()
|
||||
DoCommandRequest(cmd *model.Command, p url.Values) (*model.Command, *model.CommandResponse, *model.AppError)
|
||||
@@ -489,8 +489,8 @@ type AppIface interface {
|
||||
DoGuestRolesCreationMigration()
|
||||
DoLocalRequest(rawURL string, body []byte) (*http.Response, *model.AppError)
|
||||
DoLogin(w http.ResponseWriter, r *http.Request, user *model.User, deviceId string, isMobile, isOAuthUser, isSaml bool) *model.AppError
|
||||
DoPostAction(postId, actionId, userId, selectedOption string) (string, *model.AppError)
|
||||
DoPostActionWithCookie(postId, actionId, userId, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError)
|
||||
DoPostAction(postId, actionId, userID, selectedOption string) (string, *model.AppError)
|
||||
DoPostActionWithCookie(postId, actionId, userID, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError)
|
||||
DoSystemConsoleRolesCreationMigration()
|
||||
DoUploadFile(now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, *model.AppError)
|
||||
DoUploadFileExpectModification(now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError)
|
||||
@@ -507,7 +507,7 @@ type AppIface interface {
|
||||
FillInChannelsProps(channelList *model.ChannelList) *model.AppError
|
||||
FilterUsersByVisible(viewer *model.User, otherUsers []*model.User) ([]*model.User, *model.AppError)
|
||||
FindTeamByName(name string) bool
|
||||
GenerateMfaSecret(userId string) (*model.MfaSecret, *model.AppError)
|
||||
GenerateMfaSecret(userID string) (*model.MfaSecret, *model.AppError)
|
||||
GeneratePublicLink(siteURL string, info *model.FileInfo) string
|
||||
GenerateSupportPacket() []model.FileData
|
||||
GetActivePluginManifests() ([]*model.Manifest, *model.AppError)
|
||||
@@ -524,43 +524,43 @@ type AppIface interface {
|
||||
GetAllTeams() ([]*model.Team, *model.AppError)
|
||||
GetAllTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError)
|
||||
GetAllTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError)
|
||||
GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppError)
|
||||
GetAudits(userId string, limit int) (model.Audits, *model.AppError)
|
||||
GetAuditsPage(userId string, page int, perPage int) (model.Audits, *model.AppError)
|
||||
GetAnalytics(name string, teamID string) (model.AnalyticsRows, *model.AppError)
|
||||
GetAudits(userID string, limit int) (model.Audits, *model.AppError)
|
||||
GetAuditsPage(userID string, page int, perPage int) (model.Audits, *model.AppError)
|
||||
GetAuthorizationCode(w http.ResponseWriter, r *http.Request, service string, props map[string]string, loginHint string) (string, *model.AppError)
|
||||
GetAuthorizedAppsForUser(userId string, page, perPage int) ([]*model.OAuthApp, *model.AppError)
|
||||
GetAuthorizedAppsForUser(userID string, page, perPage int) ([]*model.OAuthApp, *model.AppError)
|
||||
GetBrandImage() ([]byte, *model.AppError)
|
||||
GetBulkReactionsForPosts(postIds []string) (map[string][]*model.Reaction, *model.AppError)
|
||||
GetChannel(channelId string) (*model.Channel, *model.AppError)
|
||||
GetChannelByName(channelName, teamId string, includeDeleted bool) (*model.Channel, *model.AppError)
|
||||
GetChannelByName(channelName, teamID string, includeDeleted bool) (*model.Channel, *model.AppError)
|
||||
GetChannelByNameForTeamName(channelName, teamName string, includeDeleted bool) (*model.Channel, *model.AppError)
|
||||
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError)
|
||||
GetChannelCounts(teamID string, userID string) (*model.ChannelCounts, *model.AppError)
|
||||
GetChannelGuestCount(channelId string) (int64, *model.AppError)
|
||||
GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError)
|
||||
GetChannelMember(channelId string, userID string) (*model.ChannelMember, *model.AppError)
|
||||
GetChannelMemberCount(channelId string) (int64, *model.AppError)
|
||||
GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersForUserWithPagination(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError)
|
||||
GetChannelMembersByIds(channelId string, userIDs []string) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersForUserWithPagination(teamID, userID string, page, perPage int) ([]*model.ChannelMember, *model.AppError)
|
||||
GetChannelMembersPage(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersTimezones(channelId string) ([]string, *model.AppError)
|
||||
GetChannelPinnedPostCount(channelId string) (int64, *model.AppError)
|
||||
GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError)
|
||||
GetChannelsByNames(channelNames []string, teamId string) ([]*model.Channel, *model.AppError)
|
||||
GetChannelUnread(channelId, userID string) (*model.ChannelUnread, *model.AppError)
|
||||
GetChannelsByNames(channelNames []string, teamID string) ([]*model.Channel, *model.AppError)
|
||||
GetChannelsForScheme(scheme *model.Scheme, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||
GetChannelsForSchemePage(scheme *model.Scheme, page int, perPage int) (model.ChannelList, *model.AppError)
|
||||
GetChannelsForUser(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsUserNotIn(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetCloudSession(token string) (*model.Session, *model.AppError)
|
||||
GetClusterId() string
|
||||
GetClusterStatus() []*model.ClusterInfo
|
||||
GetCommand(commandId string) (*model.Command, *model.AppError)
|
||||
GetCommand(commandID string) (*model.Command, *model.AppError)
|
||||
GetComplianceFile(job *model.Compliance) ([]byte, *model.AppError)
|
||||
GetComplianceReport(reportId string) (*model.Compliance, *model.AppError)
|
||||
GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError)
|
||||
GetCookieDomain() string
|
||||
GetDataRetentionPolicy() (*model.DataRetentionPolicy, *model.AppError)
|
||||
GetDefaultProfileImage(user *model.User) ([]byte, *model.AppError)
|
||||
GetDeletedChannels(teamId string, offset int, limit int, userId string) (*model.ChannelList, *model.AppError)
|
||||
GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError)
|
||||
GetEmoji(emojiId string) (*model.Emoji, *model.AppError)
|
||||
GetEmojiByName(emojiName string) (*model.Emoji, *model.AppError)
|
||||
GetEmojiImage(emojiId string) ([]byte, string, *model.AppError)
|
||||
@@ -571,30 +571,30 @@ type AppIface interface {
|
||||
GetFileInfos(page, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, *model.AppError)
|
||||
GetFileInfosForPost(postId string, fromMaster bool) ([]*model.FileInfo, *model.AppError)
|
||||
GetFileInfosForPostWithMigration(postId string) ([]*model.FileInfo, *model.AppError)
|
||||
GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPosts(userID string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPostsForChannel(userID, channelId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPostsForTeam(userID, teamID string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetGroup(id string) (*model.Group, *model.AppError)
|
||||
GetGroupByName(name string, opts model.GroupSearchOpts) (*model.Group, *model.AppError)
|
||||
GetGroupByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, *model.AppError)
|
||||
GetGroupChannel(userIds []string) (*model.Channel, *model.AppError)
|
||||
GetGroupChannel(userIDs []string) (*model.Channel, *model.AppError)
|
||||
GetGroupMemberCount(groupID string) (int64, *model.AppError)
|
||||
GetGroupMemberUsers(groupID string) ([]*model.User, *model.AppError)
|
||||
GetGroupMemberUsersPage(groupID string, page int, perPage int) ([]*model.User, int, *model.AppError)
|
||||
GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError)
|
||||
GetGroupSyncables(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, *model.AppError)
|
||||
GetGroups(page, perPage int, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError)
|
||||
GetGroupsAssociatedToChannelsByTeam(teamId string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, *model.AppError)
|
||||
GetGroupsAssociatedToChannelsByTeam(teamID string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, *model.AppError)
|
||||
GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, int, *model.AppError)
|
||||
GetGroupsByIDs(groupIDs []string) ([]*model.Group, *model.AppError)
|
||||
GetGroupsBySource(groupSource model.GroupSource) ([]*model.Group, *model.AppError)
|
||||
GetGroupsByUserId(userId string) ([]*model.Group, *model.AppError)
|
||||
GetHubForUserId(userId string) *Hub
|
||||
GetIncomingWebhook(hookId string) (*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksForTeamPage(teamId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksForTeamPageByUser(teamId string, userId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
GetGroupsByUserId(userID string) ([]*model.Group, *model.AppError)
|
||||
GetHubForUserId(userID string) *Hub
|
||||
GetIncomingWebhook(hookID string) (*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksForTeamPage(teamID string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksForTeamPageByUser(teamID string, userID string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksPage(page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksPageByUser(userId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksPageByUser(userID string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
GetJob(id string) (*model.Job, *model.AppError)
|
||||
GetJobs(offset int, limit int) ([]*model.Job, *model.AppError)
|
||||
GetJobsByType(jobType string, offset int, limit int) ([]*model.Job, *model.AppError)
|
||||
@@ -606,30 +606,30 @@ type AppIface interface {
|
||||
GetMemberCountsByGroup(channelID string, includeTimezones bool) ([]*model.ChannelMemberCountByGroup, *model.AppError)
|
||||
GetMessageForNotification(post *model.Post, translateFunc i18n.TranslateFunc) string
|
||||
GetMultipleEmojiByName(names []string) ([]*model.Emoji, *model.AppError)
|
||||
GetNewUsersForTeamPage(teamId string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetNewUsersForTeamPage(teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetNextPostIdFromPostList(postList *model.PostList) string
|
||||
GetNotificationNameFormat(user *model.User) string
|
||||
GetNumberOfChannelsOnTeam(teamId string) (int, *model.AppError)
|
||||
GetNumberOfChannelsOnTeam(teamID string) (int, *model.AppError)
|
||||
GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, code, secret, refreshToken string) (*model.AccessResponse, *model.AppError)
|
||||
GetOAuthAccessTokenForImplicitFlow(userId string, authRequest *model.AuthorizeRequest) (*model.Session, *model.AppError)
|
||||
GetOAuthAccessTokenForImplicitFlow(userID string, authRequest *model.AuthorizeRequest) (*model.Session, *model.AppError)
|
||||
GetOAuthApp(appId string) (*model.OAuthApp, *model.AppError)
|
||||
GetOAuthApps(page, perPage int) ([]*model.OAuthApp, *model.AppError)
|
||||
GetOAuthAppsByCreator(userId string, page, perPage int) ([]*model.OAuthApp, *model.AppError)
|
||||
GetOAuthCodeRedirect(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError)
|
||||
GetOAuthImplicitRedirect(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError)
|
||||
GetOAuthLoginEndpoint(w http.ResponseWriter, r *http.Request, service, teamId, action, redirectTo, loginHint string, isMobile bool) (string, *model.AppError)
|
||||
GetOAuthSignupEndpoint(w http.ResponseWriter, r *http.Request, service, teamId string) (string, *model.AppError)
|
||||
GetOAuthAppsByCreator(userID string, page, perPage int) ([]*model.OAuthApp, *model.AppError)
|
||||
GetOAuthCodeRedirect(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError)
|
||||
GetOAuthImplicitRedirect(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError)
|
||||
GetOAuthLoginEndpoint(w http.ResponseWriter, r *http.Request, service, teamID, action, redirectTo, loginHint string, isMobile bool) (string, *model.AppError)
|
||||
GetOAuthSignupEndpoint(w http.ResponseWriter, r *http.Request, service, teamID string) (string, *model.AppError)
|
||||
GetOAuthStateToken(token string) (*model.Token, *model.AppError)
|
||||
GetOpenGraphMetadata(requestURL string) *opengraph.OpenGraph
|
||||
GetOrCreateDirectChannel(userId, otherUserId string) (*model.Channel, *model.AppError)
|
||||
GetOutgoingWebhook(hookId string) (*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksForChannelPageByUser(channelId string, userId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksForTeamPage(teamId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksForTeamPageByUser(teamId string, userId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOrCreateDirectChannel(userID, otherUserId string) (*model.Channel, *model.AppError)
|
||||
GetOutgoingWebhook(hookID string) (*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksForChannelPageByUser(channelId string, userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksForTeamPage(teamID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksForTeamPageByUser(teamID string, userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksPage(page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksPageByUser(userId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingWebhooksPageByUser(userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetPasswordRecoveryToken(token string) (*model.Token, *model.AppError)
|
||||
GetPermalinkPost(postId string, userId string) (*model.PostList, *model.AppError)
|
||||
GetPermalinkPost(postId string, userID string) (*model.PostList, *model.AppError)
|
||||
GetPinnedPosts(channelId string) (*model.PostList, *model.AppError)
|
||||
GetPluginKey(pluginId string, key string) ([]byte, *model.AppError)
|
||||
GetPlugins() (*model.PluginsResponse, *model.AppError)
|
||||
@@ -642,20 +642,20 @@ type AppIface interface {
|
||||
GetPostsAroundPost(before bool, options model.GetPostsOptions) (*model.PostList, *model.AppError)
|
||||
GetPostsBeforePost(options model.GetPostsOptions) (*model.PostList, *model.AppError)
|
||||
GetPostsEtag(channelId string, collapsedThreads bool) string
|
||||
GetPostsForChannelAroundLastUnread(channelId, userId string, limitBefore, limitAfter int, skipFetchThreads bool, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, *model.AppError)
|
||||
GetPostsForChannelAroundLastUnread(channelId, userID string, limitBefore, limitAfter int, skipFetchThreads bool, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, *model.AppError)
|
||||
GetPostsPage(options model.GetPostsOptions) (*model.PostList, *model.AppError)
|
||||
GetPostsSince(options model.GetPostsSinceOptions) (*model.PostList, *model.AppError)
|
||||
GetPreferenceByCategoryAndNameForUser(userId string, category string, preferenceName string) (*model.Preference, *model.AppError)
|
||||
GetPreferenceByCategoryForUser(userId string, category string) (model.Preferences, *model.AppError)
|
||||
GetPreferencesForUser(userId string) (model.Preferences, *model.AppError)
|
||||
GetPreferenceByCategoryAndNameForUser(userID string, category string, preferenceName string) (*model.Preference, *model.AppError)
|
||||
GetPreferenceByCategoryForUser(userID string, category string) (model.Preferences, *model.AppError)
|
||||
GetPreferencesForUser(userID string) (model.Preferences, *model.AppError)
|
||||
GetPrevPostIdFromPostList(postList *model.PostList) string
|
||||
GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetProfileImage(user *model.User) ([]byte, bool, *model.AppError)
|
||||
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetReactionsForPost(postId string) ([]*model.Reaction, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeam(teamId string) (map[string]*model.User, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeamPage(teamId string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeam(teamID string) (map[string]*model.User, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeamPage(teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetRole(id string) (*model.Role, *model.AppError)
|
||||
GetRoleByName(name string) (*model.Role, *model.AppError)
|
||||
GetRolesByNames(names []string) ([]*model.Role, *model.AppError)
|
||||
@@ -665,55 +665,55 @@ type AppIface interface {
|
||||
GetSanitizeOptions(asAdmin bool) map[string]bool
|
||||
GetScheme(id string) (*model.Scheme, *model.AppError)
|
||||
GetSchemeByName(name string) (*model.Scheme, *model.AppError)
|
||||
GetSchemeRolesForTeam(teamId string) (string, string, string, *model.AppError)
|
||||
GetSchemeRolesForTeam(teamID string) (string, string, string, *model.AppError)
|
||||
GetSchemes(scope string, offset int, limit int) ([]*model.Scheme, *model.AppError)
|
||||
GetSchemesPage(scope string, page int, perPage int) ([]*model.Scheme, *model.AppError)
|
||||
GetSession(token string) (*model.Session, *model.AppError)
|
||||
GetSessionById(sessionId string) (*model.Session, *model.AppError)
|
||||
GetSessions(userId string) ([]*model.Session, *model.AppError)
|
||||
GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, *model.AppError)
|
||||
GetSessions(userID string) ([]*model.Session, *model.AppError)
|
||||
GetSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError)
|
||||
GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError)
|
||||
GetSidebarCategoryOrder(userID, teamID string) ([]string, *model.AppError)
|
||||
GetSinglePost(postId string) (*model.Post, *model.AppError)
|
||||
GetSiteURL() string
|
||||
GetStatus(userId string) (*model.Status, *model.AppError)
|
||||
GetStatusFromCache(userId string) *model.Status
|
||||
GetStatusesByIds(userIds []string) (map[string]interface{}, *model.AppError)
|
||||
GetStatus(userID string) (*model.Status, *model.AppError)
|
||||
GetStatusFromCache(userID string) *model.Status
|
||||
GetStatusesByIds(userIDs []string) (map[string]interface{}, *model.AppError)
|
||||
GetT() goi18n.TranslateFunc
|
||||
GetTeam(teamId string) (*model.Team, *model.AppError)
|
||||
GetTeam(teamID string) (*model.Team, *model.AppError)
|
||||
GetTeamByInviteId(inviteId string) (*model.Team, *model.AppError)
|
||||
GetTeamByName(name string) (*model.Team, *model.AppError)
|
||||
GetTeamIcon(team *model.Team) ([]byte, *model.AppError)
|
||||
GetTeamIdFromQuery(query url.Values) (string, *model.AppError)
|
||||
GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError)
|
||||
GetTeamMembers(teamId string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamMembersByIds(teamId string, userIds []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamMembersForUser(userId string) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamMembersForUserWithPagination(userId string, page, perPage int) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamStats(teamId string, restrictions *model.ViewUsersRestrictions) (*model.TeamStats, *model.AppError)
|
||||
GetTeamUnread(teamId, userId string) (*model.TeamUnread, *model.AppError)
|
||||
GetTeamMember(teamID, userID string) (*model.TeamMember, *model.AppError)
|
||||
GetTeamMembers(teamID string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamMembersByIds(teamID string, userIDs []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamMembersForUser(userID string) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamMembersForUserWithPagination(userID string, page, perPage int) ([]*model.TeamMember, *model.AppError)
|
||||
GetTeamStats(teamID string, restrictions *model.ViewUsersRestrictions) (*model.TeamStats, *model.AppError)
|
||||
GetTeamUnread(teamID, userID string) (*model.TeamUnread, *model.AppError)
|
||||
GetTeamsForScheme(scheme *model.Scheme, offset int, limit int) ([]*model.Team, *model.AppError)
|
||||
GetTeamsForSchemePage(scheme *model.Scheme, page int, perPage int) ([]*model.Team, *model.AppError)
|
||||
GetTeamsForUser(userId string) ([]*model.Team, *model.AppError)
|
||||
GetTeamsUnreadForUser(excludeTeamId string, userId string) ([]*model.TeamUnread, *model.AppError)
|
||||
GetTeamsForUser(userID string) ([]*model.Team, *model.AppError)
|
||||
GetTeamsUnreadForUser(excludeTeamId string, userID string) ([]*model.TeamUnread, *model.AppError)
|
||||
GetTermsOfService(id string) (*model.TermsOfService, *model.AppError)
|
||||
GetThreadForUser(userId, teamId, threadId string, extended bool) (*model.ThreadResponse, *model.AppError)
|
||||
GetThreadMembershipsForUser(userId, teamId string) ([]*model.ThreadMembership, error)
|
||||
GetThreadsForUser(userId, teamId string, options model.GetUserThreadsOpts) (*model.Threads, *model.AppError)
|
||||
GetThreadForUser(userID, teamID, threadId string, extended bool) (*model.ThreadResponse, *model.AppError)
|
||||
GetThreadMembershipsForUser(userID, teamID string) ([]*model.ThreadMembership, error)
|
||||
GetThreadsForUser(userID, teamID string, options model.GetUserThreadsOpts) (*model.Threads, *model.AppError)
|
||||
GetUploadSession(uploadId string) (*model.UploadSession, *model.AppError)
|
||||
GetUploadSessionsForUser(userId string) ([]*model.UploadSession, *model.AppError)
|
||||
GetUser(userId string) (*model.User, *model.AppError)
|
||||
GetUserAccessToken(tokenId string, sanitize bool) (*model.UserAccessToken, *model.AppError)
|
||||
GetUploadSessionsForUser(userID string) ([]*model.UploadSession, *model.AppError)
|
||||
GetUser(userID string) (*model.User, *model.AppError)
|
||||
GetUserAccessToken(tokenID string, sanitize bool) (*model.UserAccessToken, *model.AppError)
|
||||
GetUserAccessTokens(page, perPage int) ([]*model.UserAccessToken, *model.AppError)
|
||||
GetUserAccessTokensForUser(userId string, page, perPage int) ([]*model.UserAccessToken, *model.AppError)
|
||||
GetUserAccessTokensForUser(userID string, page, perPage int) ([]*model.UserAccessToken, *model.AppError)
|
||||
GetUserByAuth(authData *string, authService string) (*model.User, *model.AppError)
|
||||
GetUserByEmail(email string) (*model.User, *model.AppError)
|
||||
GetUserByUsername(username string) (*model.User, *model.AppError)
|
||||
GetUserForLogin(id, loginId string) (*model.User, *model.AppError)
|
||||
GetUserTermsOfService(userId string) (*model.UserTermsOfService, *model.AppError)
|
||||
GetUserTermsOfService(userID string) (*model.UserTermsOfService, *model.AppError)
|
||||
GetUsers(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetUsersByGroupChannelIds(channelIds []string, asAdmin bool) (map[string][]*model.User, *model.AppError)
|
||||
GetUsersByIds(userIds []string, options *store.UserGetByIdsOpts) ([]*model.User, *model.AppError)
|
||||
GetUsersByIds(userIDs []string, options *store.UserGetByIdsOpts) ([]*model.User, *model.AppError)
|
||||
GetUsersByUsernames(usernames []string, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersEtag(restrictionsHash string) string
|
||||
GetUsersInChannel(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
@@ -722,33 +722,33 @@ type AppIface interface {
|
||||
GetUsersInChannelPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError)
|
||||
GetUsersInChannelPageByStatus(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError)
|
||||
GetUsersInTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetUsersInTeamEtag(teamId string, restrictionsHash string) string
|
||||
GetUsersInTeamEtag(teamID string, restrictionsHash string) string
|
||||
GetUsersInTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInChannelMap(teamId string, channelId string, groupConstrained bool, offset int, limit int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) (map[string]*model.User, *model.AppError)
|
||||
GetUsersNotInChannelPage(teamId string, channelId string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInTeamEtag(teamId string, restrictionsHash string) string
|
||||
GetUsersNotInTeamPage(teamId string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInChannel(teamID string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInChannelMap(teamID string, channelId string, groupConstrained bool, offset int, limit int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) (map[string]*model.User, *model.AppError)
|
||||
GetUsersNotInChannelPage(teamID string, channelId string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInTeam(teamID string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersNotInTeamEtag(teamID string, restrictionsHash string) string
|
||||
GetUsersNotInTeamPage(teamID string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUsersPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError)
|
||||
GetUsersWithoutTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetUsersWithoutTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError)
|
||||
GetVerifyEmailToken(token string) (*model.Token, *model.AppError)
|
||||
GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError)
|
||||
GetViewUsersRestrictions(userID string) (*model.ViewUsersRestrictions, *model.AppError)
|
||||
GetWarnMetricsStatus() (map[string]*model.WarnMetricStatus, *model.AppError)
|
||||
HTTPService() httpservice.HTTPService
|
||||
Handle404(w http.ResponseWriter, r *http.Request)
|
||||
HandleCommandResponse(command *model.Command, args *model.CommandArgs, response *model.CommandResponse, builtIn bool) (*model.CommandResponse, *model.AppError)
|
||||
HandleCommandResponsePost(command *model.Command, args *model.CommandArgs, response *model.CommandResponse, builtIn bool) (*model.Post, *model.AppError)
|
||||
HandleCommandWebhook(hookId string, response *model.CommandResponse) *model.AppError
|
||||
HandleCommandWebhook(hookID string, response *model.CommandResponse) *model.AppError
|
||||
HandleImages(previewPathList []string, thumbnailPathList []string, fileData [][]byte)
|
||||
HandleIncomingWebhook(hookId string, req *model.IncomingWebhookRequest) *model.AppError
|
||||
HandleIncomingWebhook(hookID string, req *model.IncomingWebhookRequest) *model.AppError
|
||||
HandleMessageExportConfig(cfg *model.Config, appCfg *model.Config)
|
||||
HasPermissionTo(askingUserId string, permission *model.Permission) bool
|
||||
HasPermissionToChannel(askingUserId string, channelId string, permission *model.Permission) bool
|
||||
HasPermissionToChannelByPost(askingUserId string, postId string, permission *model.Permission) bool
|
||||
HasPermissionToTeam(askingUserId string, teamId string, permission *model.Permission) bool
|
||||
HasPermissionToUser(askingUserId string, userId string) bool
|
||||
HasPermissionToTeam(askingUserId string, teamID string, permission *model.Permission) bool
|
||||
HasPermissionToUser(askingUserId string, userID string) bool
|
||||
HubStop()
|
||||
ImageProxy() *imageproxy.ImageProxy
|
||||
ImageProxyAdder() func(string) string
|
||||
@@ -759,12 +759,12 @@ type AppIface interface {
|
||||
InitServer()
|
||||
InstallPluginFromData(data model.PluginEventData)
|
||||
InvalidateAllEmailInvites() *model.AppError
|
||||
InvalidateCacheForUser(userId string)
|
||||
InvalidateWebConnSessionCacheForUser(userId string)
|
||||
InviteGuestsToChannels(teamId string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError
|
||||
InviteGuestsToChannelsGracefully(teamId string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||
InviteNewUsersToTeam(emailList []string, teamId, senderId string) *model.AppError
|
||||
InviteNewUsersToTeamGracefully(emailList []string, teamId, senderId string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||
InvalidateCacheForUser(userID string)
|
||||
InvalidateWebConnSessionCacheForUser(userID string)
|
||||
InviteGuestsToChannels(teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError
|
||||
InviteGuestsToChannelsGracefully(teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||
InviteNewUsersToTeam(emailList []string, teamID, senderId string) *model.AppError
|
||||
InviteNewUsersToTeamGracefully(emailList []string, teamID, senderId string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||
IpAddress() string
|
||||
IsFirstUserAccount() bool
|
||||
IsLeader() bool
|
||||
@@ -772,22 +772,22 @@ type AppIface interface {
|
||||
IsPhase2MigrationCompleted() *model.AppError
|
||||
IsUserAway(lastActivityAt int64) bool
|
||||
IsUserSignUpAllowed() *model.AppError
|
||||
JoinChannel(channel *model.Channel, userId string) *model.AppError
|
||||
JoinDefaultChannels(teamId string, user *model.User, shouldBeAdmin bool, userRequestorId string) *model.AppError
|
||||
JoinChannel(channel *model.Channel, userID string) *model.AppError
|
||||
JoinDefaultChannels(teamID string, user *model.User, shouldBeAdmin bool, userRequestorId string) *model.AppError
|
||||
JoinUserToTeam(team *model.Team, user *model.User, userRequestorId string) *model.AppError
|
||||
Ldap() einterfaces.LdapInterface
|
||||
LeaveChannel(channelId string, userId string) *model.AppError
|
||||
LeaveChannel(channelId string, userID string) *model.AppError
|
||||
LeaveTeam(team *model.Team, user *model.User, requestorId string) *model.AppError
|
||||
LimitedClientConfig() map[string]string
|
||||
ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError)
|
||||
ListAllCommands(teamID string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError)
|
||||
ListDirectory(path string) ([]string, *model.AppError)
|
||||
ListImports() ([]string, *model.AppError)
|
||||
ListPluginKeys(pluginId string, page, perPage int) ([]string, *model.AppError)
|
||||
ListTeamCommands(teamId string) ([]*model.Command, *model.AppError)
|
||||
ListTeamCommands(teamID string) ([]*model.Command, *model.AppError)
|
||||
Log() *mlog.Logger
|
||||
LoginByOAuth(service string, userData io.Reader, teamId string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||
LoginByOAuth(service string, userData io.Reader, teamID string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||
MakePermissionError(permissions []*model.Permission) *model.AppError
|
||||
MarkChannelsAsViewed(channelIds []string, userId string, currentSessionId string) (map[string]int64, *model.AppError)
|
||||
MarkChannelsAsViewed(channelIds []string, userID string, currentSessionId string) (map[string]int64, *model.AppError)
|
||||
MaxPostSize() int
|
||||
MessageExport() einterfaces.MessageExportInterface
|
||||
Metrics() einterfaces.MetricsInterface
|
||||
@@ -801,26 +801,26 @@ type AppIface interface {
|
||||
NotifyAndSetWarnMetricAck(warnMetricId string, sender *model.User, forceAck bool, isBot bool) *model.AppError
|
||||
OpenInteractiveDialog(request model.OpenDialogRequest) *model.AppError
|
||||
OriginChecker() func(*http.Request) bool
|
||||
PatchChannel(channel *model.Channel, patch *model.ChannelPatch, userId string) (*model.Channel, *model.AppError)
|
||||
PatchChannel(channel *model.Channel, patch *model.ChannelPatch, userID string) (*model.Channel, *model.AppError)
|
||||
PatchPost(postId string, patch *model.PostPatch) (*model.Post, *model.AppError)
|
||||
PatchRole(role *model.Role, patch *model.RolePatch) (*model.Role, *model.AppError)
|
||||
PatchScheme(scheme *model.Scheme, patch *model.SchemePatch) (*model.Scheme, *model.AppError)
|
||||
PatchTeam(teamId string, patch *model.TeamPatch) (*model.Team, *model.AppError)
|
||||
PatchUser(userId string, patch *model.UserPatch, asAdmin bool) (*model.User, *model.AppError)
|
||||
PatchTeam(teamID string, patch *model.TeamPatch) (*model.Team, *model.AppError)
|
||||
PatchUser(userID string, patch *model.UserPatch, asAdmin bool) (*model.User, *model.AppError)
|
||||
Path() string
|
||||
PermanentDeleteAllUsers() *model.AppError
|
||||
PermanentDeleteChannel(channel *model.Channel) *model.AppError
|
||||
PermanentDeleteTeam(team *model.Team) *model.AppError
|
||||
PermanentDeleteTeamId(teamId string) *model.AppError
|
||||
PermanentDeleteTeamId(teamID string) *model.AppError
|
||||
PermanentDeleteUser(user *model.User) *model.AppError
|
||||
PluginCommandsForTeam(teamId string) []*model.Command
|
||||
PluginCommandsForTeam(teamID string) []*model.Command
|
||||
PluginContext() *plugin.Context
|
||||
PostActionCookieSecret() []byte
|
||||
PostAddToChannelMessage(user *model.User, addedUser *model.User, channel *model.Channel, postRootId string) *model.AppError
|
||||
PostPatchWithProxyRemovedFromImageURLs(patch *model.PostPatch) *model.PostPatch
|
||||
PostUpdateChannelDisplayNameMessage(userId string, channel *model.Channel, oldChannelDisplayName, newChannelDisplayName string) *model.AppError
|
||||
PostUpdateChannelHeaderMessage(userId string, channel *model.Channel, oldChannelHeader, newChannelHeader string) *model.AppError
|
||||
PostUpdateChannelPurposeMessage(userId string, channel *model.Channel, oldChannelPurpose string, newChannelPurpose string) *model.AppError
|
||||
PostUpdateChannelDisplayNameMessage(userID string, channel *model.Channel, oldChannelDisplayName, newChannelDisplayName string) *model.AppError
|
||||
PostUpdateChannelHeaderMessage(userID string, channel *model.Channel, oldChannelHeader, newChannelHeader string) *model.AppError
|
||||
PostUpdateChannelPurposeMessage(userID string, channel *model.Channel, oldChannelPurpose string, newChannelPurpose string) *model.AppError
|
||||
PostWithProxyAddedToImageURLs(post *model.Post) *model.Post
|
||||
PostWithProxyRemovedFromImageURLs(post *model.Post) *model.Post
|
||||
PreparePostForClient(originalPost *model.Post, isNewPost bool, isEditPost bool) *model.Post
|
||||
@@ -828,7 +828,7 @@ type AppIface interface {
|
||||
ProcessSlackText(text string) string
|
||||
Publish(message *model.WebSocketEvent)
|
||||
PublishSkipClusterSend(message *model.WebSocketEvent)
|
||||
PublishUserTyping(userId, channelId, parentId string) *model.AppError
|
||||
PublishUserTyping(userID, channelId, parentId string) *model.AppError
|
||||
PurgeBleveIndexes() *model.AppError
|
||||
PurgeElasticsearchIndexes() *model.AppError
|
||||
ReadFile(path string) ([]byte, *model.AppError)
|
||||
@@ -836,7 +836,7 @@ type AppIface interface {
|
||||
RegenCommandToken(cmd *model.Command) (*model.Command, *model.AppError)
|
||||
RegenOutgoingWebhookToken(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||
RegenerateOAuthAppSecret(app *model.OAuthApp) (*model.OAuthApp, *model.AppError)
|
||||
RegenerateTeamInviteId(teamId string) (*model.Team, *model.AppError)
|
||||
RegenerateTeamInviteId(teamID string) (*model.Team, *model.AppError)
|
||||
RegisterPluginCommand(pluginId string, command *model.Command) error
|
||||
ReloadConfig() error
|
||||
RemoveAllDeactivatedMembersFromChannel(channel *model.Channel) *model.AppError
|
||||
@@ -850,24 +850,24 @@ type AppIface interface {
|
||||
RemoveSamlIdpCertificate() *model.AppError
|
||||
RemoveSamlPrivateCertificate() *model.AppError
|
||||
RemoveSamlPublicCertificate() *model.AppError
|
||||
RemoveTeamIcon(teamId string) *model.AppError
|
||||
RemoveTeamIcon(teamID string) *model.AppError
|
||||
RemoveTeamMemberFromTeam(teamMember *model.TeamMember, requestorId string) *model.AppError
|
||||
RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError
|
||||
RemoveUserFromTeam(teamId string, userId string, requestorId string) *model.AppError
|
||||
RemoveUserFromChannel(userIDToRemove string, removerUserId string, channel *model.Channel) *model.AppError
|
||||
RemoveUserFromTeam(teamID string, userID string, requestorId string) *model.AppError
|
||||
RemoveUsersFromChannelNotMemberOfTeam(remover *model.User, channel *model.Channel, team *model.Team) *model.AppError
|
||||
RequestId() string
|
||||
RequestLicenseAndAckWarnMetric(warnMetricId string, isBot bool) *model.AppError
|
||||
ResetPasswordFromToken(userSuppliedTokenString, newPassword string) *model.AppError
|
||||
ResetPermissionsSystem() *model.AppError
|
||||
RestoreChannel(channel *model.Channel, userId string) (*model.Channel, *model.AppError)
|
||||
RestoreTeam(teamId string) *model.AppError
|
||||
RestrictUsersGetByPermissions(userId string, options *model.UserGetOptions) (*model.UserGetOptions, *model.AppError)
|
||||
RestrictUsersSearchByPermissions(userId string, options *model.UserSearchOptions) (*model.UserSearchOptions, *model.AppError)
|
||||
RestoreChannel(channel *model.Channel, userID string) (*model.Channel, *model.AppError)
|
||||
RestoreTeam(teamID string) *model.AppError
|
||||
RestrictUsersGetByPermissions(userID string, options *model.UserGetOptions) (*model.UserGetOptions, *model.AppError)
|
||||
RestrictUsersSearchByPermissions(userID string, options *model.UserSearchOptions) (*model.UserSearchOptions, *model.AppError)
|
||||
RevokeAccessToken(token string) *model.AppError
|
||||
RevokeAllSessions(userId string) *model.AppError
|
||||
RevokeAllSessions(userID string) *model.AppError
|
||||
RevokeSession(session *model.Session) *model.AppError
|
||||
RevokeSessionById(sessionId string) *model.AppError
|
||||
RevokeSessionsForDeviceId(userId string, deviceId string, currentSessionId string) *model.AppError
|
||||
RevokeSessionsForDeviceId(userID string, deviceId string, currentSessionId string) *model.AppError
|
||||
RevokeUserAccessToken(token *model.UserAccessToken) *model.AppError
|
||||
RolesGrantPermission(roleNames []string, permissionId string) bool
|
||||
Saml() einterfaces.SamlInterface
|
||||
@@ -878,32 +878,32 @@ type AppIface interface {
|
||||
SaveBrandImage(imageData *multipart.FileHeader) *model.AppError
|
||||
SaveComplianceReport(job *model.Compliance) (*model.Compliance, *model.AppError)
|
||||
SaveReactionForPost(reaction *model.Reaction) (*model.Reaction, *model.AppError)
|
||||
SaveUserTermsOfService(userId, termsOfServiceId string, accepted bool) *model.AppError
|
||||
SaveUserTermsOfService(userID, termsOfServiceId string, accepted bool) *model.AppError
|
||||
SchemesIterator(scope string, batchSize int) func() []*model.Scheme
|
||||
SearchArchivedChannels(teamId string, term string, userId string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannelsForUser(userId, teamId, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannelsUserNotIn(teamId string, userId string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannelsForUser(userID, teamID, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchEmoji(name string, prefixOnly bool, limit int) ([]*model.Emoji, *model.AppError)
|
||||
SearchEngine() *searchengine.Broker
|
||||
SearchGroupChannels(userId, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchPostsInTeam(teamId string, paramsList []*model.SearchParams) (*model.PostList, *model.AppError)
|
||||
SearchPostsInTeamForUser(terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError)
|
||||
SearchGroupChannels(userID, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchPostsInTeam(teamID string, paramsList []*model.SearchParams) (*model.PostList, *model.AppError)
|
||||
SearchPostsInTeamForUser(terms string, userID string, teamID string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError)
|
||||
SearchPrivateTeams(term string) ([]*model.Team, *model.AppError)
|
||||
SearchPublicTeams(term string) ([]*model.Team, *model.AppError)
|
||||
SearchUserAccessTokens(term string) ([]*model.UserAccessToken, *model.AppError)
|
||||
SearchUsers(props *model.UserSearch, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersInTeam(teamId, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersInTeam(teamID, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersNotInChannel(teamID string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchUsersWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SendAckToPushProxy(ack *model.PushNotificationAck) error
|
||||
SendAutoResponse(channel *model.Channel, receiver *model.User, post *model.Post) (bool, *model.AppError)
|
||||
SendAutoResponseIfNecessary(channel *model.Channel, sender *model.User, post *model.Post) (bool, *model.AppError)
|
||||
SendEmailVerification(user *model.User, newEmail, redirect string) *model.AppError
|
||||
SendEphemeralPost(userId string, post *model.Post) *model.Post
|
||||
SendEphemeralPost(userID string, post *model.Post) *model.Post
|
||||
SendNotifications(post *model.Post, team *model.Team, channel *model.Channel, sender *model.User, parentPostList *model.PostList, setOnline bool) ([]string, error)
|
||||
SendPasswordReset(email string, siteURL string) (bool, *model.AppError)
|
||||
SendPaymentFailedEmail(failedPayment *model.FailedPayment) *model.AppError
|
||||
@@ -913,14 +913,14 @@ type AppIface interface {
|
||||
SessionCacheLength() int
|
||||
SessionHasPermissionTo(session model.Session, permission *model.Permission) bool
|
||||
SessionHasPermissionToAny(session model.Session, permissions []*model.Permission) bool
|
||||
SessionHasPermissionToCategory(session model.Session, userId, teamId, categoryId string) bool
|
||||
SessionHasPermissionToCategory(session model.Session, userID, teamID, categoryId string) bool
|
||||
SessionHasPermissionToChannel(session model.Session, channelId string, permission *model.Permission) bool
|
||||
SessionHasPermissionToChannelByPost(session model.Session, postId string, permission *model.Permission) bool
|
||||
SessionHasPermissionToTeam(session model.Session, teamId string, permission *model.Permission) bool
|
||||
SessionHasPermissionToUser(session model.Session, userId string) bool
|
||||
SessionHasPermissionToUserOrBot(session model.Session, userId string) bool
|
||||
SessionHasPermissionToTeam(session model.Session, teamID string, permission *model.Permission) bool
|
||||
SessionHasPermissionToUser(session model.Session, userID string) bool
|
||||
SessionHasPermissionToUserOrBot(session model.Session, userID string) bool
|
||||
SetAcceptLanguage(s string)
|
||||
SetActiveChannel(userId string, channelId string) *model.AppError
|
||||
SetActiveChannel(userID string, channelId string) *model.AppError
|
||||
SetAutoResponderStatus(user *model.User, oldNotifyProps model.StringMap)
|
||||
SetContext(c context.Context)
|
||||
SetDefaultProfileImage(user *model.User) *model.AppError
|
||||
@@ -931,26 +931,26 @@ type AppIface interface {
|
||||
SetPluginKeyWithExpiry(pluginId string, key string, value []byte, expireInSeconds int64) *model.AppError
|
||||
SetPluginKeyWithOptions(pluginId string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
||||
SetPluginsEnvironment(pluginsEnvironment *plugin.Environment)
|
||||
SetProfileImage(userId string, imageData *multipart.FileHeader) *model.AppError
|
||||
SetProfileImageFromFile(userId string, file io.Reader) *model.AppError
|
||||
SetProfileImageFromMultiPartFile(userId string, file multipart.File) *model.AppError
|
||||
SetProfileImage(userID string, imageData *multipart.FileHeader) *model.AppError
|
||||
SetProfileImageFromFile(userID string, file io.Reader) *model.AppError
|
||||
SetProfileImageFromMultiPartFile(userID string, file multipart.File) *model.AppError
|
||||
SetRequestId(s string)
|
||||
SetSamlIdpCertificateFromMetadata(data []byte) *model.AppError
|
||||
SetSearchEngine(se *searchengine.Broker)
|
||||
SetServer(srv *Server)
|
||||
SetSession(s *model.Session)
|
||||
SetStatusAwayIfNeeded(userId string, manual bool)
|
||||
SetStatusDoNotDisturb(userId string)
|
||||
SetStatusOffline(userId string, manual bool)
|
||||
SetStatusOnline(userId string, manual bool)
|
||||
SetStatusOutOfOffice(userId string)
|
||||
SetStatusAwayIfNeeded(userID string, manual bool)
|
||||
SetStatusDoNotDisturb(userID string)
|
||||
SetStatusOffline(userID string, manual bool)
|
||||
SetStatusOnline(userID string, manual bool)
|
||||
SetStatusOutOfOffice(userID string)
|
||||
SetT(t goi18n.TranslateFunc)
|
||||
SetTeamIcon(teamId string, imageData *multipart.FileHeader) *model.AppError
|
||||
SetTeamIcon(teamID string, imageData *multipart.FileHeader) *model.AppError
|
||||
SetTeamIconFromFile(team *model.Team, file io.Reader) *model.AppError
|
||||
SetTeamIconFromMultiPartFile(teamId string, file multipart.File) *model.AppError
|
||||
SetTeamIconFromMultiPartFile(teamID string, file multipart.File) *model.AppError
|
||||
SetUserAgent(s string)
|
||||
SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model.AppError, *bytes.Buffer)
|
||||
SoftDeleteTeam(teamId string) *model.AppError
|
||||
SoftDeleteTeam(teamID string) *model.AppError
|
||||
Srv() *Server
|
||||
SubmitInteractiveDialog(request model.SubmitDialogRequest) (*model.SubmitDialogResponse, *model.AppError)
|
||||
SwitchEmailToLdap(email, password, code, ldapLoginId, ldapPassword string) (string, *model.AppError)
|
||||
@@ -964,72 +964,72 @@ type AppIface interface {
|
||||
TeamMembersToRemove(teamID *string) ([]*model.TeamMember, *model.AppError)
|
||||
TelemetryId() string
|
||||
TestElasticsearch(cfg *model.Config) *model.AppError
|
||||
TestEmail(userId string, cfg *model.Config) *model.AppError
|
||||
TestEmail(userID string, cfg *model.Config) *model.AppError
|
||||
TestFilesStoreConnection() *model.AppError
|
||||
TestFilesStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError
|
||||
TestLdap() *model.AppError
|
||||
TestSiteURL(siteURL string) *model.AppError
|
||||
Timezones() *timezones.Timezones
|
||||
ToggleMuteChannel(channelId, userId string) (*model.ChannelMember, *model.AppError)
|
||||
ToggleMuteChannel(channelId, userID string) (*model.ChannelMember, *model.AppError)
|
||||
TotalWebsocketConnections() int
|
||||
TriggerWebhook(payload *model.OutgoingWebhookPayload, hook *model.OutgoingWebhook, post *model.Post, channel *model.Channel)
|
||||
UnregisterPluginCommand(pluginId, teamId, trigger string)
|
||||
UnregisterPluginCommand(pluginId, teamID, trigger string)
|
||||
UnregisterPluginCommands(pluginId string)
|
||||
UpdateActive(user *model.User, active bool) (*model.User, *model.AppError)
|
||||
UpdateChannelLastViewedAt(channelIds []string, userId string) *model.AppError
|
||||
UpdateChannelMemberNotifyProps(data map[string]string, channelId string, userId string) (*model.ChannelMember, *model.AppError)
|
||||
UpdateChannelMemberRoles(channelId string, userId string, newRoles string) (*model.ChannelMember, *model.AppError)
|
||||
UpdateChannelMemberSchemeRoles(channelId string, userId string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.ChannelMember, *model.AppError)
|
||||
UpdateChannelLastViewedAt(channelIds []string, userID string) *model.AppError
|
||||
UpdateChannelMemberNotifyProps(data map[string]string, channelId string, userID string) (*model.ChannelMember, *model.AppError)
|
||||
UpdateChannelMemberRoles(channelId string, userID string, newRoles string) (*model.ChannelMember, *model.AppError)
|
||||
UpdateChannelMemberSchemeRoles(channelId string, userID string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.ChannelMember, *model.AppError)
|
||||
UpdateChannelPrivacy(oldChannel *model.Channel, user *model.User) (*model.Channel, *model.AppError)
|
||||
UpdateCommand(oldCmd, updatedCmd *model.Command) (*model.Command, *model.AppError)
|
||||
UpdateConfig(f func(*model.Config))
|
||||
UpdateEphemeralPost(userId string, post *model.Post) *model.Post
|
||||
UpdateEphemeralPost(userID string, post *model.Post) *model.Post
|
||||
UpdateGroup(group *model.Group) (*model.Group, *model.AppError)
|
||||
UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError)
|
||||
UpdateHashedPassword(user *model.User, newHashedPassword string) *model.AppError
|
||||
UpdateHashedPasswordByUserId(userId, newHashedPassword string) *model.AppError
|
||||
UpdateHashedPasswordByUserId(userID, newHashedPassword string) *model.AppError
|
||||
UpdateIncomingWebhook(oldHook, updatedHook *model.IncomingWebhook) (*model.IncomingWebhook, *model.AppError)
|
||||
UpdateLastActivityAtIfNeeded(session model.Session)
|
||||
UpdateMfa(activate bool, userId, token string) *model.AppError
|
||||
UpdateMobileAppBadge(userId string)
|
||||
UpdateMfa(activate bool, userID, token string) *model.AppError
|
||||
UpdateMobileAppBadge(userID string)
|
||||
UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provider einterfaces.OauthProvider, service string, tokenUser *model.User) *model.AppError
|
||||
UpdateOauthApp(oldApp, updatedApp *model.OAuthApp) (*model.OAuthApp, *model.AppError)
|
||||
UpdateOutgoingWebhook(oldHook, updatedHook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||
UpdatePassword(user *model.User, newPassword string) *model.AppError
|
||||
UpdatePasswordAsUser(userId, currentPassword, newPassword string) *model.AppError
|
||||
UpdatePasswordByUserIdSendEmail(userId, newPassword, method string) *model.AppError
|
||||
UpdatePasswordAsUser(userID, currentPassword, newPassword string) *model.AppError
|
||||
UpdatePasswordByUserIdSendEmail(userID, newPassword, method string) *model.AppError
|
||||
UpdatePasswordSendEmail(user *model.User, newPassword, method string) *model.AppError
|
||||
UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model.AppError)
|
||||
UpdatePreferences(userId string, preferences model.Preferences) *model.AppError
|
||||
UpdatePreferences(userID string, preferences model.Preferences) *model.AppError
|
||||
UpdateRole(role *model.Role) (*model.Role, *model.AppError)
|
||||
UpdateScheme(scheme *model.Scheme) (*model.Scheme, *model.AppError)
|
||||
UpdateSessionsIsGuest(userId string, isGuest bool)
|
||||
UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) *model.AppError
|
||||
UpdateSessionsIsGuest(userID string, isGuest bool)
|
||||
UpdateSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
UpdateSidebarCategoryOrder(userID, teamID string, categoryOrder []string) *model.AppError
|
||||
UpdateTeam(team *model.Team) (*model.Team, *model.AppError)
|
||||
UpdateTeamMemberRoles(teamId string, userId string, newRoles string) (*model.TeamMember, *model.AppError)
|
||||
UpdateTeamMemberSchemeRoles(teamId string, userId string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.TeamMember, *model.AppError)
|
||||
UpdateTeamPrivacy(teamId string, teamType string, allowOpenInvite bool) *model.AppError
|
||||
UpdateTeamMemberRoles(teamID string, userID string, newRoles string) (*model.TeamMember, *model.AppError)
|
||||
UpdateTeamMemberSchemeRoles(teamID string, userID string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.TeamMember, *model.AppError)
|
||||
UpdateTeamPrivacy(teamID string, teamType string, allowOpenInvite bool) *model.AppError
|
||||
UpdateTeamScheme(team *model.Team) (*model.Team, *model.AppError)
|
||||
UpdateThreadFollowForUser(userId, threadId string, state bool) *model.AppError
|
||||
UpdateThreadReadForUser(userId, teamId, threadId string, timestamp int64) *model.AppError
|
||||
UpdateThreadsReadForUser(userId, teamId string) *model.AppError
|
||||
UpdateThreadFollowForUser(userID, threadId string, state bool) *model.AppError
|
||||
UpdateThreadReadForUser(userID, teamID, threadId string, timestamp int64) *model.AppError
|
||||
UpdateThreadsReadForUser(userID, teamID string) *model.AppError
|
||||
UpdateUser(user *model.User, sendNotifications bool) (*model.User, *model.AppError)
|
||||
UpdateUserActive(userId string, active bool) *model.AppError
|
||||
UpdateUserActive(userID string, active bool) *model.AppError
|
||||
UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *model.AppError)
|
||||
UpdateUserAuth(userId string, userAuth *model.UserAuth) (*model.UserAuth, *model.AppError)
|
||||
UpdateUserNotifyProps(userId string, props map[string]string, sendNotifications bool) (*model.User, *model.AppError)
|
||||
UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError)
|
||||
UpdateUserAuth(userID string, userAuth *model.UserAuth) (*model.UserAuth, *model.AppError)
|
||||
UpdateUserNotifyProps(userID string, props map[string]string, sendNotifications bool) (*model.User, *model.AppError)
|
||||
UpdateUserRoles(userID string, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError)
|
||||
UploadData(us *model.UploadSession, rd io.Reader) (*model.FileInfo, *model.AppError)
|
||||
UploadEmojiImage(id string, imageData *multipart.FileHeader) *model.AppError
|
||||
UploadMultipartFiles(teamId string, channelId string, userId string, fileHeaders []*multipart.FileHeader, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError)
|
||||
UploadMultipartFiles(teamID string, channelId string, userID string, fileHeaders []*multipart.FileHeader, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError)
|
||||
UpsertGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError)
|
||||
UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError)
|
||||
UserAgent() string
|
||||
UserCanSeeOtherUser(userId string, otherUserId string) (bool, *model.AppError)
|
||||
UserCanSeeOtherUser(userID string, otherUserId string) (bool, *model.AppError)
|
||||
VerifyEmailFromToken(userSuppliedTokenString string) *model.AppError
|
||||
VerifyUserEmail(userId, email string) *model.AppError
|
||||
ViewChannel(view *model.ChannelView, userId string, currentSessionId string) (map[string]int64, *model.AppError)
|
||||
WaitForChannelMembership(channelId string, userId string)
|
||||
VerifyUserEmail(userID, email string) *model.AppError
|
||||
ViewChannel(view *model.ChannelView, userID string, currentSessionId string) (map[string]int64, *model.AppError)
|
||||
WaitForChannelMembership(channelId string, userID string)
|
||||
WriteFile(fr io.Reader, path string) (int64, *model.AppError)
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ var (
|
||||
LevelCLI = mlog.LvlAuditCLI
|
||||
)
|
||||
|
||||
func (a *App) GetAudits(userId string, limit int) (model.Audits, *model.AppError) {
|
||||
audits, err := a.Srv().Store.Audit().Get(userId, 0, limit)
|
||||
func (a *App) GetAudits(userID string, limit int) (model.Audits, *model.AppError) {
|
||||
audits, err := a.Srv().Store.Audit().Get(userID, 0, limit)
|
||||
if err != nil {
|
||||
var outErr *store.ErrOutOfBounds
|
||||
switch {
|
||||
@@ -46,8 +46,8 @@ func (a *App) GetAudits(userId string, limit int) (model.Audits, *model.AppError
|
||||
return audits, nil
|
||||
}
|
||||
|
||||
func (a *App) GetAuditsPage(userId string, page int, perPage int) (model.Audits, *model.AppError) {
|
||||
audits, err := a.Srv().Store.Audit().Get(userId, page*perPage, perPage)
|
||||
func (a *App) GetAuditsPage(userID string, page int, perPage int) (model.Audits, *model.AppError) {
|
||||
audits, err := a.Srv().Store.Audit().Get(userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
var outErr *store.ErrOutOfBounds
|
||||
switch {
|
||||
|
||||
@@ -36,15 +36,15 @@ func (a *App) SessionHasPermissionToAny(session model.Session, permissions []*mo
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *App) SessionHasPermissionToTeam(session model.Session, teamId string, permission *model.Permission) bool {
|
||||
if teamId == "" {
|
||||
func (a *App) SessionHasPermissionToTeam(session model.Session, teamID string, permission *model.Permission) bool {
|
||||
if teamID == "" {
|
||||
return false
|
||||
}
|
||||
if session.IsUnrestricted() {
|
||||
return true
|
||||
}
|
||||
|
||||
teamMember := session.GetTeamByTeamId(teamId)
|
||||
teamMember := session.GetTeamByTeamId(teamID)
|
||||
if teamMember != nil {
|
||||
if a.RolesGrantPermission(teamMember.GetRoles(), permission.Id) {
|
||||
return true
|
||||
@@ -104,23 +104,23 @@ func (a *App) SessionHasPermissionToChannelByPost(session model.Session, postId
|
||||
return a.SessionHasPermissionTo(session, permission)
|
||||
}
|
||||
|
||||
func (a *App) SessionHasPermissionToCategory(session model.Session, userId, teamId, categoryId string) bool {
|
||||
func (a *App) SessionHasPermissionToCategory(session model.Session, userID, teamID, categoryId string) bool {
|
||||
if a.SessionHasPermissionTo(session, model.PERMISSION_EDIT_OTHER_USERS) {
|
||||
return true
|
||||
}
|
||||
category, err := a.GetSidebarCategory(categoryId)
|
||||
return err == nil && category != nil && category.UserId == session.UserId && category.UserId == userId && category.TeamId == teamId
|
||||
return err == nil && category != nil && category.UserId == session.UserId && category.UserId == userID && category.TeamId == teamID
|
||||
}
|
||||
|
||||
func (a *App) SessionHasPermissionToUser(session model.Session, userId string) bool {
|
||||
if userId == "" {
|
||||
func (a *App) SessionHasPermissionToUser(session model.Session, userID string) bool {
|
||||
if userID == "" {
|
||||
return false
|
||||
}
|
||||
if session.IsUnrestricted() {
|
||||
return true
|
||||
}
|
||||
|
||||
if session.UserId == userId {
|
||||
if session.UserId == userID {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -131,15 +131,15 @@ func (a *App) SessionHasPermissionToUser(session model.Session, userId string) b
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *App) SessionHasPermissionToUserOrBot(session model.Session, userId string) bool {
|
||||
func (a *App) SessionHasPermissionToUserOrBot(session model.Session, userID string) bool {
|
||||
if session.IsUnrestricted() {
|
||||
return true
|
||||
}
|
||||
if a.SessionHasPermissionToUser(session, userId) {
|
||||
if a.SessionHasPermissionToUser(session, userID) {
|
||||
return true
|
||||
}
|
||||
|
||||
if err := a.SessionHasPermissionToManageBot(session, userId); err == nil {
|
||||
if err := a.SessionHasPermissionToManageBot(session, userID); err == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -157,11 +157,11 @@ func (a *App) HasPermissionTo(askingUserId string, permission *model.Permission)
|
||||
return a.RolesGrantPermission(roles, permission.Id)
|
||||
}
|
||||
|
||||
func (a *App) HasPermissionToTeam(askingUserId string, teamId string, permission *model.Permission) bool {
|
||||
if teamId == "" || askingUserId == "" {
|
||||
func (a *App) HasPermissionToTeam(askingUserId string, teamID string, permission *model.Permission) bool {
|
||||
if teamID == "" || askingUserId == "" {
|
||||
return false
|
||||
}
|
||||
teamMember, _ := a.GetTeamMember(teamId, askingUserId)
|
||||
teamMember, _ := a.GetTeamMember(teamID, askingUserId)
|
||||
if teamMember != nil && teamMember.DeleteAt == 0 {
|
||||
if a.RolesGrantPermission(teamMember.GetRoles(), permission.Id) {
|
||||
return true
|
||||
@@ -206,8 +206,8 @@ func (a *App) HasPermissionToChannelByPost(askingUserId string, postId string, p
|
||||
return a.HasPermissionTo(askingUserId, permission)
|
||||
}
|
||||
|
||||
func (a *App) HasPermissionToUser(askingUserId string, userId string) bool {
|
||||
if askingUserId == userId {
|
||||
func (a *App) HasPermissionToUser(askingUserId string, userID string) bool {
|
||||
if askingUserId == userID {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ func (a *App) SetAutoResponderStatus(user *model.User, oldNotifyProps model.Stri
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) DisableAutoResponder(userId string, asAdmin bool) *model.AppError {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) DisableAutoResponder(userID string, asAdmin bool) *model.AppError {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func (a *App) DisableAutoResponder(userId string, asAdmin bool) *model.AppError
|
||||
patch.NotifyProps = user.NotifyProps
|
||||
patch.NotifyProps[model.AUTO_RESPONDER_ACTIVE_NOTIFY_PROP] = "false"
|
||||
|
||||
_, err := a.PatchUser(userId, patch, asAdmin)
|
||||
_, err := a.PatchUser(userID, patch, asAdmin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
10
app/bot.go
10
app/bot.go
@@ -335,11 +335,11 @@ func (a *App) UpdateBotOwner(botUserId, newOwnerId string) (*model.Bot, *model.A
|
||||
}
|
||||
|
||||
// disableUserBots disables all bots owned by the given user.
|
||||
func (a *App) disableUserBots(userId string) *model.AppError {
|
||||
func (a *App) disableUserBots(userID string) *model.AppError {
|
||||
perPage := 20
|
||||
for {
|
||||
options := &model.BotGetOptions{
|
||||
OwnerId: userId,
|
||||
OwnerId: userID,
|
||||
IncludeDeleted: false,
|
||||
OnlyOrphaned: false,
|
||||
Page: 0,
|
||||
@@ -368,10 +368,10 @@ func (a *App) disableUserBots(userId string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) notifySysadminsBotOwnerDeactivated(userId string) *model.AppError {
|
||||
func (a *App) notifySysadminsBotOwnerDeactivated(userID string) *model.AppError {
|
||||
perPage := 25
|
||||
botOptions := &model.BotGetOptions{
|
||||
OwnerId: userId,
|
||||
OwnerId: userID,
|
||||
IncludeDeleted: false,
|
||||
OnlyOrphaned: false,
|
||||
Page: 0,
|
||||
@@ -423,7 +423,7 @@ func (a *App) notifySysadminsBotOwnerDeactivated(userId string) *model.AppError
|
||||
}
|
||||
|
||||
// user being disabled
|
||||
user, err := a.GetUser(userId)
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
332
app/channel.go
332
app/channel.go
@@ -63,7 +63,7 @@ func (a *App) DefaultChannelNames() []string {
|
||||
return names
|
||||
}
|
||||
|
||||
func (a *App) JoinDefaultChannels(teamId string, user *model.User, shouldBeAdmin bool, userRequestorId string) *model.AppError {
|
||||
func (a *App) JoinDefaultChannels(teamID string, user *model.User, shouldBeAdmin bool, userRequestorId string) *model.AppError {
|
||||
var requestor *model.User
|
||||
var nErr error
|
||||
if userRequestorId != "" {
|
||||
@@ -81,7 +81,7 @@ func (a *App) JoinDefaultChannels(teamId string, user *model.User, shouldBeAdmin
|
||||
|
||||
var err *model.AppError
|
||||
for _, channelName := range a.DefaultChannelNames() {
|
||||
channel, channelErr := a.Srv().Store.Channel().GetByName(teamId, channelName, true)
|
||||
channel, channelErr := a.Srv().Store.Channel().GetByName(teamID, channelName, true)
|
||||
if channelErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -170,7 +170,7 @@ func (a *App) postJoinMessageForDefaultChannel(user *model.User, requestor *mode
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) CreateChannelWithUser(channel *model.Channel, userId string) (*model.Channel, *model.AppError) {
|
||||
func (a *App) CreateChannelWithUser(channel *model.Channel, userID string) (*model.Channel, *model.AppError) {
|
||||
if channel.IsGroupOrDirect() {
|
||||
return nil, model.NewAppError("CreateChannelWithUser", "api.channel.create_channel.direct_channel.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -189,7 +189,7 @@ func (a *App) CreateChannelWithUser(channel *model.Channel, userId string) (*mod
|
||||
return nil, model.NewAppError("CreateChannelWithUser", "api.channel.create_channel.max_channel_limit.app_error", map[string]interface{}{"MaxChannelsPerTeam": *a.Config().TeamSettings.MaxChannelsPerTeam}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
channel.CreatorId = userId
|
||||
channel.CreatorId = userID
|
||||
|
||||
rchannel, err := a.CreateChannel(channel, true)
|
||||
if err != nil {
|
||||
@@ -197,13 +197,13 @@ func (a *App) CreateChannelWithUser(channel *model.Channel, userId string) (*mod
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if user, err = a.GetUser(userId); err != nil {
|
||||
if user, err = a.GetUser(userID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.postJoinChannelMessage(user, channel)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_CREATED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_CREATED, "", "", userID, nil)
|
||||
message.Add("channel_id", channel.Id)
|
||||
message.Add("team_id", channel.TeamId)
|
||||
a.Publish(message)
|
||||
@@ -320,13 +320,13 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
|
||||
return sc, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOrCreateDirectChannel(userId, otherUserId string) (*model.Channel, *model.AppError) {
|
||||
channel, nErr := a.Srv().Store.Channel().GetByName("", model.GetDMNameFromIds(userId, otherUserId), true)
|
||||
func (a *App) GetOrCreateDirectChannel(userID, otherUserId string) (*model.Channel, *model.AppError) {
|
||||
channel, nErr := a.Srv().Store.Channel().GetByName("", model.GetDMNameFromIds(userID, otherUserId), true)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
if errors.As(nErr, &nfErr) {
|
||||
var err *model.AppError
|
||||
channel, err = a.createDirectChannel(userId, otherUserId)
|
||||
channel, err = a.createDirectChannel(userID, otherUserId)
|
||||
if err != nil {
|
||||
if err.Id == store.ChannelExistsError {
|
||||
return channel, nil
|
||||
@@ -334,9 +334,9 @@ func (a *App) GetOrCreateDirectChannel(userId, otherUserId string) (*model.Chann
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.WaitForChannelMembership(channel.Id, userId)
|
||||
a.WaitForChannelMembership(channel.Id, userID)
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(userID)
|
||||
a.InvalidateCacheForUser(otherUserId)
|
||||
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
@@ -360,11 +360,11 @@ func (a *App) GetOrCreateDirectChannel(userId, otherUserId string) (*model.Chann
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Channel, *model.AppError) {
|
||||
func (a *App) createDirectChannel(userID string, otherUserId string) (*model.Channel, *model.AppError) {
|
||||
uc1 := make(chan store.StoreResult, 1)
|
||||
uc2 := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
uc1 <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uc1)
|
||||
}()
|
||||
@@ -376,7 +376,7 @@ func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Cha
|
||||
|
||||
result := <-uc1
|
||||
if result.NErr != nil {
|
||||
return nil, model.NewAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, userId, http.StatusBadRequest)
|
||||
return nil, model.NewAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, userID, http.StatusBadRequest)
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
@@ -418,10 +418,10 @@ func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Cha
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.ChannelMemberHistory().LogJoinEvent(userId, channel.Id, model.GetMillis()); err != nil {
|
||||
if err := a.Srv().Store.ChannelMemberHistory().LogJoinEvent(userID, channel.Id, model.GetMillis()); err != nil {
|
||||
return nil, model.NewAppError("CreateDirectChannel", "app.channel_member_history.log_join_event.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if userId != otherUserId {
|
||||
if userID != otherUserId {
|
||||
if err := a.Srv().Store.ChannelMemberHistory().LogJoinEvent(otherUserId, channel.Id, model.GetMillis()); err != nil {
|
||||
return nil, model.NewAppError("CreateDirectChannel", "app.channel_member_history.log_join_event.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -430,7 +430,7 @@ func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Cha
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) WaitForChannelMembership(channelId string, userId string) {
|
||||
func (a *App) WaitForChannelMembership(channelId string, userID string) {
|
||||
if len(a.Config().SqlSettings.DataSourceReplicas) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -441,7 +441,7 @@ func (a *App) WaitForChannelMembership(channelId string, userId string) {
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
_, err := a.Srv().Store.Channel().GetMember(channelId, userId)
|
||||
_, err := a.Srv().Store.Channel().GetMember(channelId, userID)
|
||||
|
||||
// If the membership was found then return
|
||||
if err == nil {
|
||||
@@ -455,11 +455,11 @@ func (a *App) WaitForChannelMembership(channelId string, userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
mlog.Error("WaitForChannelMembership giving up", mlog.String("channel_id", channelId), mlog.String("user_id", userId))
|
||||
mlog.Error("WaitForChannelMembership giving up", mlog.String("channel_id", channelId), mlog.String("user_id", userID))
|
||||
}
|
||||
|
||||
func (a *App) CreateGroupChannel(userIds []string, creatorId string) (*model.Channel, *model.AppError) {
|
||||
channel, err := a.createGroupChannel(userIds)
|
||||
func (a *App) CreateGroupChannel(userIDs []string, creatorId string) (*model.Channel, *model.AppError) {
|
||||
channel, err := a.createGroupChannel(userIDs)
|
||||
if err != nil {
|
||||
if err.Id == store.ChannelExistsError {
|
||||
return channel, nil
|
||||
@@ -467,37 +467,37 @@ func (a *App) CreateGroupChannel(userIds []string, creatorId string) (*model.Cha
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, userId := range userIds {
|
||||
if userId == creatorId {
|
||||
for _, userID := range userIDs {
|
||||
if userID == creatorId {
|
||||
a.WaitForChannelMembership(channel.Id, creatorId)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(userID)
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_GROUP_ADDED, "", channel.Id, "", nil)
|
||||
message.Add("teammate_ids", model.ArrayToJson(userIds))
|
||||
message.Add("teammate_ids", model.ArrayToJson(userIDs))
|
||||
a.Publish(message)
|
||||
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) createGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
|
||||
if len(userIds) > model.CHANNEL_GROUP_MAX_USERS || len(userIds) < model.CHANNEL_GROUP_MIN_USERS {
|
||||
func (a *App) createGroupChannel(userIDs []string) (*model.Channel, *model.AppError) {
|
||||
if len(userIDs) > model.CHANNEL_GROUP_MAX_USERS || len(userIDs) < model.CHANNEL_GROUP_MIN_USERS {
|
||||
return nil, model.NewAppError("CreateGroupChannel", "api.channel.create_group.bad_size.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIds, nil, true)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIDs, nil, true)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("createGroupChannel", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if len(users) != len(userIds) {
|
||||
return nil, model.NewAppError("CreateGroupChannel", "api.channel.create_group.bad_user.app_error", nil, "user_ids="+model.ArrayToJson(userIds), http.StatusBadRequest)
|
||||
if len(users) != len(userIDs) {
|
||||
return nil, model.NewAppError("CreateGroupChannel", "api.channel.create_group.bad_user.app_error", nil, "user_ids="+model.ArrayToJson(userIDs), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
group := &model.Channel{
|
||||
Name: model.GetGroupNameFromUserIds(userIds),
|
||||
Name: model.GetGroupNameFromUserIds(userIDs),
|
||||
DisplayName: model.GetGroupDisplayNameFromUsers(users, true),
|
||||
Type: model.CHANNEL_GROUP,
|
||||
}
|
||||
@@ -561,21 +561,21 @@ func (a *App) createGroupChannel(userIds []string) (*model.Channel, *model.AppEr
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
|
||||
if len(userIds) > model.CHANNEL_GROUP_MAX_USERS || len(userIds) < model.CHANNEL_GROUP_MIN_USERS {
|
||||
func (a *App) GetGroupChannel(userIDs []string) (*model.Channel, *model.AppError) {
|
||||
if len(userIDs) > model.CHANNEL_GROUP_MAX_USERS || len(userIDs) < model.CHANNEL_GROUP_MIN_USERS {
|
||||
return nil, model.NewAppError("GetGroupChannel", "api.channel.create_group.bad_size.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIds, nil, true)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIDs, nil, true)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetGroupChannel", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if len(users) != len(userIds) {
|
||||
return nil, model.NewAppError("GetGroupChannel", "api.channel.create_group.bad_user.app_error", nil, "user_ids="+model.ArrayToJson(userIds), http.StatusBadRequest)
|
||||
if len(users) != len(userIDs) {
|
||||
return nil, model.NewAppError("GetGroupChannel", "api.channel.create_group.bad_user.app_error", nil, "user_ids="+model.ArrayToJson(userIDs), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
channel, appErr := a.GetChannelByName(model.GetGroupNameFromUserIds(userIds), "", true)
|
||||
channel, appErr := a.GetChannelByName(model.GetGroupNameFromUserIds(userIDs), "", true)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
@@ -697,7 +697,7 @@ func (a *App) postChannelPrivacyMessage(user *model.User, channel *model.Channel
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RestoreChannel(channel *model.Channel, userId string) (*model.Channel, *model.AppError) {
|
||||
func (a *App) RestoreChannel(channel *model.Channel, userID string) (*model.Channel, *model.AppError) {
|
||||
if channel.DeleteAt == 0 {
|
||||
return nil, model.NewAppError("restoreChannel", "api.channel.restore_channel.restored.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -712,7 +712,7 @@ func (a *App) RestoreChannel(channel *model.Channel, userId string) (*model.Chan
|
||||
message.Add("channel_id", channel.Id)
|
||||
a.Publish(message)
|
||||
|
||||
user, nErr := a.Srv().Store.User().Get(userId)
|
||||
user, nErr := a.Srv().Store.User().Get(userID)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -730,7 +730,7 @@ func (a *App) RestoreChannel(channel *model.Channel, userId string) (*model.Chan
|
||||
ChannelId: channel.Id,
|
||||
Message: T("api.channel.restore_channel.unarchived", map[string]interface{}{"Username": user.Username}),
|
||||
Type: model.POST_CHANNEL_RESTORED,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Props: model.StringInterface{
|
||||
"username": user.Username,
|
||||
},
|
||||
@@ -744,7 +744,7 @@ func (a *App) RestoreChannel(channel *model.Channel, userId string) (*model.Chan
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) PatchChannel(channel *model.Channel, patch *model.ChannelPatch, userId string) (*model.Channel, *model.AppError) {
|
||||
func (a *App) PatchChannel(channel *model.Channel, patch *model.ChannelPatch, userID string) (*model.Channel, *model.AppError) {
|
||||
oldChannelDisplayName := channel.DisplayName
|
||||
oldChannelHeader := channel.Header
|
||||
oldChannelPurpose := channel.Purpose
|
||||
@@ -756,19 +756,19 @@ func (a *App) PatchChannel(channel *model.Channel, patch *model.ChannelPatch, us
|
||||
}
|
||||
|
||||
if oldChannelDisplayName != channel.DisplayName {
|
||||
if err = a.PostUpdateChannelDisplayNameMessage(userId, channel, oldChannelDisplayName, channel.DisplayName); err != nil {
|
||||
if err = a.PostUpdateChannelDisplayNameMessage(userID, channel, oldChannelDisplayName, channel.DisplayName); err != nil {
|
||||
mlog.Warn(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if channel.Header != oldChannelHeader {
|
||||
if err = a.PostUpdateChannelHeaderMessage(userId, channel, oldChannelHeader, channel.Header); err != nil {
|
||||
if err = a.PostUpdateChannelHeaderMessage(userID, channel, oldChannelHeader, channel.Header); err != nil {
|
||||
mlog.Warn(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if channel.Purpose != oldChannelPurpose {
|
||||
if err = a.PostUpdateChannelPurposeMessage(userId, channel, oldChannelPurpose, channel.Purpose); err != nil {
|
||||
if err = a.PostUpdateChannelPurposeMessage(userID, channel, oldChannelPurpose, channel.Purpose); err != nil {
|
||||
mlog.Warn(err.Error())
|
||||
}
|
||||
}
|
||||
@@ -801,8 +801,8 @@ func (a *App) GetSchemeRolesForChannel(channelId string) (guestRoleName, userRol
|
||||
}
|
||||
|
||||
// GetTeamSchemeChannelRoles Checks if a team has an override scheme and returns the scheme channel role names or default channel role names.
|
||||
func (a *App) GetTeamSchemeChannelRoles(teamId string) (guestRoleName, userRoleName, adminRoleName string, err *model.AppError) {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) GetTeamSchemeChannelRoles(teamID string) (guestRoleName, userRoleName, adminRoleName string, err *model.AppError) {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -1040,10 +1040,10 @@ func buildChannelModerations(channelType string, memberRole *model.Role, guestRo
|
||||
return channelModerations
|
||||
}
|
||||
|
||||
func (a *App) UpdateChannelMemberRoles(channelId string, userId string, newRoles string) (*model.ChannelMember, *model.AppError) {
|
||||
func (a *App) UpdateChannelMemberRoles(channelId string, userID string, newRoles string) (*model.ChannelMember, *model.AppError) {
|
||||
var member *model.ChannelMember
|
||||
var err *model.AppError
|
||||
if member, err = a.GetChannelMember(channelId, userId); err != nil {
|
||||
if member, err = a.GetChannelMember(channelId, userID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1099,8 +1099,8 @@ func (a *App) UpdateChannelMemberRoles(channelId string, userId string, newRoles
|
||||
return a.updateChannelMember(member)
|
||||
}
|
||||
|
||||
func (a *App) UpdateChannelMemberSchemeRoles(channelId string, userId string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.ChannelMember, *model.AppError) {
|
||||
member, err := a.GetChannelMember(channelId, userId)
|
||||
func (a *App) UpdateChannelMemberSchemeRoles(channelId string, userID string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.ChannelMember, *model.AppError) {
|
||||
member, err := a.GetChannelMember(channelId, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1121,10 +1121,10 @@ func (a *App) UpdateChannelMemberSchemeRoles(channelId string, userId string, is
|
||||
return a.updateChannelMember(member)
|
||||
}
|
||||
|
||||
func (a *App) UpdateChannelMemberNotifyProps(data map[string]string, channelId string, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
func (a *App) UpdateChannelMemberNotifyProps(data map[string]string, channelId string, userID string) (*model.ChannelMember, *model.AppError) {
|
||||
var member *model.ChannelMember
|
||||
var err *model.AppError
|
||||
if member, err = a.GetChannelMember(channelId, userId); err != nil {
|
||||
if member, err = a.GetChannelMember(channelId, userID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1184,7 +1184,7 @@ func (a *App) updateChannelMember(member *model.ChannelMember) (*model.ChannelMe
|
||||
return member, nil
|
||||
}
|
||||
|
||||
func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppError {
|
||||
func (a *App) DeleteChannel(channel *model.Channel, userID string) *model.AppError {
|
||||
ihc := make(chan store.StoreResult, 1)
|
||||
ohc := make(chan store.StoreResult, 1)
|
||||
|
||||
@@ -1201,9 +1201,9 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
||||
}()
|
||||
|
||||
var user *model.User
|
||||
if userId != "" {
|
||||
if userID != "" {
|
||||
var nErr error
|
||||
user, nErr = a.Srv().Store.User().Get(userId)
|
||||
user, nErr = a.Srv().Store.User().Get(userID)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1245,7 +1245,7 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
||||
ChannelId: channel.Id,
|
||||
Message: fmt.Sprintf(T("api.channel.delete_channel.archived"), user.Username),
|
||||
Type: model.POST_CHANNEL_DELETED,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Props: model.StringInterface{
|
||||
"username": user.Username,
|
||||
},
|
||||
@@ -1372,8 +1372,8 @@ func (a *App) AddUserToChannel(user *model.User, channel *model.Channel) (*model
|
||||
return newMember, nil
|
||||
}
|
||||
|
||||
func (a *App) AddChannelMember(userId string, channel *model.Channel, userRequestorId string, postRootId string) (*model.ChannelMember, *model.AppError) {
|
||||
if member, err := a.Srv().Store.Channel().GetMember(channel.Id, userId); err != nil {
|
||||
func (a *App) AddChannelMember(userID string, channel *model.Channel, userRequestorId string, postRootId string) (*model.ChannelMember, *model.AppError) {
|
||||
if member, err := a.Srv().Store.Channel().GetMember(channel.Id, userID); err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
if !errors.As(err, &nfErr) {
|
||||
return nil, model.NewAppError("AddChannelMember", "app.channel.get_member.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -1385,7 +1385,7 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
|
||||
var user *model.User
|
||||
var err *model.AppError
|
||||
|
||||
if user, err = a.GetUser(userId); err != nil {
|
||||
if user, err = a.GetUser(userID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1411,7 +1411,7 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
|
||||
})
|
||||
}
|
||||
|
||||
if userRequestorId == "" || userId == userRequestorId {
|
||||
if userRequestorId == "" || userID == userRequestorId {
|
||||
a.postJoinChannelMessage(user, channel)
|
||||
} else {
|
||||
a.Srv().Go(func() {
|
||||
@@ -1422,12 +1422,12 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
|
||||
return cm, nil
|
||||
}
|
||||
|
||||
func (a *App) AddDirectChannels(teamId string, user *model.User) *model.AppError {
|
||||
func (a *App) AddDirectChannels(teamID string, user *model.User) *model.AppError {
|
||||
var profiles []*model.User
|
||||
options := &model.UserGetOptions{InTeamId: teamId, Page: 0, PerPage: 100}
|
||||
options := &model.UserGetOptions{InTeamId: teamID, Page: 0, PerPage: 100}
|
||||
profiles, err := a.Srv().Store.User().GetProfiles(options)
|
||||
if err != nil {
|
||||
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamId, "Error": err.Error()}, "", http.StatusInternalServerError)
|
||||
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
var preferences model.Preferences
|
||||
@@ -1452,14 +1452,14 @@ func (a *App) AddDirectChannels(teamId string, user *model.User) *model.AppError
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Preference().Save(&preferences); err != nil {
|
||||
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamId, "Error": err.Error()}, "", http.StatusInternalServerError)
|
||||
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) PostUpdateChannelHeaderMessage(userId string, channel *model.Channel, oldChannelHeader, newChannelHeader string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
func (a *App) PostUpdateChannelHeaderMessage(userID string, channel *model.Channel, oldChannelHeader, newChannelHeader string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
if err != nil {
|
||||
return model.NewAppError("PostUpdateChannelHeaderMessage", "api.channel.post_update_channel_header_message_and_forget.retrieve_user.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -1477,7 +1477,7 @@ func (a *App) PostUpdateChannelHeaderMessage(userId string, channel *model.Chann
|
||||
ChannelId: channel.Id,
|
||||
Message: message,
|
||||
Type: model.POST_HEADER_CHANGE,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Props: model.StringInterface{
|
||||
"username": user.Username,
|
||||
"old_header": oldChannelHeader,
|
||||
@@ -1492,8 +1492,8 @@ func (a *App) PostUpdateChannelHeaderMessage(userId string, channel *model.Chann
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) PostUpdateChannelPurposeMessage(userId string, channel *model.Channel, oldChannelPurpose string, newChannelPurpose string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
func (a *App) PostUpdateChannelPurposeMessage(userID string, channel *model.Channel, oldChannelPurpose string, newChannelPurpose string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
if err != nil {
|
||||
return model.NewAppError("PostUpdateChannelPurposeMessage", "app.channel.post_update_channel_purpose_message.retrieve_user.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -1511,7 +1511,7 @@ func (a *App) PostUpdateChannelPurposeMessage(userId string, channel *model.Chan
|
||||
ChannelId: channel.Id,
|
||||
Message: message,
|
||||
Type: model.POST_PURPOSE_CHANGE,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Props: model.StringInterface{
|
||||
"username": user.Username,
|
||||
"old_purpose": oldChannelPurpose,
|
||||
@@ -1525,8 +1525,8 @@ func (a *App) PostUpdateChannelPurposeMessage(userId string, channel *model.Chan
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) PostUpdateChannelDisplayNameMessage(userId string, channel *model.Channel, oldChannelDisplayName, newChannelDisplayName string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
func (a *App) PostUpdateChannelDisplayNameMessage(userID string, channel *model.Channel, oldChannelDisplayName, newChannelDisplayName string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
if err != nil {
|
||||
return model.NewAppError("PostUpdateChannelDisplayNameMessage", "api.channel.post_update_channel_displayname_message_and_forget.retrieve_user.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -1537,7 +1537,7 @@ func (a *App) PostUpdateChannelDisplayNameMessage(userId string, channel *model.
|
||||
ChannelId: channel.Id,
|
||||
Message: message,
|
||||
Type: model.POST_DISPLAYNAME_CHANGE,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Props: model.StringInterface{
|
||||
"username": user.Username,
|
||||
"old_displayname": oldChannelDisplayName,
|
||||
@@ -1566,14 +1566,14 @@ func (a *App) GetChannel(channelId string) (*model.Channel, *model.AppError) {
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelByName(channelName, teamId string, includeDeleted bool) (*model.Channel, *model.AppError) {
|
||||
func (a *App) GetChannelByName(channelName, teamID string, includeDeleted bool) (*model.Channel, *model.AppError) {
|
||||
var channel *model.Channel
|
||||
var err error
|
||||
|
||||
if includeDeleted {
|
||||
channel, err = a.Srv().Store.Channel().GetByNameIncludeDeleted(teamId, channelName, false)
|
||||
channel, err = a.Srv().Store.Channel().GetByNameIncludeDeleted(teamID, channelName, false)
|
||||
} else {
|
||||
channel, err = a.Srv().Store.Channel().GetByName(teamId, channelName, false)
|
||||
channel, err = a.Srv().Store.Channel().GetByName(teamID, channelName, false)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -1589,8 +1589,8 @@ func (a *App) GetChannelByName(channelName, teamId string, includeDeleted bool)
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelsByNames(channelNames []string, teamId string) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := a.Srv().Store.Channel().GetByNames(teamId, channelNames, true)
|
||||
func (a *App) GetChannelsByNames(channelNames []string, teamID string) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := a.Srv().Store.Channel().GetByNames(teamID, channelNames, true)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelsByNames", "app.channel.get_by_name.existing.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1633,8 +1633,8 @@ func (a *App) GetChannelByNameForTeamName(channelName, teamName string, includeD
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelsForUser(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetChannels(teamId, userId, includeDeleted, lastDeleteAt)
|
||||
func (a *App) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetChannels(teamID, userID, includeDeleted, lastDeleteAt)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1682,8 +1682,8 @@ func (a *App) GetAllChannelsCount(opts model.ChannelSearchOpts) (int64, *model.A
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (a *App) GetDeletedChannels(teamId string, offset int, limit int, userId string) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetDeleted(teamId, offset, limit, userId)
|
||||
func (a *App) GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetDeleted(teamID, offset, limit, userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1697,16 +1697,16 @@ func (a *App) GetDeletedChannels(teamId string, offset int, limit int, userId st
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelsUserNotIn(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
channels, err := a.Srv().Store.Channel().GetMoreChannels(teamId, userId, offset, limit)
|
||||
func (a *App) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
channels, err := a.Srv().Store.Channel().GetMoreChannels(teamID, userID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelsUserNotIn", "app.channel.get_more_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return channels, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPublicChannelsByIdsForTeam(teamId, channelIds)
|
||||
func (a *App) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPublicChannelsByIdsForTeam(teamID, channelIds)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1720,8 +1720,8 @@ func (a *App) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string)
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPublicChannelsForTeam(teamId, offset, limit)
|
||||
func (a *App) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPublicChannelsForTeam(teamID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPublicChannelsForTeam", "app.channel.get_public_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1729,8 +1729,8 @@ func (a *App) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*m
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPrivateChannelsForTeam(teamId, offset, limit)
|
||||
func (a *App) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPrivateChannelsForTeam(teamID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPrivateChannelsForTeam", "app.channel.get_private_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1738,8 +1738,8 @@ func (a *App) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
channelMember, err := a.Srv().Store.Channel().GetMember(channelId, userId)
|
||||
func (a *App) GetChannelMember(channelId string, userID string) (*model.ChannelMember, *model.AppError) {
|
||||
channelMember, err := a.Srv().Store.Channel().GetMember(channelId, userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1779,8 +1779,8 @@ func (a *App) GetChannelMembersTimezones(channelId string) ([]string, *model.App
|
||||
return model.RemoveDuplicateStrings(timezones), nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) {
|
||||
members, err := a.Srv().Store.Channel().GetMembersByIds(channelId, userIds)
|
||||
func (a *App) GetChannelMembersByIds(channelId string, userIDs []string) (*model.ChannelMembers, *model.AppError) {
|
||||
members, err := a.Srv().Store.Channel().GetMembersByIds(channelId, userIDs)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelMembersByIds", "app.channel.get_members_by_ids.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1788,8 +1788,8 @@ func (a *App) GetChannelMembersByIds(channelId string, userIds []string) (*model
|
||||
return members, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError) {
|
||||
channelMembers, err := a.Srv().Store.Channel().GetMembersForUser(teamId, userId)
|
||||
func (a *App) GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError) {
|
||||
channelMembers, err := a.Srv().Store.Channel().GetMembersForUser(teamID, userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelMembersForUser", "app.channel.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1797,8 +1797,8 @@ func (a *App) GetChannelMembersForUser(teamId string, userId string) (*model.Cha
|
||||
return channelMembers, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMembersForUserWithPagination(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
||||
m, err := a.Srv().Store.Channel().GetMembersForUserWithPagination(teamId, userId, page, perPage)
|
||||
func (a *App) GetChannelMembersForUserWithPagination(teamID, userID string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
||||
m, err := a.Srv().Store.Channel().GetMembersForUserWithPagination(teamID, userID, page, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelMembersForUserWithPagination", "app.channel.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1840,8 +1840,8 @@ func (a *App) GetChannelPinnedPostCount(channelId string) (int64, *model.AppErro
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError) {
|
||||
counts, err := a.Srv().Store.Channel().GetChannelCounts(teamId, userId)
|
||||
func (a *App) GetChannelCounts(teamID string, userID string) (*model.ChannelCounts, *model.AppError) {
|
||||
counts, err := a.Srv().Store.Channel().GetChannelCounts(teamID, userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlChannelStore.GetChannelCounts", "app.channel.get_channel_counts.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1849,8 +1849,8 @@ func (a *App) GetChannelCounts(teamId string, userId string) (*model.ChannelCoun
|
||||
return counts, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError) {
|
||||
channelUnread, err := a.Srv().Store.Channel().GetChannelUnread(channelId, userId)
|
||||
func (a *App) GetChannelUnread(channelId, userID string) (*model.ChannelUnread, *model.AppError) {
|
||||
channelUnread, err := a.Srv().Store.Channel().GetChannelUnread(channelId, userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1868,16 +1868,16 @@ func (a *App) GetChannelUnread(channelId, userId string) (*model.ChannelUnread,
|
||||
return channelUnread, nil
|
||||
}
|
||||
|
||||
func (a *App) JoinChannel(channel *model.Channel, userId string) *model.AppError {
|
||||
func (a *App) JoinChannel(channel *model.Channel, userID string) *model.AppError {
|
||||
userChan := make(chan store.StoreResult, 1)
|
||||
memberChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
userChan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(userChan)
|
||||
}()
|
||||
go func() {
|
||||
member, err := a.Srv().Store.Channel().GetMember(channel.Id, userId)
|
||||
member, err := a.Srv().Store.Channel().GetMember(channel.Id, userID)
|
||||
memberChan <- store.StoreResult{Data: member, NErr: err}
|
||||
close(memberChan)
|
||||
}()
|
||||
@@ -1971,7 +1971,7 @@ func (a *App) postJoinTeamMessage(user *model.User, channel *model.Channel) *mod
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) LeaveChannel(channelId string, userId string) *model.AppError {
|
||||
func (a *App) LeaveChannel(channelId string, userID string) *model.AppError {
|
||||
sc := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
channel, err := a.Srv().Store.Channel().Get(channelId, true)
|
||||
@@ -1981,7 +1981,7 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError {
|
||||
|
||||
uc := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
uc <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uc)
|
||||
}()
|
||||
@@ -2032,7 +2032,7 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.removeUserFromChannel(userId, userId, channel); err != nil {
|
||||
if err := a.removeUserFromChannel(userID, userID, channel); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2142,8 +2142,8 @@ func (a *App) postRemoveFromChannelMessage(removerUserId string, removedUser *mo
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
|
||||
user, nErr := a.Srv().Store.User().Get(userIdToRemove)
|
||||
func (a *App) removeUserFromChannel(userIDToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
|
||||
user, nErr := a.Srv().Store.User().Get(userIDToRemove)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -2161,8 +2161,8 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
||||
}
|
||||
}
|
||||
|
||||
if channel.IsGroupConstrained() && userIdToRemove != removerUserId && !user.IsBot {
|
||||
nonMembers, err := a.FilterNonGroupChannelMembers([]string{userIdToRemove}, channel)
|
||||
if channel.IsGroupConstrained() && userIDToRemove != removerUserId && !user.IsBot {
|
||||
nonMembers, err := a.FilterNonGroupChannelMembers([]string{userIDToRemove}, channel)
|
||||
if err != nil {
|
||||
return model.NewAppError("removeUserFromChannel", "api.channel.remove_user_from_channel.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2171,25 +2171,25 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
||||
}
|
||||
}
|
||||
|
||||
cm, err := a.GetChannelMember(channel.Id, userIdToRemove)
|
||||
cm, err := a.GetChannelMember(channel.Id, userIDToRemove)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Channel().RemoveMember(channel.Id, userIdToRemove); err != nil {
|
||||
if err := a.Srv().Store.Channel().RemoveMember(channel.Id, userIDToRemove); err != nil {
|
||||
return model.NewAppError("removeUserFromChannel", "app.channel.remove_member.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if err := a.Srv().Store.ChannelMemberHistory().LogLeaveEvent(userIdToRemove, channel.Id, model.GetMillis()); err != nil {
|
||||
if err := a.Srv().Store.ChannelMemberHistory().LogLeaveEvent(userIDToRemove, channel.Id, model.GetMillis()); err != nil {
|
||||
return model.NewAppError("removeUserFromChannel", "app.channel_member_history.log_leave_event.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if isGuest {
|
||||
currentMembers, err := a.GetChannelMembersForUser(channel.TeamId, userIdToRemove)
|
||||
currentMembers, err := a.GetChannelMembersForUser(channel.TeamId, userIDToRemove)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(*currentMembers) == 0 {
|
||||
teamMember, err := a.GetTeamMember(channel.TeamId, userIdToRemove)
|
||||
teamMember, err := a.GetTeamMember(channel.TeamId, userIDToRemove)
|
||||
if err != nil {
|
||||
return model.NewAppError("removeUserFromChannel", "api.team.remove_user_from_team.missing.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -2200,7 +2200,7 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
||||
}
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userIdToRemove)
|
||||
a.InvalidateCacheForUser(userIDToRemove)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
@@ -2219,12 +2219,12 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", channel.Id, "", nil)
|
||||
message.Add("user_id", userIdToRemove)
|
||||
message.Add("user_id", userIDToRemove)
|
||||
message.Add("remover_id", removerUserId)
|
||||
a.Publish(message)
|
||||
|
||||
// because the removed user no longer belongs to the channel we need to send a separate websocket event
|
||||
userMsg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", "", userIdToRemove, nil)
|
||||
userMsg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", "", userIDToRemove, nil)
|
||||
userMsg.Add("channel_id", channel.Id)
|
||||
userMsg.Add("remover_id", removerUserId)
|
||||
a.Publish(userMsg)
|
||||
@@ -2232,19 +2232,19 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
|
||||
func (a *App) RemoveUserFromChannel(userIDToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
|
||||
var err *model.AppError
|
||||
|
||||
if err = a.removeUserFromChannel(userIdToRemove, removerUserId, channel); err != nil {
|
||||
if err = a.removeUserFromChannel(userIDToRemove, removerUserId, channel); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if user, err = a.GetUser(userIdToRemove); err != nil {
|
||||
if user, err = a.GetUser(userIDToRemove); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if userIdToRemove == removerUserId {
|
||||
if userIDToRemove == removerUserId {
|
||||
a.postLeaveChannelMessage(user, channel)
|
||||
} else {
|
||||
a.Srv().Go(func() {
|
||||
@@ -2255,9 +2255,9 @@ func (a *App) RemoveUserFromChannel(userIdToRemove string, removerUserId string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetNumberOfChannelsOnTeam(teamId string) (int, *model.AppError) {
|
||||
func (a *App) GetNumberOfChannelsOnTeam(teamID string) (int, *model.AppError) {
|
||||
// Get total number of channels on current team
|
||||
list, err := a.Srv().Store.Channel().GetTeamChannels(teamId)
|
||||
list, err := a.Srv().Store.Channel().GetTeamChannels(teamID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -2270,13 +2270,13 @@ func (a *App) GetNumberOfChannelsOnTeam(teamId string) (int, *model.AppError) {
|
||||
return len(*list), nil
|
||||
}
|
||||
|
||||
func (a *App) SetActiveChannel(userId string, channelId string) *model.AppError {
|
||||
status, err := a.GetStatus(userId)
|
||||
func (a *App) SetActiveChannel(userID string, channelId string) *model.AppError {
|
||||
status, err := a.GetStatus(userID)
|
||||
|
||||
oldStatus := model.STATUS_OFFLINE
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelId}
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelId}
|
||||
} else {
|
||||
oldStatus = status.Status
|
||||
status.ActiveChannel = channelId
|
||||
@@ -2295,8 +2295,8 @@ func (a *App) SetActiveChannel(userId string, channelId string) *model.AppError
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateChannelLastViewedAt(channelIds []string, userId string) *model.AppError {
|
||||
if _, err := a.Srv().Store.Channel().UpdateLastViewedAt(channelIds, userId, *a.Config().ServiceSettings.ThreadAutoFollow); err != nil {
|
||||
func (a *App) UpdateChannelLastViewedAt(channelIds []string, userID string) *model.AppError {
|
||||
if _, err := a.Srv().Store.Channel().UpdateLastViewedAt(channelIds, userID, *a.Config().ServiceSettings.ThreadAutoFollow); err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
@@ -2308,7 +2308,7 @@ func (a *App) UpdateChannelLastViewedAt(channelIds []string, userId string) *mod
|
||||
|
||||
if *a.Config().ServiceSettings.EnableChannelViewedMessages {
|
||||
for _, channelId := range channelIds {
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userID, nil)
|
||||
message.Add("channel_id", channelId)
|
||||
a.Publish(message)
|
||||
}
|
||||
@@ -2369,11 +2369,11 @@ func (a *App) MarkChannelAsUnreadFromPost(postID string, userID string) (*model.
|
||||
return channelUnread, nil
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteChannels(teamId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().AutocompleteInTeam(teamId, term, includeDeleted)
|
||||
channelList, err := a.Srv().Store.Channel().AutocompleteInTeam(teamID, term, includeDeleted)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("AutocompleteChannels", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2381,12 +2381,12 @@ func (a *App) AutocompleteChannels(teamId string, term string) (*model.ChannelLi
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteChannelsForSearch(teamId string, userId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted)
|
||||
channelList, err := a.Srv().Store.Channel().AutocompleteInTeamForSearch(teamID, userID, term, includeDeleted)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("AutocompleteChannelsForSearch", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2423,12 +2423,12 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod
|
||||
return channelList, totalCount, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().SearchInTeam(teamId, term, includeDeleted)
|
||||
channelList, err := a.Srv().Store.Channel().SearchInTeam(teamID, term, includeDeleted)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchChannels", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2436,10 +2436,10 @@ func (a *App) SearchChannels(teamId string, term string) (*model.ChannelList, *m
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchArchivedChannels(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().SearchArchivedInTeam(teamId, term, userId)
|
||||
channelList, err := a.Srv().Store.Channel().SearchArchivedInTeam(teamID, term, userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchArchivedChannels", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2447,12 +2447,12 @@ func (a *App) SearchArchivedChannels(teamId string, term string, userId string)
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchChannelsForUser(userId, teamId, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchChannelsForUser(userID, teamID, term string) (*model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().SearchForUserInTeam(userId, teamId, term, includeDeleted)
|
||||
channelList, err := a.Srv().Store.Channel().SearchForUserInTeam(userID, teamID, term, includeDeleted)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchChannelsForUser", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2460,21 +2460,21 @@ func (a *App) SearchChannelsForUser(userId, teamId, term string) (*model.Channel
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchGroupChannels(userId, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchGroupChannels(userID, term string) (*model.ChannelList, *model.AppError) {
|
||||
if term == "" {
|
||||
return &model.ChannelList{}, nil
|
||||
}
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().SearchGroupChannels(userId, term)
|
||||
channelList, err := a.Srv().Store.Channel().SearchGroupChannels(userID, term)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchGroupChannels", "app.channel.search_group_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchChannelsUserNotIn(teamId string, userId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
channelList, err := a.Srv().Store.Channel().SearchMore(userId, teamId, term)
|
||||
channelList, err := a.Srv().Store.Channel().SearchMore(userID, teamID, term)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchChannelsUserNotIn", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2482,7 +2482,7 @@ func (a *App) SearchChannelsUserNotIn(teamId string, userId string, term string)
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSessionId string) (map[string]int64, *model.AppError) {
|
||||
func (a *App) MarkChannelsAsViewed(channelIds []string, userID string, currentSessionId string) (map[string]int64, *model.AppError) {
|
||||
// I start looking for channels with notifications before I mark it as read, to clear the push notifications if needed
|
||||
channelsToClearPushNotifications := []string{}
|
||||
if *a.Config().EmailSettings.SendPushNotifications {
|
||||
@@ -2493,7 +2493,7 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSe
|
||||
continue
|
||||
}
|
||||
|
||||
member, err := a.Srv().Store.Channel().GetMember(channelId, userId)
|
||||
member, err := a.Srv().Store.Channel().GetMember(channelId, userID)
|
||||
if err != nil {
|
||||
mlog.Warn("Failed to get membership", mlog.Err(err))
|
||||
continue
|
||||
@@ -2501,21 +2501,21 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSe
|
||||
|
||||
notify := member.NotifyProps[model.PUSH_NOTIFY_PROP]
|
||||
if notify == model.CHANNEL_NOTIFY_DEFAULT {
|
||||
user, err := a.GetUser(userId)
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
mlog.Warn("Failed to get user", mlog.String("user_id", userId), mlog.Err(err))
|
||||
mlog.Warn("Failed to get user", mlog.String("user_id", userID), mlog.Err(err))
|
||||
continue
|
||||
}
|
||||
notify = user.NotifyProps[model.PUSH_NOTIFY_PROP]
|
||||
}
|
||||
if notify == model.USER_NOTIFY_ALL {
|
||||
if count, err := a.Srv().Store.User().GetAnyUnreadPostCountForChannel(userId, channelId); err == nil {
|
||||
if count, err := a.Srv().Store.User().GetAnyUnreadPostCountForChannel(userID, channelId); err == nil {
|
||||
if count > 0 {
|
||||
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
|
||||
}
|
||||
}
|
||||
} else if notify == model.USER_NOTIFY_MENTION || channel.Type == model.CHANNEL_DIRECT {
|
||||
if count, err := a.Srv().Store.User().GetUnreadCountForChannel(userId, channelId); err == nil {
|
||||
if count, err := a.Srv().Store.User().GetUnreadCountForChannel(userID, channelId); err == nil {
|
||||
if count > 0 {
|
||||
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
|
||||
}
|
||||
@@ -2523,7 +2523,7 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSe
|
||||
}
|
||||
}
|
||||
}
|
||||
times, err := a.Srv().Store.Channel().UpdateLastViewedAt(channelIds, userId, *a.Config().ServiceSettings.ThreadAutoFollow)
|
||||
times, err := a.Srv().Store.Channel().UpdateLastViewedAt(channelIds, userID, *a.Config().ServiceSettings.ThreadAutoFollow)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
@@ -2536,19 +2536,19 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSe
|
||||
|
||||
if *a.Config().ServiceSettings.EnableChannelViewedMessages {
|
||||
for _, channelId := range channelIds {
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userID, nil)
|
||||
message.Add("channel_id", channelId)
|
||||
a.Publish(message)
|
||||
}
|
||||
}
|
||||
for _, channelId := range channelsToClearPushNotifications {
|
||||
a.clearPushNotification(currentSessionId, userId, channelId)
|
||||
a.clearPushNotification(currentSessionId, userID, channelId)
|
||||
}
|
||||
return times, nil
|
||||
}
|
||||
|
||||
func (a *App) ViewChannel(view *model.ChannelView, userId string, currentSessionId string) (map[string]int64, *model.AppError) {
|
||||
if err := a.SetActiveChannel(userId, view.ChannelId); err != nil {
|
||||
func (a *App) ViewChannel(view *model.ChannelView, userID string, currentSessionId string) (map[string]int64, *model.AppError) {
|
||||
if err := a.SetActiveChannel(userID, view.ChannelId); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -2566,7 +2566,7 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, currentSession
|
||||
return map[string]int64{}, nil
|
||||
}
|
||||
|
||||
return a.MarkChannelsAsViewed(channelIds, userId, currentSessionId)
|
||||
return a.MarkChannelsAsViewed(channelIds, userID, currentSessionId)
|
||||
}
|
||||
|
||||
func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
|
||||
@@ -2760,8 +2760,8 @@ func (a *App) RemoveUsersFromChannelNotMemberOfTeam(remover *model.User, channel
|
||||
if remover != nil {
|
||||
removerId = remover.Id
|
||||
}
|
||||
for userId := range channelMemberMap {
|
||||
if err := a.removeUserFromChannel(userId, removerId, channel); err != nil {
|
||||
for userID := range channelMemberMap {
|
||||
if err := a.removeUserFromChannel(userID, removerId, channel); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -2780,8 +2780,8 @@ func (a *App) GetPinnedPosts(channelId string) (*model.PostList, *model.AppError
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (a *App) ToggleMuteChannel(channelId, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
member, nErr := a.Srv().Store.Channel().GetMember(channelId, userId)
|
||||
func (a *App) ToggleMuteChannel(channelId, userID string) (*model.ChannelMember, *model.AppError) {
|
||||
member, nErr := a.Srv().Store.Channel().GetMember(channelId, userID)
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
var nfErr *store.ErrNotFound
|
||||
@@ -2807,8 +2807,8 @@ func (a *App) ToggleMuteChannel(channelId, userId string) (*model.ChannelMember,
|
||||
return member, nil
|
||||
}
|
||||
|
||||
func (a *App) setChannelsMuted(channelIds []string, userId string, muted bool) ([]*model.ChannelMember, *model.AppError) {
|
||||
members, nErr := a.Srv().Store.Channel().GetMembersByChannelIds(channelIds, userId)
|
||||
func (a *App) setChannelsMuted(channelIds []string, userID string, muted bool) ([]*model.ChannelMember, *model.AppError) {
|
||||
members, nErr := a.Srv().Store.Channel().GetMembersByChannelIds(channelIds, userID)
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
@@ -2871,7 +2871,7 @@ func (a *App) FillInChannelsProps(channelList *model.ChannelList) *model.AppErro
|
||||
channelsByTeam[channel.TeamId] = append(channelsByTeam[channel.TeamId], channel)
|
||||
}
|
||||
|
||||
for teamId, channelList := range channelsByTeam {
|
||||
for teamID, channelList := range channelsByTeam {
|
||||
allChannelMentions := make(map[string]bool)
|
||||
channelMentions := make(map[*model.Channel][]string, len(channelList))
|
||||
|
||||
@@ -2890,7 +2890,7 @@ func (a *App) FillInChannelsProps(channelList *model.ChannelList) *model.AppErro
|
||||
}
|
||||
|
||||
if len(allChannelMentionNames) > 0 {
|
||||
mentionedChannels, err := a.GetChannelsByNames(allChannelMentionNames, teamId)
|
||||
mentionedChannels, err := a.GetChannelsByNames(allChannelMentionNames, teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
)
|
||||
|
||||
func (a *App) createInitialSidebarCategories(userId, teamId string) *model.AppError {
|
||||
nErr := a.Srv().Store.Channel().CreateInitialSidebarCategories(userId, teamId)
|
||||
func (a *App) createInitialSidebarCategories(userID, teamID string) *model.AppError {
|
||||
nErr := a.Srv().Store.Channel().CreateInitialSidebarCategories(userID, teamID)
|
||||
|
||||
if nErr != nil {
|
||||
return model.NewAppError("createInitialSidebarCategories", "app.channel.create_initial_sidebar_categories.internal_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
@@ -23,17 +23,17 @@ func (a *App) createInitialSidebarCategories(userId, teamId string) *model.AppEr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
categories, err := a.Srv().Store.Channel().GetSidebarCategories(userId, teamId)
|
||||
func (a *App) GetSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
categories, err := a.Srv().Store.Channel().GetSidebarCategories(userID, teamID)
|
||||
|
||||
if err == nil && len(categories.Categories) == 0 {
|
||||
// A user must always have categories, so migration must not have happened yet, and we should run it ourselves
|
||||
appErr := a.createInitialSidebarCategories(userId, teamId)
|
||||
appErr := a.createInitialSidebarCategories(userID, teamID)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
categories, err = a.waitForSidebarCategories(userId, teamId)
|
||||
categories, err = a.waitForSidebarCategories(userID, teamID)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -51,10 +51,10 @@ func (a *App) GetSidebarCategories(userId, teamId string) (*model.OrderedSidebar
|
||||
|
||||
// waitForSidebarCategories is used to get a user's sidebar categories after they've been created since there may be
|
||||
// replication lag if any database replicas exist. It will wait until results are available to return them.
|
||||
func (a *App) waitForSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, error) {
|
||||
func (a *App) waitForSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, error) {
|
||||
if len(a.Config().SqlSettings.DataSourceReplicas) == 0 {
|
||||
// The categories should be available immediately on a single database
|
||||
return a.Srv().Store.Channel().GetSidebarCategories(userId, teamId)
|
||||
return a.Srv().Store.Channel().GetSidebarCategories(userID, teamID)
|
||||
}
|
||||
|
||||
now := model.GetMillis()
|
||||
@@ -62,7 +62,7 @@ func (a *App) waitForSidebarCategories(userId, teamId string) (*model.OrderedSid
|
||||
for model.GetMillis()-now < 12000 {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
categories, err := a.Srv().Store.Channel().GetSidebarCategories(userId, teamId)
|
||||
categories, err := a.Srv().Store.Channel().GetSidebarCategories(userID, teamID)
|
||||
|
||||
if err != nil || len(categories.Categories) > 0 {
|
||||
// We've found something, so return
|
||||
@@ -70,13 +70,13 @@ func (a *App) waitForSidebarCategories(userId, teamId string) (*model.OrderedSid
|
||||
}
|
||||
}
|
||||
|
||||
mlog.Error("waitForSidebarCategories giving up", mlog.String("user_id", userId), mlog.String("team_id", teamId))
|
||||
mlog.Error("waitForSidebarCategories giving up", mlog.String("user_id", userID), mlog.String("team_id", teamID))
|
||||
|
||||
return &model.OrderedSidebarCategories{}, nil
|
||||
}
|
||||
|
||||
func (a *App) GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError) {
|
||||
categories, err := a.Srv().Store.Channel().GetSidebarCategoryOrder(userId, teamId)
|
||||
func (a *App) GetSidebarCategoryOrder(userID, teamID string) ([]string, *model.AppError) {
|
||||
categories, err := a.Srv().Store.Channel().GetSidebarCategoryOrder(userID, teamID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -105,8 +105,8 @@ func (a *App) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithC
|
||||
return category, nil
|
||||
}
|
||||
|
||||
func (a *App) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
category, err := a.Srv().Store.Channel().CreateSidebarCategory(userId, teamId, newCategory)
|
||||
func (a *App) CreateSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
category, err := a.Srv().Store.Channel().CreateSidebarCategory(userID, teamID, newCategory)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -116,14 +116,14 @@ func (a *App) CreateSidebarCategory(userId, teamId string, newCategory *model.Si
|
||||
return nil, model.NewAppError("CreateSidebarCategory", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_CREATED, teamId, "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_CREATED, teamID, "", userID, nil)
|
||||
message.Add("category_id", category.Id)
|
||||
a.Publish(message)
|
||||
return category, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) *model.AppError {
|
||||
err := a.Srv().Store.Channel().UpdateSidebarCategoryOrder(userId, teamId, categoryOrder)
|
||||
func (a *App) UpdateSidebarCategoryOrder(userID, teamID string, categoryOrder []string) *model.AppError {
|
||||
err := a.Srv().Store.Channel().UpdateSidebarCategoryOrder(userID, teamID, categoryOrder)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
var invErr *store.ErrInvalidInput
|
||||
@@ -136,27 +136,27 @@ func (a *App) UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []
|
||||
return model.NewAppError("UpdateSidebarCategoryOrder", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_ORDER_UPDATED, teamId, "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_ORDER_UPDATED, teamID, "", userID, nil)
|
||||
message.Add("order", categoryOrder)
|
||||
a.Publish(message)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
updatedCategories, originalCategories, err := a.Srv().Store.Channel().UpdateSidebarCategories(userId, teamId, categories)
|
||||
func (a *App) UpdateSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
updatedCategories, originalCategories, err := a.Srv().Store.Channel().UpdateSidebarCategories(userID, teamID, categories)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("UpdateSidebarCategories", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, teamId, "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, teamID, "", userID, nil)
|
||||
a.Publish(message)
|
||||
|
||||
a.muteChannelsForUpdatedCategories(userId, updatedCategories, originalCategories)
|
||||
a.muteChannelsForUpdatedCategories(userID, updatedCategories, originalCategories)
|
||||
|
||||
return updatedCategories, nil
|
||||
}
|
||||
|
||||
func (a *App) muteChannelsForUpdatedCategories(userId string, updatedCategories []*model.SidebarCategoryWithChannels, originalCategories []*model.SidebarCategoryWithChannels) {
|
||||
func (a *App) muteChannelsForUpdatedCategories(userID string, updatedCategories []*model.SidebarCategoryWithChannels, originalCategories []*model.SidebarCategoryWithChannels) {
|
||||
var channelsToMute []string
|
||||
var channelsToUnmute []string
|
||||
|
||||
@@ -204,22 +204,22 @@ func (a *App) muteChannelsForUpdatedCategories(userId string, updatedCategories
|
||||
}
|
||||
|
||||
if len(channelsToMute) > 0 {
|
||||
_, err := a.setChannelsMuted(channelsToMute, userId, true)
|
||||
_, err := a.setChannelsMuted(channelsToMute, userID, true)
|
||||
if err != nil {
|
||||
mlog.Error(
|
||||
"Failed to mute channels to match category",
|
||||
mlog.String("user_id", userId),
|
||||
mlog.String("user_id", userID),
|
||||
mlog.Err(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if len(channelsToUnmute) > 0 {
|
||||
_, err := a.setChannelsMuted(channelsToUnmute, userId, false)
|
||||
_, err := a.setChannelsMuted(channelsToUnmute, userID, false)
|
||||
if err != nil {
|
||||
mlog.Error(
|
||||
"Failed to unmute channels to match category",
|
||||
mlog.String("user_id", userId),
|
||||
mlog.String("user_id", userID),
|
||||
mlog.Err(err),
|
||||
)
|
||||
}
|
||||
@@ -261,7 +261,7 @@ func diffChannelsBetweenCategories(updatedCategories []*model.SidebarCategoryWit
|
||||
return channelsDiff
|
||||
}
|
||||
|
||||
func (a *App) DeleteSidebarCategory(userId, teamId, categoryId string) *model.AppError {
|
||||
func (a *App) DeleteSidebarCategory(userID, teamID, categoryId string) *model.AppError {
|
||||
err := a.Srv().Store.Channel().DeleteSidebarCategory(categoryId)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
@@ -273,7 +273,7 @@ func (a *App) DeleteSidebarCategory(userId, teamId, categoryId string) *model.Ap
|
||||
}
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_DELETED, teamId, "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_DELETED, teamID, "", userID, nil)
|
||||
message.Add("category_id", categoryId)
|
||||
a.Publish(message)
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ func GetCommandProvider(name string) CommandProvider {
|
||||
return nil
|
||||
}
|
||||
|
||||
// @openTracingParams teamId, skipSlackParsing
|
||||
func (a *App) CreateCommandPost(post *model.Post, teamId string, response *model.CommandResponse, skipSlackParsing bool) (*model.Post, *model.AppError) {
|
||||
// @openTracingParams teamID, skipSlackParsing
|
||||
func (a *App) CreateCommandPost(post *model.Post, teamID string, response *model.CommandResponse, skipSlackParsing bool) (*model.Post, *model.AppError) {
|
||||
if skipSlackParsing {
|
||||
post.Message = response.Text
|
||||
} else {
|
||||
@@ -73,13 +73,13 @@ func (a *App) CreateCommandPost(post *model.Post, teamId string, response *model
|
||||
return post, nil
|
||||
}
|
||||
|
||||
// @openTracingParams teamId
|
||||
// @openTracingParams teamID
|
||||
// previous ListCommands now ListAutocompleteCommands
|
||||
func (a *App) ListAutocompleteCommands(teamId string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError) {
|
||||
func (a *App) ListAutocompleteCommands(teamID string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError) {
|
||||
commands := make([]*model.Command, 0, 32)
|
||||
seen := make(map[string]bool)
|
||||
|
||||
for _, cmd := range a.PluginCommandsForTeam(teamId) {
|
||||
for _, cmd := range a.PluginCommandsForTeam(teamID) {
|
||||
if cmd.AutoComplete && !seen[cmd.Trigger] {
|
||||
seen[cmd.Trigger] = true
|
||||
commands = append(commands, cmd)
|
||||
@@ -87,7 +87,7 @@ func (a *App) ListAutocompleteCommands(teamId string, T goi18n.TranslateFunc) ([
|
||||
}
|
||||
|
||||
if *a.Config().ServiceSettings.EnableCommands {
|
||||
teamCmds, err := a.Srv().Store.Command().GetByTeam(teamId)
|
||||
teamCmds, err := a.Srv().Store.Command().GetByTeam(teamID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("ListAutocompleteCommands", "app.command.listautocompletecommands.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -115,12 +115,12 @@ func (a *App) ListAutocompleteCommands(teamId string, T goi18n.TranslateFunc) ([
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
func (a *App) ListTeamCommands(teamId string) ([]*model.Command, *model.AppError) {
|
||||
func (a *App) ListTeamCommands(teamID string) ([]*model.Command, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableCommands {
|
||||
return nil, model.NewAppError("ListTeamCommands", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
teamCmds, err := a.Srv().Store.Command().GetByTeam(teamId)
|
||||
teamCmds, err := a.Srv().Store.Command().GetByTeam(teamID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("ListTeamCommands", "app.command.listteamcommands.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func (a *App) ListTeamCommands(teamId string) ([]*model.Command, *model.AppError
|
||||
return teamCmds, nil
|
||||
}
|
||||
|
||||
func (a *App) ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError) {
|
||||
func (a *App) ListAllCommands(teamID string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError) {
|
||||
commands := make([]*model.Command, 0, 32)
|
||||
seen := make(map[string]bool)
|
||||
for _, value := range commandProviders {
|
||||
@@ -142,7 +142,7 @@ func (a *App) ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.C
|
||||
}
|
||||
}
|
||||
|
||||
for _, cmd := range a.PluginCommandsForTeam(teamId) {
|
||||
for _, cmd := range a.PluginCommandsForTeam(teamID) {
|
||||
if !seen[cmd.Trigger] {
|
||||
seen[cmd.Trigger] = true
|
||||
commands = append(commands, cmd)
|
||||
@@ -150,7 +150,7 @@ func (a *App) ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.C
|
||||
}
|
||||
|
||||
if *a.Config().ServiceSettings.EnableCommands {
|
||||
teamCmds, err := a.Srv().Store.Command().GetByTeam(teamId)
|
||||
teamCmds, err := a.Srv().Store.Command().GetByTeam(teamID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("ListAllCommands", "app.command.listallcommands.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
|
||||
|
||||
// MentionsToTeamMembers returns all the @ mentions found in message that
|
||||
// belong to users in the specified team, linking them to their users
|
||||
func (a *App) MentionsToTeamMembers(message, teamId string) model.UserMentionMap {
|
||||
func (a *App) MentionsToTeamMembers(message, teamID string) model.UserMentionMap {
|
||||
type mentionMapItem struct {
|
||||
Name string
|
||||
Id string
|
||||
@@ -254,7 +254,7 @@ func (a *App) MentionsToTeamMembers(message, teamId string) model.UserMentionMap
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := a.GetTeamMember(teamId, userFromTrimmed.Id)
|
||||
_, err := a.GetTeamMember(teamID, userFromTrimmed.Id)
|
||||
if err != nil {
|
||||
// The user is not in the team, so we should ignore it
|
||||
return
|
||||
@@ -267,7 +267,7 @@ func (a *App) MentionsToTeamMembers(message, teamId string) model.UserMentionMap
|
||||
return
|
||||
}
|
||||
|
||||
_, err := a.GetTeamMember(teamId, user.Id)
|
||||
_, err := a.GetTeamMember(teamID, user.Id)
|
||||
if err != nil {
|
||||
// The user is not in the team, so we should ignore it
|
||||
return
|
||||
@@ -290,7 +290,7 @@ func (a *App) MentionsToTeamMembers(message, teamId string) model.UserMentionMap
|
||||
|
||||
// MentionsToPublicChannels returns all the mentions to public channels,
|
||||
// linking them to their channels
|
||||
func (a *App) MentionsToPublicChannels(message, teamId string) model.ChannelMentionMap {
|
||||
func (a *App) MentionsToPublicChannels(message, teamID string) model.ChannelMentionMap {
|
||||
type mentionMapItem struct {
|
||||
Name string
|
||||
Id string
|
||||
@@ -304,7 +304,7 @@ func (a *App) MentionsToPublicChannels(message, teamId string) model.ChannelMent
|
||||
wg.Add(1)
|
||||
go func(channelName string) {
|
||||
defer wg.Done()
|
||||
channel, err := a.GetChannelByName(channelName, teamId, false)
|
||||
channel, err := a.GetChannelByName(channelName, teamID, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -655,17 +655,17 @@ func (a *App) createCommand(cmd *model.Command) (*model.Command, *model.AppError
|
||||
return command, nil
|
||||
}
|
||||
|
||||
func (a *App) GetCommand(commandId string) (*model.Command, *model.AppError) {
|
||||
func (a *App) GetCommand(commandID string) (*model.Command, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableCommands {
|
||||
return nil, model.NewAppError("GetCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
command, err := a.Srv().Store.Command().Get(commandId)
|
||||
command, err := a.Srv().Store.Command().Get(commandID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("SqlCommandStore.Get", "store.sql_command.get.missing.app_error", map[string]interface{}{"command_id": commandId}, "", http.StatusNotFound)
|
||||
return nil, model.NewAppError("SqlCommandStore.Get", "store.sql_command.get.missing.app_error", map[string]interface{}{"command_id": commandID}, "", http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("GetCommand", "app.command.getcommand.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -749,12 +749,12 @@ func (a *App) RegenCommandToken(cmd *model.Command) (*model.Command, *model.AppE
|
||||
return command, nil
|
||||
}
|
||||
|
||||
func (a *App) DeleteCommand(commandId string) *model.AppError {
|
||||
func (a *App) DeleteCommand(commandID string) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableCommands {
|
||||
return model.NewAppError("DeleteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
err := a.Srv().Store.Command().Delete(commandId, model.GetMillis())
|
||||
err := a.Srv().Store.Command().Delete(commandID, model.GetMillis())
|
||||
if err != nil {
|
||||
return model.NewAppError("DeleteCommand", "app.command.deletecommand.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ func (es *EmailService) SendSignInChangeEmail(email, method, locale, siteURL str
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *EmailService) sendWelcomeEmail(userId string, email string, verified bool, locale, siteURL, redirect string) *model.AppError {
|
||||
func (es *EmailService) sendWelcomeEmail(userID string, email string, verified bool, locale, siteURL, redirect string) *model.AppError {
|
||||
if !*es.srv.Config().EmailSettings.SendEmailNotifications && !*es.srv.Config().EmailSettings.RequireEmailVerification {
|
||||
return model.NewAppError("SendWelcomeEmail", "api.user.send_welcome_email_and_forget.failed.error", nil, "Send Email Notifications and Require Email Verification is disabled in the system console", http.StatusInternalServerError)
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func (es *EmailService) sendWelcomeEmail(userId string, email string, verified b
|
||||
}
|
||||
|
||||
if !verified && *es.srv.Config().EmailSettings.RequireEmailVerification {
|
||||
token, err := es.CreateVerifyEmailToken(userId, email)
|
||||
token, err := es.CreateVerifyEmailToken(userID, email)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -568,12 +568,12 @@ func (es *EmailService) sendMailWithEmbeddedFiles(to, subject, htmlBody string,
|
||||
return mailservice.SendMailWithEmbeddedFilesUsingConfig(to, subject, htmlBody, embeddedFiles, config, license != nil && *license.Features.Compliance, "")
|
||||
}
|
||||
|
||||
func (es *EmailService) CreateVerifyEmailToken(userId string, newEmail string) (*model.Token, *model.AppError) {
|
||||
func (es *EmailService) CreateVerifyEmailToken(userID string, newEmail string) (*model.Token, *model.AppError) {
|
||||
tokenExtra := struct {
|
||||
UserId string
|
||||
Email string
|
||||
}{
|
||||
userId,
|
||||
userID,
|
||||
newEmail,
|
||||
}
|
||||
jsonData, err := json.Marshal(tokenExtra)
|
||||
|
||||
@@ -48,7 +48,7 @@ func (es *EmailService) AddNotificationEmailToBatch(user *model.User, post *mode
|
||||
}
|
||||
|
||||
type batchedNotification struct {
|
||||
userId string
|
||||
userID string
|
||||
post *model.Post
|
||||
teamName string
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func (job *EmailBatchingJob) Start() {
|
||||
|
||||
func (job *EmailBatchingJob) Add(user *model.User, post *model.Post, team *model.Team) bool {
|
||||
notification := &batchedNotification{
|
||||
userId: user.Id,
|
||||
userID: user.Id,
|
||||
post: post,
|
||||
teamName: team.Name,
|
||||
}
|
||||
@@ -116,12 +116,12 @@ func (job *EmailBatchingJob) handleNewNotifications() {
|
||||
for receiving {
|
||||
select {
|
||||
case notification := <-job.newNotifications:
|
||||
userId := notification.userId
|
||||
userID := notification.userID
|
||||
|
||||
if _, ok := job.pendingNotifications[userId]; !ok {
|
||||
job.pendingNotifications[userId] = []*batchedNotification{notification}
|
||||
if _, ok := job.pendingNotifications[userID]; !ok {
|
||||
job.pendingNotifications[userID] = []*batchedNotification{notification}
|
||||
} else {
|
||||
job.pendingNotifications[userId] = append(job.pendingNotifications[userId], notification)
|
||||
job.pendingNotifications[userID] = append(job.pendingNotifications[userID], notification)
|
||||
}
|
||||
default:
|
||||
receiving = false
|
||||
@@ -130,7 +130,7 @@ func (job *EmailBatchingJob) handleNewNotifications() {
|
||||
}
|
||||
|
||||
func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler func(string, []*batchedNotification)) {
|
||||
for userId, notifications := range job.pendingNotifications {
|
||||
for userID, notifications := range job.pendingNotifications {
|
||||
batchStartTime := notifications[0].post.CreateAt
|
||||
inspectedTeamNames := make(map[string]string)
|
||||
for _, notification := range notifications {
|
||||
@@ -151,7 +151,7 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
|
||||
|
||||
// if the user has viewed any channels in this team since the notification was queued, delete
|
||||
// all queued notifications
|
||||
channelMembers, err := job.server.Store.Channel().GetMembersForUser(inspectedTeamNames[notification.teamName], userId)
|
||||
channelMembers, err := job.server.Store.Channel().GetMembersForUser(inspectedTeamNames[notification.teamName], userID)
|
||||
if err != nil {
|
||||
mlog.Error("Unable to find ChannelMembers for user", mlog.Err(err))
|
||||
continue
|
||||
@@ -159,8 +159,8 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
|
||||
|
||||
for _, channelMember := range *channelMembers {
|
||||
if channelMember.LastViewedAt >= batchStartTime {
|
||||
mlog.Debug("Deleted notifications for user", mlog.String("user_id", userId))
|
||||
delete(job.pendingNotifications, userId)
|
||||
mlog.Debug("Deleted notifications for user", mlog.String("user_id", userID))
|
||||
delete(job.pendingNotifications, userID)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
|
||||
|
||||
// get how long we need to wait to send notifications to the user
|
||||
var interval int64
|
||||
preference, err := job.server.Store.Preference().Get(userId, model.PREFERENCE_CATEGORY_NOTIFICATIONS, model.PREFERENCE_NAME_EMAIL_INTERVAL)
|
||||
preference, err := job.server.Store.Preference().Get(userID, model.PREFERENCE_CATEGORY_NOTIFICATIONS, model.PREFERENCE_NAME_EMAIL_INTERVAL)
|
||||
if err != nil {
|
||||
// use the default batching interval if an error ocurrs while fetching user preferences
|
||||
interval, _ = strconv.ParseInt(model.PREFERENCE_EMAIL_INTERVAL_BATCHING_SECONDS, 10, 64)
|
||||
@@ -182,19 +182,19 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
|
||||
}
|
||||
|
||||
// send the email notification if there are notifications to send AND it's been long enough
|
||||
if len(job.pendingNotifications[userId]) > 0 && now.Sub(time.Unix(batchStartTime/1000, 0)) > time.Duration(interval)*time.Second {
|
||||
job.server.Go(func(userId string, notifications []*batchedNotification) func() {
|
||||
if len(job.pendingNotifications[userID]) > 0 && now.Sub(time.Unix(batchStartTime/1000, 0)) > time.Duration(interval)*time.Second {
|
||||
job.server.Go(func(userID string, notifications []*batchedNotification) func() {
|
||||
return func() {
|
||||
handler(userId, notifications)
|
||||
handler(userID, notifications)
|
||||
}
|
||||
}(userId, job.pendingNotifications[userId]))
|
||||
delete(job.pendingNotifications, userId)
|
||||
}(userID, job.pendingNotifications[userID]))
|
||||
delete(job.pendingNotifications, userID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (es *EmailService) sendBatchedEmailNotification(userId string, notifications []*batchedNotification) {
|
||||
user, err := es.srv.Store.User().Get(userId)
|
||||
func (es *EmailService) sendBatchedEmailNotification(userID string, notifications []*batchedNotification) {
|
||||
user, err := es.srv.Store.User().Get(userID)
|
||||
if err != nil {
|
||||
mlog.Warn("Unable to find recipient for batched email notification")
|
||||
return
|
||||
|
||||
@@ -256,10 +256,10 @@ func (a *App) exportAllUsers(writer io.Writer) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) buildUserTeamAndChannelMemberships(userId string) (*[]UserTeamImportData, *model.AppError) {
|
||||
func (a *App) buildUserTeamAndChannelMemberships(userID string) (*[]UserTeamImportData, *model.AppError) {
|
||||
var memberships []UserTeamImportData
|
||||
|
||||
members, err := a.Srv().Store.Team().GetTeamMembersForExport(userId)
|
||||
members, err := a.Srv().Store.Team().GetTeamMembersForExport(userID)
|
||||
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("buildUserTeamAndChannelMemberships", "app.team.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -274,7 +274,7 @@ func (a *App) buildUserTeamAndChannelMemberships(userId string) (*[]UserTeamImpo
|
||||
memberData := ImportUserTeamDataFromTeamMember(member)
|
||||
|
||||
// Do the Channel Memberships.
|
||||
channelMembers, err := a.buildUserChannelMemberships(userId, member.TeamId)
|
||||
channelMembers, err := a.buildUserChannelMemberships(userID, member.TeamId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -293,16 +293,16 @@ func (a *App) buildUserTeamAndChannelMemberships(userId string) (*[]UserTeamImpo
|
||||
return &memberships, nil
|
||||
}
|
||||
|
||||
func (a *App) buildUserChannelMemberships(userId string, teamId string) (*[]UserChannelImportData, *model.AppError) {
|
||||
func (a *App) buildUserChannelMemberships(userID string, teamID string) (*[]UserChannelImportData, *model.AppError) {
|
||||
var memberships []UserChannelImportData
|
||||
|
||||
members, nErr := a.Srv().Store.Channel().GetChannelMembersForExport(userId, teamId)
|
||||
members, nErr := a.Srv().Store.Channel().GetChannelMembersForExport(userID, teamID)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("buildUserChannelMemberships", "app.channel.get_members.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
category := model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL
|
||||
preferences, err := a.GetPreferenceByCategoryForUser(userId, category)
|
||||
preferences, err := a.GetPreferenceByCategoryForUser(userID, category)
|
||||
if err != nil && err.StatusCode != http.StatusNotFound {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
50
app/file.go
50
app/file.go
@@ -250,9 +250,9 @@ func (a *App) RemoveDirectory(path string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) getInfoForFilename(post *model.Post, teamId, channelId, userId, oldId, filename string) *model.FileInfo {
|
||||
func (a *App) getInfoForFilename(post *model.Post, teamID, channelId, userID, oldId, filename string) *model.FileInfo {
|
||||
name, _ := url.QueryUnescape(filename)
|
||||
pathPrefix := fmt.Sprintf("teams/%s/channels/%s/users/%s/%s/", teamId, channelId, userId, oldId)
|
||||
pathPrefix := fmt.Sprintf("teams/%s/channels/%s/users/%s/%s/", teamID, channelId, userID, oldId)
|
||||
path := pathPrefix + name
|
||||
|
||||
// Open the file and populate the fields of the FileInfo
|
||||
@@ -324,8 +324,8 @@ func (a *App) findTeamIdForFilename(post *model.Post, id, filename string) strin
|
||||
var fileMigrationLock sync.Mutex
|
||||
var oldFilenameMatchExp *regexp.Regexp = regexp.MustCompile(`^\/([a-z\d]{26})\/([a-z\d]{26})\/([a-z\d]{26})\/([^\/]+)$`)
|
||||
|
||||
// Parse the path from the Filename of the form /{channelId}/{userId}/{uid}/{nameWithExtension}
|
||||
func parseOldFilenames(filenames []string, channelId, userId string) [][]string {
|
||||
// Parse the path from the Filename of the form /{channelId}/{userID}/{uid}/{nameWithExtension}
|
||||
func parseOldFilenames(filenames []string, channelId, userID string) [][]string {
|
||||
parsed := [][]string{}
|
||||
for _, filename := range filenames {
|
||||
matches := oldFilenameMatchExp.FindStringSubmatch(filename)
|
||||
@@ -335,8 +335,8 @@ func parseOldFilenames(filenames []string, channelId, userId string) [][]string
|
||||
}
|
||||
if matches[1] != channelId {
|
||||
mlog.Error("ChannelId in Filename does not match", mlog.String("channel_id", channelId), mlog.String("matched", matches[1]))
|
||||
} else if matches[2] != userId {
|
||||
mlog.Error("UserId in Filename does not match", mlog.String("user_id", userId), mlog.String("matched", matches[2]))
|
||||
} else if matches[2] != userID {
|
||||
mlog.Error("UserId in Filename does not match", mlog.String("user_id", userID), mlog.String("matched", matches[2]))
|
||||
} else {
|
||||
parsed = append(parsed, matches[1:])
|
||||
}
|
||||
@@ -373,17 +373,17 @@ func (a *App) MigrateFilenamesToFileInfos(post *model.Post) []*model.FileInfo {
|
||||
}
|
||||
|
||||
// Find the team that was used to make this post since its part of the file path that isn't saved in the Filename
|
||||
var teamId string
|
||||
var teamID string
|
||||
if channel.TeamId == "" {
|
||||
// This post was made in a cross-team DM channel, so we need to find where its files were saved
|
||||
teamId = a.findTeamIdForFilename(post, parsedFilenames[0][2], parsedFilenames[0][3])
|
||||
teamID = a.findTeamIdForFilename(post, parsedFilenames[0][2], parsedFilenames[0][3])
|
||||
} else {
|
||||
teamId = channel.TeamId
|
||||
teamID = channel.TeamId
|
||||
}
|
||||
|
||||
// Create FileInfo objects for this post
|
||||
infos := make([]*model.FileInfo, 0, len(filenames))
|
||||
if teamId == "" {
|
||||
if teamID == "" {
|
||||
mlog.Error(
|
||||
"Unable to find team id for files when migrating post to use FileInfos",
|
||||
mlog.String("filenames", strings.Join(filenames, ",")),
|
||||
@@ -391,7 +391,7 @@ func (a *App) MigrateFilenamesToFileInfos(post *model.Post) []*model.FileInfo {
|
||||
)
|
||||
} else {
|
||||
for _, parsed := range parsedFilenames {
|
||||
info := a.getInfoForFilename(post, teamId, parsed[0], parsed[1], parsed[2], parsed[3])
|
||||
info := a.getInfoForFilename(post, teamID, parsed[0], parsed[1], parsed[2], parsed[3])
|
||||
if info == nil {
|
||||
continue
|
||||
}
|
||||
@@ -476,7 +476,7 @@ func GeneratePublicLinkHash(fileId, salt string) string {
|
||||
return base64.RawURLEncoding.EncodeToString(hash.Sum(nil))
|
||||
}
|
||||
|
||||
func (a *App) UploadMultipartFiles(teamId string, channelId string, userId string, fileHeaders []*multipart.FileHeader, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError) {
|
||||
func (a *App) UploadMultipartFiles(teamID string, channelId string, userID string, fileHeaders []*multipart.FileHeader, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError) {
|
||||
files := make([]io.ReadCloser, len(fileHeaders))
|
||||
filenames := make([]string, len(fileHeaders))
|
||||
|
||||
@@ -494,13 +494,13 @@ func (a *App) UploadMultipartFiles(teamId string, channelId string, userId strin
|
||||
filenames[i] = fileHeader.Filename
|
||||
}
|
||||
|
||||
return a.UploadFiles(teamId, channelId, userId, files, filenames, clientIds, now)
|
||||
return a.UploadFiles(teamID, channelId, userID, files, filenames, clientIds, now)
|
||||
}
|
||||
|
||||
// Uploads some files to the given team and channel as the given user. files and filenames should have
|
||||
// the same length. clientIds should either not be provided or have the same length as files and filenames.
|
||||
// The provided files should be closed by the caller so that they are not leaked.
|
||||
func (a *App) UploadFiles(teamId string, channelId string, userId string, files []io.ReadCloser, filenames []string, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError) {
|
||||
func (a *App) UploadFiles(teamID string, channelId string, userID string, files []io.ReadCloser, filenames []string, clientIds []string, now time.Time) (*model.FileUploadResponse, *model.AppError) {
|
||||
if *a.Config().FileSettings.DriverName == "" {
|
||||
return nil, model.NewAppError("UploadFiles", "api.file.upload_file.storage.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -523,7 +523,7 @@ func (a *App) UploadFiles(teamId string, channelId string, userId string, files
|
||||
io.Copy(buf, file)
|
||||
data := buf.Bytes()
|
||||
|
||||
info, data, err := a.DoUploadFileExpectModification(now, teamId, channelId, userId, filenames[i], data)
|
||||
info, data, err := a.DoUploadFileExpectModification(now, teamID, channelId, userID, filenames[i], data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -575,15 +575,15 @@ func (a *App) DoUploadFile(now time.Time, rawTeamId string, rawChannelId string,
|
||||
return info, err
|
||||
}
|
||||
|
||||
func UploadFileSetTeamId(teamId string) func(t *UploadFileTask) {
|
||||
func UploadFileSetTeamId(teamID string) func(t *UploadFileTask) {
|
||||
return func(t *UploadFileTask) {
|
||||
t.TeamId = filepath.Base(teamId)
|
||||
t.TeamId = filepath.Base(teamID)
|
||||
}
|
||||
}
|
||||
|
||||
func UploadFileSetUserId(userId string) func(t *UploadFileTask) {
|
||||
func UploadFileSetUserId(userID string) func(t *UploadFileTask) {
|
||||
return func(t *UploadFileTask) {
|
||||
t.UserId = filepath.Base(userId)
|
||||
t.UserId = filepath.Base(userID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,9 +940,9 @@ func (t UploadFileTask) newAppError(id string, details interface{}, httpStatus i
|
||||
|
||||
func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError) {
|
||||
filename := filepath.Base(rawFilename)
|
||||
teamId := filepath.Base(rawTeamId)
|
||||
teamID := filepath.Base(rawTeamId)
|
||||
channelId := filepath.Base(rawChannelId)
|
||||
userId := filepath.Base(rawUserId)
|
||||
userID := filepath.Base(rawUserId)
|
||||
|
||||
info, err := model.GetInfoForBytes(filename, bytes.NewReader(data), len(data))
|
||||
if err != nil {
|
||||
@@ -959,10 +959,10 @@ func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamId string, ra
|
||||
}
|
||||
|
||||
info.Id = model.NewId()
|
||||
info.CreatorId = userId
|
||||
info.CreatorId = userID
|
||||
info.CreateAt = now.UnixNano() / int64(time.Millisecond)
|
||||
|
||||
pathPrefix := now.Format("20060102") + "/teams/" + teamId + "/channels/" + channelId + "/users/" + userId + "/" + info.Id + "/"
|
||||
pathPrefix := now.Format("20060102") + "/teams/" + teamID + "/channels/" + channelId + "/users/" + userID + "/" + info.Id + "/"
|
||||
info.Path = pathPrefix + filename
|
||||
|
||||
if info.IsImage() {
|
||||
@@ -1223,7 +1223,7 @@ func (a *App) GetFile(fileId string) ([]byte, *model.AppError) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (a *App) CopyFileInfos(userId string, fileIds []string) ([]string, *model.AppError) {
|
||||
func (a *App) CopyFileInfos(userID string, fileIds []string) ([]string, *model.AppError) {
|
||||
var newFileIds []string
|
||||
|
||||
now := model.GetMillis()
|
||||
@@ -1241,7 +1241,7 @@ func (a *App) CopyFileInfos(userId string, fileIds []string) ([]string, *model.A
|
||||
}
|
||||
|
||||
fileInfo.Id = model.NewId()
|
||||
fileInfo.CreatorId = userId
|
||||
fileInfo.CreatorId = userID
|
||||
fileInfo.CreateAt = now
|
||||
fileInfo.UpdateAt = now
|
||||
fileInfo.PostId = ""
|
||||
|
||||
@@ -61,9 +61,9 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
defer th.TearDown()
|
||||
// disable logging in the benchmark, as best we can
|
||||
th.App.Log().SetConsoleLevel(mlog.LevelError)
|
||||
teamId := model.NewId()
|
||||
teamID := model.NewId()
|
||||
channelId := model.NewId()
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
|
||||
mb := func(i int) int {
|
||||
return (i + 512*1024) / (1024 * 1024)
|
||||
@@ -86,8 +86,8 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
{
|
||||
title: "raw-ish DoUploadFile",
|
||||
f: func(b *testing.B, n int, data []byte, ext string) {
|
||||
info1, err := th.App.DoUploadFile(time.Now(), teamId, channelId,
|
||||
userId, fmt.Sprintf("BenchmarkDoUploadFile-%d%s", n, ext), data)
|
||||
info1, err := th.App.DoUploadFile(time.Now(), teamID, channelId,
|
||||
userID, fmt.Sprintf("BenchmarkDoUploadFile-%d%s", n, ext), data)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
@@ -102,8 +102,8 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
info, aerr := th.App.UploadFileX(channelId,
|
||||
fmt.Sprintf("BenchmarkUploadFileTask-%d%s", n, ext),
|
||||
bytes.NewReader(data),
|
||||
UploadFileSetTeamId(teamId),
|
||||
UploadFileSetUserId(userId),
|
||||
UploadFileSetTeamId(teamID),
|
||||
UploadFileSetUserId(userID),
|
||||
UploadFileSetTimestamp(time.Now()),
|
||||
UploadFileSetContentLength(int64(len(data))),
|
||||
UploadFileSetRaw())
|
||||
@@ -120,8 +120,8 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
info, aerr := th.App.UploadFileX(channelId,
|
||||
fmt.Sprintf("BenchmarkUploadFileTask-%d%s", n, ext),
|
||||
bytes.NewReader(data),
|
||||
UploadFileSetTeamId(teamId),
|
||||
UploadFileSetUserId(userId),
|
||||
UploadFileSetTeamId(teamID),
|
||||
UploadFileSetUserId(userID),
|
||||
UploadFileSetTimestamp(time.Now()),
|
||||
UploadFileSetContentLength(-1),
|
||||
UploadFileSetRaw())
|
||||
@@ -135,7 +135,7 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
{
|
||||
title: "image UploadFiles",
|
||||
f: func(b *testing.B, n int, data []byte, ext string) {
|
||||
resp, err := th.App.UploadFiles(teamId, channelId, userId,
|
||||
resp, err := th.App.UploadFiles(teamID, channelId, userID,
|
||||
[]io.ReadCloser{ioutil.NopCloser(bytes.NewReader(data))},
|
||||
[]string{fmt.Sprintf("BenchmarkDoUploadFiles-%d%s", n, ext)},
|
||||
[]string{},
|
||||
@@ -153,8 +153,8 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
info, aerr := th.App.UploadFileX(channelId,
|
||||
fmt.Sprintf("BenchmarkUploadFileTask-%d%s", n, ext),
|
||||
bytes.NewReader(data),
|
||||
UploadFileSetTeamId(teamId),
|
||||
UploadFileSetUserId(userId),
|
||||
UploadFileSetTeamId(teamID),
|
||||
UploadFileSetUserId(userID),
|
||||
UploadFileSetTimestamp(time.Now()),
|
||||
UploadFileSetContentLength(int64(len(data))))
|
||||
if aerr != nil {
|
||||
@@ -170,8 +170,8 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
info, aerr := th.App.UploadFileX(channelId,
|
||||
fmt.Sprintf("BenchmarkUploadFileTask-%d%s", n, ext),
|
||||
bytes.NewReader(data),
|
||||
UploadFileSetTeamId(teamId),
|
||||
UploadFileSetUserId(userId),
|
||||
UploadFileSetTeamId(teamID),
|
||||
UploadFileSetUserId(userID),
|
||||
UploadFileSetTimestamp(time.Now()),
|
||||
UploadFileSetContentLength(int64(len(data))))
|
||||
if aerr != nil {
|
||||
|
||||
@@ -43,50 +43,50 @@ func TestDoUploadFile(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
teamId := model.NewId()
|
||||
teamID := model.NewId()
|
||||
channelId := model.NewId()
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
filename := "test"
|
||||
data := []byte("abcd")
|
||||
|
||||
info1, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamId, channelId, userId, filename, data)
|
||||
info1, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamID, channelId, userID, filename, data)
|
||||
require.Nil(t, err, "DoUploadFile should succeed with valid data")
|
||||
defer func() {
|
||||
th.App.Srv().Store.FileInfo().PermanentDelete(info1.Id)
|
||||
th.App.RemoveFile(info1.Path)
|
||||
}()
|
||||
|
||||
value := fmt.Sprintf("20070204/teams/%v/channels/%v/users/%v/%v/%v", teamId, channelId, userId, info1.Id, filename)
|
||||
value := fmt.Sprintf("20070204/teams/%v/channels/%v/users/%v/%v/%v", teamID, channelId, userID, info1.Id, filename)
|
||||
assert.Equal(t, value, info1.Path, "stored file at incorrect path")
|
||||
|
||||
info2, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamId, channelId, userId, filename, data)
|
||||
info2, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamID, channelId, userID, filename, data)
|
||||
require.Nil(t, err, "DoUploadFile should succeed with valid data")
|
||||
defer func() {
|
||||
th.App.Srv().Store.FileInfo().PermanentDelete(info2.Id)
|
||||
th.App.RemoveFile(info2.Path)
|
||||
}()
|
||||
|
||||
value = fmt.Sprintf("20070204/teams/%v/channels/%v/users/%v/%v/%v", teamId, channelId, userId, info2.Id, filename)
|
||||
value = fmt.Sprintf("20070204/teams/%v/channels/%v/users/%v/%v/%v", teamID, channelId, userID, info2.Id, filename)
|
||||
assert.Equal(t, value, info2.Path, "stored file at incorrect path")
|
||||
|
||||
info3, err := th.App.DoUploadFile(time.Date(2008, 3, 5, 1, 2, 3, 4, time.Local), teamId, channelId, userId, filename, data)
|
||||
info3, err := th.App.DoUploadFile(time.Date(2008, 3, 5, 1, 2, 3, 4, time.Local), teamID, channelId, userID, filename, data)
|
||||
require.Nil(t, err, "DoUploadFile should succeed with valid data")
|
||||
defer func() {
|
||||
th.App.Srv().Store.FileInfo().PermanentDelete(info3.Id)
|
||||
th.App.RemoveFile(info3.Path)
|
||||
}()
|
||||
|
||||
value = fmt.Sprintf("20080305/teams/%v/channels/%v/users/%v/%v/%v", teamId, channelId, userId, info3.Id, filename)
|
||||
value = fmt.Sprintf("20080305/teams/%v/channels/%v/users/%v/%v/%v", teamID, channelId, userID, info3.Id, filename)
|
||||
assert.Equal(t, value, info3.Path, "stored file at incorrect path")
|
||||
|
||||
info4, err := th.App.DoUploadFile(time.Date(2009, 3, 5, 1, 2, 3, 4, time.Local), "../../"+teamId, "../../"+channelId, "../../"+userId, "../../"+filename, data)
|
||||
info4, err := th.App.DoUploadFile(time.Date(2009, 3, 5, 1, 2, 3, 4, time.Local), "../../"+teamID, "../../"+channelId, "../../"+userID, "../../"+filename, data)
|
||||
require.Nil(t, err, "DoUploadFile should succeed with valid data")
|
||||
defer func() {
|
||||
th.App.Srv().Store.FileInfo().PermanentDelete(info4.Id)
|
||||
th.App.RemoveFile(info4.Path)
|
||||
}()
|
||||
|
||||
value = fmt.Sprintf("20090305/teams/%v/channels/%v/users/%v/%v/%v", teamId, channelId, userId, info4.Id, filename)
|
||||
value = fmt.Sprintf("20090305/teams/%v/channels/%v/users/%v/%v/%v", teamID, channelId, userID, info4.Id, filename)
|
||||
assert.Equal(t, value, info4.Path, "stored file at incorrect path")
|
||||
}
|
||||
|
||||
@@ -127,21 +127,21 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
description string
|
||||
filenames []string
|
||||
channelId string
|
||||
userId string
|
||||
userID string
|
||||
expected [][]string
|
||||
}{
|
||||
{
|
||||
description: "Empty input should result in empty output",
|
||||
filenames: []string{},
|
||||
channelId: th.BasicChannel.Id,
|
||||
userId: th.BasicUser.Id,
|
||||
userID: th.BasicUser.Id,
|
||||
expected: [][]string{},
|
||||
},
|
||||
{
|
||||
description: "Filename with invalid format should not parse",
|
||||
filenames: []string{"/path/to/some/file.png"},
|
||||
channelId: th.BasicChannel.Id,
|
||||
userId: th.BasicUser.Id,
|
||||
userID: th.BasicUser.Id,
|
||||
expected: [][]string{},
|
||||
},
|
||||
{
|
||||
@@ -150,7 +150,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
fmt.Sprintf("/%v/%v/%v/file.png", model.NewId(), th.BasicUser.Id, fileId),
|
||||
},
|
||||
channelId: th.BasicChannel.Id,
|
||||
userId: th.BasicUser.Id,
|
||||
userID: th.BasicUser.Id,
|
||||
expected: [][]string{},
|
||||
},
|
||||
{
|
||||
@@ -159,7 +159,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
fmt.Sprintf("/%v/%v/%v/file.png", th.BasicChannel.Id, model.NewId(), fileId),
|
||||
},
|
||||
channelId: th.BasicChannel.Id,
|
||||
userId: th.BasicUser.Id,
|
||||
userID: th.BasicUser.Id,
|
||||
expected: [][]string{},
|
||||
},
|
||||
{
|
||||
@@ -168,7 +168,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
fmt.Sprintf("/%v/%v/%v/../../../file.png", th.BasicChannel.Id, th.BasicUser.Id, fileId),
|
||||
},
|
||||
channelId: th.BasicChannel.Id,
|
||||
userId: th.BasicUser.Id,
|
||||
userID: th.BasicUser.Id,
|
||||
expected: [][]string{},
|
||||
},
|
||||
{
|
||||
@@ -178,7 +178,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
fmt.Sprintf("/%v/%v/%v/file.png", th.BasicChannel.Id, th.BasicUser.Id, fileId),
|
||||
},
|
||||
channelId: th.BasicChannel.Id,
|
||||
userId: th.BasicUser.Id,
|
||||
userID: th.BasicUser.Id,
|
||||
expected: [][]string{
|
||||
{
|
||||
th.BasicChannel.Id,
|
||||
@@ -194,7 +194,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
fmt.Sprintf("/%v/%v/%v/file.png", th.BasicChannel.Id, th.BasicUser.Id, fileId),
|
||||
},
|
||||
channelId: th.BasicChannel.Id,
|
||||
userId: th.BasicUser.Id,
|
||||
userID: th.BasicUser.Id,
|
||||
expected: [][]string{
|
||||
{
|
||||
th.BasicChannel.Id,
|
||||
@@ -208,7 +208,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.description, func(tt *testing.T) {
|
||||
result := parseOldFilenames(test.filenames, test.channelId, test.userId)
|
||||
result := parseOldFilenames(test.filenames, test.channelId, test.userID)
|
||||
require.Equal(tt, result, test.expected)
|
||||
})
|
||||
}
|
||||
@@ -219,9 +219,9 @@ func TestGetInfoForFilename(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
post := th.BasicPost
|
||||
teamId := th.BasicTeam.Id
|
||||
teamID := th.BasicTeam.Id
|
||||
|
||||
info := th.App.getInfoForFilename(post, teamId, post.ChannelId, post.UserId, "someid", "somefile.png")
|
||||
info := th.App.getInfoForFilename(post, teamID, post.ChannelId, post.UserId, "someid", "somefile.png")
|
||||
assert.Nil(t, info, "Test non-existent file")
|
||||
}
|
||||
|
||||
@@ -229,14 +229,14 @@ func TestFindTeamIdForFilename(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
teamId := th.App.findTeamIdForFilename(th.BasicPost, "someid", "somefile.png")
|
||||
assert.Equal(t, th.BasicTeam.Id, teamId)
|
||||
teamID := th.App.findTeamIdForFilename(th.BasicPost, "someid", "somefile.png")
|
||||
assert.Equal(t, th.BasicTeam.Id, teamID)
|
||||
|
||||
_, err := th.App.CreateTeamWithUser(&model.Team{Email: th.BasicUser.Email, Name: "zz" + model.NewId(), DisplayName: "Joram's Test Team", Type: model.TEAM_OPEN}, th.BasicUser.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
teamId = th.App.findTeamIdForFilename(th.BasicPost, "someid", "somefile.png")
|
||||
assert.Equal(t, "", teamId)
|
||||
teamID = th.App.findTeamIdForFilename(th.BasicPost, "someid", "somefile.png")
|
||||
assert.Equal(t, "", teamID)
|
||||
}
|
||||
|
||||
func TestMigrateFilenamesToFileInfos(t *testing.T) {
|
||||
@@ -294,20 +294,20 @@ func TestCopyFileInfos(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
teamId := model.NewId()
|
||||
teamID := model.NewId()
|
||||
channelId := model.NewId()
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
filename := "test"
|
||||
data := []byte("abcd")
|
||||
|
||||
info1, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamId, channelId, userId, filename, data)
|
||||
info1, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamID, channelId, userID, filename, data)
|
||||
require.Nil(t, err)
|
||||
defer func() {
|
||||
th.App.Srv().Store.FileInfo().PermanentDelete(info1.Id)
|
||||
th.App.RemoveFile(info1.Path)
|
||||
}()
|
||||
|
||||
infoIds, err := th.App.CopyFileInfos(userId, []string{info1.Id})
|
||||
infoIds, err := th.App.CopyFileInfos(userID, []string{info1.Id})
|
||||
require.Nil(t, err)
|
||||
|
||||
info2, err := th.App.GetFileInfo(infoIds[0])
|
||||
|
||||
14
app/group.go
14
app/group.go
@@ -65,8 +65,8 @@ func (a *App) GetGroupsBySource(groupSource model.GroupSource) ([]*model.Group,
|
||||
return groups, nil
|
||||
}
|
||||
|
||||
func (a *App) GetGroupsByUserId(userId string) ([]*model.Group, *model.AppError) {
|
||||
groups, err := a.Srv().Store.Group().GetByUser(userId)
|
||||
func (a *App) GetGroupsByUserId(userID string) ([]*model.Group, *model.AppError) {
|
||||
groups, err := a.Srv().Store.Group().GetByUser(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetGroupsByUserId", "app.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -450,13 +450,13 @@ func (a *App) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) (
|
||||
}
|
||||
|
||||
// GetGroupsByTeam returns the paged list and the total count of group associated to the given team.
|
||||
func (a *App) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, int, *model.AppError) {
|
||||
groups, err := a.Srv().Store.Group().GetGroupsByTeam(teamId, opts)
|
||||
func (a *App) GetGroupsByTeam(teamID string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, int, *model.AppError) {
|
||||
groups, err := a.Srv().Store.Group().GetGroupsByTeam(teamID, opts)
|
||||
if err != nil {
|
||||
return nil, 0, model.NewAppError("GetGroupsByTeam", "app.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
count, err := a.Srv().Store.Group().CountGroupsByTeam(teamId, opts)
|
||||
count, err := a.Srv().Store.Group().CountGroupsByTeam(teamID, opts)
|
||||
if err != nil {
|
||||
return nil, 0, model.NewAppError("GetGroupsByTeam", "app.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -464,8 +464,8 @@ func (a *App) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*mod
|
||||
return groups, int(count), nil
|
||||
}
|
||||
|
||||
func (a *App) GetGroupsAssociatedToChannelsByTeam(teamId string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, *model.AppError) {
|
||||
groupsAssociatedByChannelId, err := a.Srv().Store.Group().GetGroupsAssociatedToChannelsByTeam(teamId, opts)
|
||||
func (a *App) GetGroupsAssociatedToChannelsByTeam(teamID string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, *model.AppError) {
|
||||
groupsAssociatedByChannelId, err := a.Srv().Store.Group().GetGroupsAssociatedToChannelsByTeam(teamID, opts)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetGroupsAssociatedToChannelsByTeam", "app.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -1016,7 +1016,7 @@ func (a *App) importReaction(data *ReactionImportData, post *model.Post) *model.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId string) *model.AppError {
|
||||
func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamID string) *model.AppError {
|
||||
var err *model.AppError
|
||||
usernames := []string{}
|
||||
for _, replyData := range data {
|
||||
@@ -1064,7 +1064,7 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
|
||||
reply.Message = *replyData.Message
|
||||
reply.CreateAt = *replyData.CreateAt
|
||||
|
||||
fileIds, err := a.uploadAttachments(replyData.Attachments, reply, teamId)
|
||||
fileIds, err := a.uploadAttachments(replyData.Attachments, reply, teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1112,7 +1112,7 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) importAttachment(data *AttachmentImportData, post *model.Post, teamId string) (*model.FileInfo, *model.AppError) {
|
||||
func (a *App) importAttachment(data *AttachmentImportData, post *model.Post, teamID string) (*model.FileInfo, *model.AppError) {
|
||||
file, err := os.Open(*data.Path)
|
||||
if file == nil || err != nil {
|
||||
return nil, model.NewAppError("BulkImport", "app.import.attachment.bad_file.error", map[string]interface{}{"FilePath": *data.Path}, "", http.StatusBadRequest)
|
||||
@@ -1145,7 +1145,7 @@ func (a *App) importAttachment(data *AttachmentImportData, post *model.Post, tea
|
||||
}
|
||||
}
|
||||
}
|
||||
fileInfo, appErr := a.DoUploadFile(timestamp, teamId, post.ChannelId, post.UserId, file.Name(), buf.Bytes())
|
||||
fileInfo, appErr := a.DoUploadFile(timestamp, teamID, post.ChannelId, post.UserId, file.Name(), buf.Bytes())
|
||||
if appErr != nil {
|
||||
mlog.Error("Failed to upload file:", mlog.Err(appErr))
|
||||
return nil, appErr
|
||||
@@ -1197,8 +1197,8 @@ func (a *App) getTeamsByNames(names []string) (map[string]*model.Team, *model.Ap
|
||||
return teams, nil
|
||||
}
|
||||
|
||||
func (a *App) getChannelsByNames(names []string, teamId string) (map[string]*model.Channel, *model.AppError) {
|
||||
allChannels, err := a.Srv().Store.Channel().GetByNames(teamId, names, true)
|
||||
func (a *App) getChannelsByNames(names []string, teamID string) (map[string]*model.Channel, *model.AppError) {
|
||||
allChannels, err := a.Srv().Store.Channel().GetByNames(teamID, names, true)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("BulkImport", "app.import.get_teams_by_names.some_teams_not_found.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -1421,14 +1421,14 @@ func (a *App) importMultiplePostLines(lines []LineImportWorkerData, dryRun bool)
|
||||
}
|
||||
|
||||
// uploadAttachments imports new attachments and returns current attachments of the post as a map
|
||||
func (a *App) uploadAttachments(attachments *[]AttachmentImportData, post *model.Post, teamId string) (map[string]bool, *model.AppError) {
|
||||
func (a *App) uploadAttachments(attachments *[]AttachmentImportData, post *model.Post, teamID string) (map[string]bool, *model.AppError) {
|
||||
if attachments == nil {
|
||||
return nil, nil
|
||||
}
|
||||
fileIds := make(map[string]bool)
|
||||
for _, attachment := range *attachments {
|
||||
attachment := attachment
|
||||
fileInfo, err := a.importAttachment(&attachment, post, teamId)
|
||||
fileInfo, err := a.importAttachment(&attachment, post, teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1455,25 +1455,25 @@ func (a *App) importDirectChannel(data *DirectChannelImportData, dryRun bool) *m
|
||||
return nil
|
||||
}
|
||||
|
||||
var userIds []string
|
||||
var userIDs []string
|
||||
userMap, err := a.getUsersByUsernames(*data.Members)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, user := range *data.Members {
|
||||
userIds = append(userIds, userMap[user].Id)
|
||||
userIDs = append(userIDs, userMap[user].Id)
|
||||
}
|
||||
|
||||
var channel *model.Channel
|
||||
|
||||
if len(userIds) == 2 {
|
||||
ch, err := a.createDirectChannel(userIds[0], userIds[1])
|
||||
if len(userIDs) == 2 {
|
||||
ch, err := a.createDirectChannel(userIDs[0], userIDs[1])
|
||||
if err != nil && err.Id != store.ChannelExistsError {
|
||||
return model.NewAppError("BulkImport", "app.import.import_direct_channel.create_direct_channel.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
channel = ch
|
||||
} else {
|
||||
ch, err := a.createGroupChannel(userIds)
|
||||
ch, err := a.createGroupChannel(userIDs)
|
||||
if err != nil && err.Id != store.ChannelExistsError {
|
||||
return model.NewAppError("BulkImport", "app.import.import_direct_channel.create_group_channel.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -1482,9 +1482,9 @@ func (a *App) importDirectChannel(data *DirectChannelImportData, dryRun bool) *m
|
||||
|
||||
var preferences model.Preferences
|
||||
|
||||
for _, userId := range userIds {
|
||||
for _, userID := range userIDs {
|
||||
preferences = append(preferences, model.Preference{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW,
|
||||
Name: channel.Id,
|
||||
Value: "true",
|
||||
@@ -1562,23 +1562,23 @@ func (a *App) importMultipleDirectPostLines(lines []LineImportWorkerData, dryRun
|
||||
postsForOverwriteMap := map[string]int{}
|
||||
|
||||
for _, line := range lines {
|
||||
var userIds []string
|
||||
var userIDs []string
|
||||
var err *model.AppError
|
||||
for _, username := range *line.DirectPost.ChannelMembers {
|
||||
user := users[username]
|
||||
userIds = append(userIds, user.Id)
|
||||
userIDs = append(userIDs, user.Id)
|
||||
}
|
||||
|
||||
var channel *model.Channel
|
||||
var ch *model.Channel
|
||||
if len(userIds) == 2 {
|
||||
ch, err = a.GetOrCreateDirectChannel(userIds[0], userIds[1])
|
||||
if len(userIDs) == 2 {
|
||||
ch, err = a.GetOrCreateDirectChannel(userIDs[0], userIDs[1])
|
||||
if err != nil && err.Id != store.ChannelExistsError {
|
||||
return line.LineNumber, model.NewAppError("BulkImport", "app.import.import_direct_post.create_direct_channel.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
channel = ch
|
||||
} else {
|
||||
ch, err = a.createGroupChannel(userIds)
|
||||
ch, err = a.createGroupChannel(userIDs)
|
||||
if err != nil && err.Id != store.ChannelExistsError {
|
||||
return line.LineNumber, model.NewAppError("BulkImport", "app.import.import_direct_post.create_group_channel.error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3094,12 +3094,12 @@ func TestImportImportDirectChannel(t *testing.T) {
|
||||
AssertChannelCount(t, th.App, model.CHANNEL_GROUP, groupChannelCount+1)
|
||||
|
||||
// Get the channel to check that the header was updated.
|
||||
userIds := []string{
|
||||
userIDs := []string{
|
||||
th.BasicUser.Id,
|
||||
th.BasicUser2.Id,
|
||||
user3.Id,
|
||||
}
|
||||
channel, appErr := th.App.createGroupChannel(userIds)
|
||||
channel, appErr := th.App.createGroupChannel(userIDs)
|
||||
require.Equal(t, appErr.Id, store.ChannelExistsError)
|
||||
require.Equal(t, channel.Header, *data.Header)
|
||||
|
||||
@@ -3395,12 +3395,12 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
|
||||
// Get the channel.
|
||||
var groupChannel *model.Channel
|
||||
userIds := []string{
|
||||
userIDs := []string{
|
||||
th.BasicUser.Id,
|
||||
th.BasicUser2.Id,
|
||||
user3.Id,
|
||||
}
|
||||
channel, appErr = th.App.createGroupChannel(userIds)
|
||||
channel, appErr = th.App.createGroupChannel(userIDs)
|
||||
require.Equal(t, appErr.Id, store.ChannelExistsError)
|
||||
groupChannel = channel
|
||||
|
||||
@@ -3889,12 +3889,12 @@ func TestImportAttachment(t *testing.T) {
|
||||
testImage := filepath.Join(testsDir, "test.png")
|
||||
invalidPath := "some-invalid-path"
|
||||
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
data := AttachmentImportData{Path: &testImage}
|
||||
_, err := th.App.importAttachment(&data, &model.Post{UserId: userId, ChannelId: "some-channel"}, "some-team")
|
||||
_, err := th.App.importAttachment(&data, &model.Post{UserId: userID, ChannelId: "some-channel"}, "some-team")
|
||||
assert.Nil(t, err, "sample run without errors")
|
||||
|
||||
attachments := GetAttachments(userId, th, t)
|
||||
attachments := GetAttachments(userID, th, t)
|
||||
assert.Len(t, attachments, 1)
|
||||
|
||||
data = AttachmentImportData{Path: &invalidPath}
|
||||
|
||||
@@ -36,18 +36,18 @@ func ptrBool(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
func checkPreference(t *testing.T, a *App, userId string, category string, name string, value string) {
|
||||
preferences, err := a.Srv().Store.Preference().GetCategory(userId, category)
|
||||
require.Nilf(t, err, "Failed to get preferences for user %v with category %v", userId, category)
|
||||
func checkPreference(t *testing.T, a *App, userID string, category string, name string, value string) {
|
||||
preferences, err := a.Srv().Store.Preference().GetCategory(userID, category)
|
||||
require.Nilf(t, err, "Failed to get preferences for user %v with category %v", userID, category)
|
||||
found := false
|
||||
for _, preference := range preferences {
|
||||
if preference.Name == name {
|
||||
found = true
|
||||
require.Equal(t, preference.Value, value, "Preference for user %v in category %v with name %v has value %v, expected %v", userId, category, name, preference.Value, value)
|
||||
require.Equal(t, preference.Value, value, "Preference for user %v in category %v with name %v has value %v, expected %v", userID, category, name, preference.Value, value)
|
||||
break
|
||||
}
|
||||
}
|
||||
require.Truef(t, found, "Did not find preference for user %v in category %v with name %v", userId, category, name)
|
||||
require.Truef(t, found, "Did not find preference for user %v in category %v with name %v", userID, category, name)
|
||||
}
|
||||
|
||||
func checkNotifyProp(t *testing.T, user *model.User, key string, value string) {
|
||||
@@ -249,8 +249,8 @@ func TestImportProcessImportDataFileVersionLine(t *testing.T) {
|
||||
require.NotNil(t, err, "Expected error on invalid version line.")
|
||||
}
|
||||
|
||||
func GetAttachments(userId string, th *TestHelper, t *testing.T) []*model.FileInfo {
|
||||
fileInfos, err := th.App.Srv().Store.FileInfo().GetForUser(userId)
|
||||
func GetAttachments(userID string, th *TestHelper, t *testing.T) []*model.FileInfo {
|
||||
fileInfos, err := th.App.Srv().Store.FileInfo().GetForUser(userID)
|
||||
require.Nil(t, err)
|
||||
return fileInfos
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
func (a *App) DoPostAction(postId, actionId, userId, selectedOption string) (string, *model.AppError) {
|
||||
return a.DoPostActionWithCookie(postId, actionId, userId, selectedOption, nil)
|
||||
func (a *App) DoPostAction(postId, actionId, userID, selectedOption string) (string, *model.AppError) {
|
||||
return a.DoPostActionWithCookie(postId, actionId, userID, selectedOption, nil)
|
||||
}
|
||||
|
||||
func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError) {
|
||||
func (a *App) DoPostActionWithCookie(postId, actionId, userID, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError) {
|
||||
|
||||
// PostAction may result in the original post being updated. For the
|
||||
// updated post, we need to unconditionally preserve the original
|
||||
@@ -62,7 +62,7 @@ func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption st
|
||||
upstreamURL := ""
|
||||
rootPostId := ""
|
||||
upstreamRequest := &model.PostActionIntegrationRequest{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
PostId: postId,
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption st
|
||||
Message: response.EphemeralText,
|
||||
ChannelId: upstreamRequest.ChannelId,
|
||||
RootId: rootPostId,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
}
|
||||
|
||||
if !response.SkipSlackParsing {
|
||||
@@ -287,7 +287,7 @@ func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption st
|
||||
for key, value := range retain {
|
||||
ephemeralPost.AddProp(key, value)
|
||||
}
|
||||
a.SendEphemeralPost(userId, ephemeralPost)
|
||||
a.SendEphemeralPost(userID, ephemeralPost)
|
||||
}
|
||||
|
||||
return clientTriggerId, nil
|
||||
@@ -567,7 +567,7 @@ func (a *App) DoLocalRequest(rawURL string, body []byte) (*http.Response, *model
|
||||
}
|
||||
|
||||
func (a *App) OpenInteractiveDialog(request model.OpenDialogRequest) *model.AppError {
|
||||
clientTriggerId, userId, err := request.DecodeAndVerifyTriggerId(a.AsymmetricSigningKey())
|
||||
clientTriggerId, userID, err := request.DecodeAndVerifyTriggerId(a.AsymmetricSigningKey())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -576,7 +576,7 @@ func (a *App) OpenInteractiveDialog(request model.OpenDialogRequest) *model.AppE
|
||||
|
||||
jsonRequest, _ := json.Marshal(request)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_OPEN_DIALOG, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_OPEN_DIALOG, "", "", userID, nil)
|
||||
message.Add("dialog", string(jsonRequest))
|
||||
a.Publish(message)
|
||||
|
||||
|
||||
@@ -181,16 +181,16 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
// for each mention, make sure to update thread autofollow (if enabled) and update increment mention count
|
||||
for id := range threadParticipants {
|
||||
mac := make(chan *model.AppError, 1)
|
||||
go func(userId string) {
|
||||
go func(userID string) {
|
||||
defer close(mac)
|
||||
incrementMentions := false
|
||||
for mid := range mentions.Mentions {
|
||||
if userId == mid {
|
||||
if userID == mid {
|
||||
incrementMentions = true
|
||||
break
|
||||
}
|
||||
}
|
||||
nErr := a.Srv().Store.Thread().CreateMembershipIfNeeded(userId, post.RootId, true, incrementMentions, *a.Config().ServiceSettings.ThreadAutoFollow)
|
||||
nErr := a.Srv().Store.Thread().CreateMembershipIfNeeded(userID, post.RootId, true, incrementMentions, *a.Config().ServiceSettings.ThreadAutoFollow)
|
||||
if nErr != nil {
|
||||
mac <- model.NewAppError("SendNotifications", "app.channel.autofollow.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -205,9 +205,9 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
mentionedUsersList = append(mentionedUsersList, id)
|
||||
|
||||
umc := make(chan *model.AppError, 1)
|
||||
go func(userId string) {
|
||||
go func(userID string) {
|
||||
defer close(umc)
|
||||
nErr := a.Srv().Store.Channel().IncrementMentionCount(post.ChannelId, userId, *a.Config().ServiceSettings.ThreadAutoFollow)
|
||||
nErr := a.Srv().Store.Channel().IncrementMentionCount(post.ChannelId, userID, *a.Config().ServiceSettings.ThreadAutoFollow)
|
||||
if nErr != nil {
|
||||
umc <- model.NewAppError("SendNotifications", "app.channel.increment_mention_count.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -705,16 +705,16 @@ const (
|
||||
GroupMention
|
||||
)
|
||||
|
||||
func (m *ExplicitMentions) addMention(userId string, mentionType MentionType) {
|
||||
func (m *ExplicitMentions) addMention(userID string, mentionType MentionType) {
|
||||
if m.Mentions == nil {
|
||||
m.Mentions = make(map[string]MentionType)
|
||||
}
|
||||
|
||||
if currentType, ok := m.Mentions[userId]; ok && currentType >= mentionType {
|
||||
if currentType, ok := m.Mentions[userID]; ok && currentType >= mentionType {
|
||||
return
|
||||
}
|
||||
|
||||
m.Mentions[userId] = mentionType
|
||||
m.Mentions[userID] = mentionType
|
||||
}
|
||||
|
||||
func (m *ExplicitMentions) addGroupMention(word string, groups map[string]*model.Group) bool {
|
||||
@@ -745,14 +745,14 @@ func (m *ExplicitMentions) addGroupMention(word string, groups map[string]*model
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *ExplicitMentions) addMentions(userIds []string, mentionType MentionType) {
|
||||
for _, userId := range userIds {
|
||||
m.addMention(userId, mentionType)
|
||||
func (m *ExplicitMentions) addMentions(userIDs []string, mentionType MentionType) {
|
||||
for _, userID := range userIDs {
|
||||
m.addMention(userID, mentionType)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ExplicitMentions) removeMention(userId string) {
|
||||
delete(m.Mentions, userId)
|
||||
func (m *ExplicitMentions) removeMention(userID string) {
|
||||
delete(m.Mentions, userID)
|
||||
}
|
||||
|
||||
// Given a message and a map mapping mention keywords to the users who use them, returns a map of mentioned
|
||||
|
||||
@@ -41,7 +41,7 @@ type PushNotificationsHub struct {
|
||||
type PushNotification struct {
|
||||
notificationType notificationType
|
||||
currentSessionId string
|
||||
userId string
|
||||
userID string
|
||||
channelId string
|
||||
post *model.Post
|
||||
user *model.User
|
||||
@@ -74,8 +74,8 @@ func (a *App) sendPushNotificationSync(post *model.Post, user *model.User, chann
|
||||
return a.sendPushNotificationToAllSessions(msg, user.Id, "")
|
||||
}
|
||||
|
||||
func (a *App) sendPushNotificationToAllSessions(msg *model.PushNotification, userId string, skipSessionId string) *model.AppError {
|
||||
sessions, err := a.getMobileAppSessions(userId)
|
||||
func (a *App) sendPushNotificationToAllSessions(msg *model.PushNotification, userID string, skipSessionId string) *model.AppError {
|
||||
sessions, err := a.getMobileAppSessions(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -201,7 +201,7 @@ func (a *App) getPushNotificationMessage(contentsConfig, postMessage string, exp
|
||||
return senderName + userLocale("api.post.send_notifications_and_forget.push_general_message")
|
||||
}
|
||||
|
||||
func (a *App) clearPushNotificationSync(currentSessionId, userId, channelId string) *model.AppError {
|
||||
func (a *App) clearPushNotificationSync(currentSessionId, userID, channelId string) *model.AppError {
|
||||
msg := &model.PushNotification{
|
||||
Type: model.PUSH_TYPE_CLEAR,
|
||||
Version: model.PUSH_MESSAGE_V2,
|
||||
@@ -209,22 +209,22 @@ func (a *App) clearPushNotificationSync(currentSessionId, userId, channelId stri
|
||||
ContentAvailable: 1,
|
||||
}
|
||||
|
||||
unreadCount, err := a.Srv().Store.User().GetUnreadCount(userId)
|
||||
unreadCount, err := a.Srv().Store.User().GetUnreadCount(userID)
|
||||
if err != nil {
|
||||
return model.NewAppError("clearPushNotificationSync", "app.user.get_unread_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
msg.Badge = int(unreadCount)
|
||||
|
||||
return a.sendPushNotificationToAllSessions(msg, userId, currentSessionId)
|
||||
return a.sendPushNotificationToAllSessions(msg, userID, currentSessionId)
|
||||
}
|
||||
|
||||
func (a *App) clearPushNotification(currentSessionId, userId, channelId string) {
|
||||
func (a *App) clearPushNotification(currentSessionId, userID, channelId string) {
|
||||
select {
|
||||
case a.Srv().PushNotificationsHub.notificationsChan <- PushNotification{
|
||||
notificationType: notificationTypeClear,
|
||||
currentSessionId: currentSessionId,
|
||||
userId: userId,
|
||||
userID: userID,
|
||||
channelId: channelId,
|
||||
}:
|
||||
case <-a.Srv().PushNotificationsHub.stopChan:
|
||||
@@ -232,7 +232,7 @@ func (a *App) clearPushNotification(currentSessionId, userId, channelId string)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) updateMobileAppBadgeSync(userId string) *model.AppError {
|
||||
func (a *App) updateMobileAppBadgeSync(userID string) *model.AppError {
|
||||
msg := &model.PushNotification{
|
||||
Type: model.PUSH_TYPE_UPDATE_BADGE,
|
||||
Version: model.PUSH_MESSAGE_V2,
|
||||
@@ -240,21 +240,21 @@ func (a *App) updateMobileAppBadgeSync(userId string) *model.AppError {
|
||||
ContentAvailable: 1,
|
||||
}
|
||||
|
||||
unreadCount, err := a.Srv().Store.User().GetUnreadCount(userId)
|
||||
unreadCount, err := a.Srv().Store.User().GetUnreadCount(userID)
|
||||
if err != nil {
|
||||
return model.NewAppError("updateMobileAppBadgeSync", "app.user.get_unread_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
msg.Badge = int(unreadCount)
|
||||
|
||||
return a.sendPushNotificationToAllSessions(msg, userId, "")
|
||||
return a.sendPushNotificationToAllSessions(msg, userID, "")
|
||||
}
|
||||
|
||||
func (a *App) UpdateMobileAppBadge(userId string) {
|
||||
func (a *App) UpdateMobileAppBadge(userID string) {
|
||||
select {
|
||||
case a.Srv().PushNotificationsHub.notificationsChan <- PushNotification{
|
||||
notificationType: notificationTypeUpdateBadge,
|
||||
userId: userId,
|
||||
userID: userID,
|
||||
}:
|
||||
case <-a.Srv().PushNotificationsHub.stopChan:
|
||||
return
|
||||
@@ -307,7 +307,7 @@ func (hub *PushNotificationsHub) start() {
|
||||
var err *model.AppError
|
||||
switch notification.notificationType {
|
||||
case notificationTypeClear:
|
||||
err = hub.app.clearPushNotificationSync(notification.currentSessionId, notification.userId, notification.channelId)
|
||||
err = hub.app.clearPushNotificationSync(notification.currentSessionId, notification.userID, notification.channelId)
|
||||
case notificationTypeMessage:
|
||||
err = hub.app.sendPushNotificationSync(
|
||||
notification.post,
|
||||
@@ -320,7 +320,7 @@ func (hub *PushNotificationsHub) start() {
|
||||
notification.replyToThreadType,
|
||||
)
|
||||
case notificationTypeUpdateBadge:
|
||||
err = hub.app.updateMobileAppBadgeSync(notification.userId)
|
||||
err = hub.app.updateMobileAppBadgeSync(notification.userID)
|
||||
default:
|
||||
mlog.Debug("Invalid notification type", mlog.String("notification_type", string(notification.notificationType)))
|
||||
}
|
||||
@@ -429,8 +429,8 @@ func (a *App) SendAckToPushProxy(ack *model.PushNotificationAck) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) getMobileAppSessions(userId string) ([]*model.Session, *model.AppError) {
|
||||
sessions, err := a.Srv().Store.Session().GetSessionsWithActiveDeviceIds(userId)
|
||||
func (a *App) getMobileAppSessions(userID string) ([]*model.Session, *model.AppError) {
|
||||
sessions, err := a.Srv().Store.Session().GetSessionsWithActiveDeviceIds(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("getMobileAppSessions", "app.session.get_sessions.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -353,13 +353,13 @@ func TestDoesNotifyPropsAllowPushNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoesStatusAllowPushNotification(t *testing.T) {
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
channelId := model.NewId()
|
||||
|
||||
offline := &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
away := &model.Status{UserId: userId, Status: model.STATUS_AWAY, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
online := &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
dnd := &model.Status{UserId: userId, Status: model.STATUS_DND, Manual: true, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
offline := &model.Status{UserId: userID, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
away := &model.Status{UserId: userID, Status: model.STATUS_AWAY, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
online := &model.Status{UserId: userID, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
dnd := &model.Status{UserId: userID, Status: model.STATUS_DND, Manual: true, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
|
||||
tt := []struct {
|
||||
name string
|
||||
|
||||
@@ -1971,51 +1971,51 @@ func TestAddMention(t *testing.T) {
|
||||
t.Run("should initialize Mentions and store new mentions", func(t *testing.T) {
|
||||
m := &ExplicitMentions{}
|
||||
|
||||
userId1 := model.NewId()
|
||||
userId2 := model.NewId()
|
||||
userID1 := model.NewId()
|
||||
userID2 := model.NewId()
|
||||
|
||||
m.addMention(userId1, KeywordMention)
|
||||
m.addMention(userId2, CommentMention)
|
||||
m.addMention(userID1, KeywordMention)
|
||||
m.addMention(userID2, CommentMention)
|
||||
|
||||
assert.Equal(t, map[string]MentionType{
|
||||
userId1: KeywordMention,
|
||||
userId2: CommentMention,
|
||||
userID1: KeywordMention,
|
||||
userID2: CommentMention,
|
||||
}, m.Mentions)
|
||||
})
|
||||
|
||||
t.Run("should replace existing mentions with higher priority ones", func(t *testing.T) {
|
||||
m := &ExplicitMentions{}
|
||||
|
||||
userId1 := model.NewId()
|
||||
userId2 := model.NewId()
|
||||
userID1 := model.NewId()
|
||||
userID2 := model.NewId()
|
||||
|
||||
m.addMention(userId1, ThreadMention)
|
||||
m.addMention(userId2, DMMention)
|
||||
m.addMention(userID1, ThreadMention)
|
||||
m.addMention(userID2, DMMention)
|
||||
|
||||
m.addMention(userId1, ChannelMention)
|
||||
m.addMention(userId2, KeywordMention)
|
||||
m.addMention(userID1, ChannelMention)
|
||||
m.addMention(userID2, KeywordMention)
|
||||
|
||||
assert.Equal(t, map[string]MentionType{
|
||||
userId1: ChannelMention,
|
||||
userId2: KeywordMention,
|
||||
userID1: ChannelMention,
|
||||
userID2: KeywordMention,
|
||||
}, m.Mentions)
|
||||
})
|
||||
|
||||
t.Run("should not replace high priority mentions with low priority ones", func(t *testing.T) {
|
||||
m := &ExplicitMentions{}
|
||||
|
||||
userId1 := model.NewId()
|
||||
userId2 := model.NewId()
|
||||
userID1 := model.NewId()
|
||||
userID2 := model.NewId()
|
||||
|
||||
m.addMention(userId1, KeywordMention)
|
||||
m.addMention(userId2, CommentMention)
|
||||
m.addMention(userID1, KeywordMention)
|
||||
m.addMention(userID2, CommentMention)
|
||||
|
||||
m.addMention(userId1, DMMention)
|
||||
m.addMention(userId2, ThreadMention)
|
||||
m.addMention(userID1, DMMention)
|
||||
m.addMention(userID2, ThreadMention)
|
||||
|
||||
assert.Equal(t, map[string]MentionType{
|
||||
userId1: KeywordMention,
|
||||
userId2: CommentMention,
|
||||
userID1: KeywordMention,
|
||||
userID2: CommentMention,
|
||||
}, m.Mentions)
|
||||
})
|
||||
}
|
||||
|
||||
68
app/oauth.go
68
app/oauth.go
@@ -128,12 +128,12 @@ func (a *App) GetOAuthApps(page, perPage int) ([]*model.OAuthApp, *model.AppErro
|
||||
return oauthApps, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthAppsByCreator(userId string, page, perPage int) ([]*model.OAuthApp, *model.AppError) {
|
||||
func (a *App) GetOAuthAppsByCreator(userID string, page, perPage int) ([]*model.OAuthApp, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
return nil, model.NewAppError("GetOAuthAppsByUser", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
oauthApps, err := a.Srv().Store.OAuth().GetAppByUser(userId, page*perPage, perPage)
|
||||
oauthApps, err := a.Srv().Store.OAuth().GetAppByUser(userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetOAuthAppsByCreator", "app.oauth.get_app_by_user.find.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -141,8 +141,8 @@ func (a *App) GetOAuthAppsByCreator(userId string, page, perPage int) ([]*model.
|
||||
return oauthApps, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthImplicitRedirect(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
session, err := a.GetOAuthAccessTokenForImplicitFlow(userId, authRequest)
|
||||
func (a *App) GetOAuthImplicitRedirect(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
session, err := a.GetOAuthAccessTokenForImplicitFlow(userID, authRequest)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -157,8 +157,8 @@ func (a *App) GetOAuthImplicitRedirect(userId string, authRequest *model.Authori
|
||||
return fmt.Sprintf("%s#%s", authRequest.RedirectUri, values.Encode()), nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthCodeRedirect(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
authData := &model.AuthData{UserId: userId, ClientId: authRequest.ClientId, CreateAt: model.GetMillis(), RedirectUri: authRequest.RedirectUri, State: authRequest.State, Scope: authRequest.Scope}
|
||||
func (a *App) GetOAuthCodeRedirect(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
authData := &model.AuthData{UserId: userID, ClientId: authRequest.ClientId, CreateAt: model.GetMillis(), RedirectUri: authRequest.RedirectUri, State: authRequest.State, Scope: authRequest.Scope}
|
||||
authData.Code = model.NewId() + model.NewId()
|
||||
|
||||
if _, err := a.Srv().Store.OAuth().SaveAuthData(authData); err != nil {
|
||||
@@ -168,7 +168,7 @@ func (a *App) GetOAuthCodeRedirect(userId string, authRequest *model.AuthorizeRe
|
||||
return authRequest.RedirectUri + "?code=" + url.QueryEscape(authData.Code) + "&state=" + url.QueryEscape(authData.State), nil
|
||||
}
|
||||
|
||||
func (a *App) AllowOAuthAppAccessToUser(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
func (a *App) AllowOAuthAppAccessToUser(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
return "", model.NewAppError("AllowOAuthAppAccessToUser", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -196,9 +196,9 @@ func (a *App) AllowOAuthAppAccessToUser(userId string, authRequest *model.Author
|
||||
var err *model.AppError
|
||||
switch authRequest.ResponseType {
|
||||
case model.AUTHCODE_RESPONSE_TYPE:
|
||||
redirectURI, err = a.GetOAuthCodeRedirect(userId, authRequest)
|
||||
redirectURI, err = a.GetOAuthCodeRedirect(userID, authRequest)
|
||||
case model.IMPLICIT_RESPONSE_TYPE:
|
||||
redirectURI, err = a.GetOAuthImplicitRedirect(userId, authRequest)
|
||||
redirectURI, err = a.GetOAuthImplicitRedirect(userID, authRequest)
|
||||
default:
|
||||
return authRequest.RedirectUri + "?error=unsupported_response_type&state=" + authRequest.State, nil
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func (a *App) AllowOAuthAppAccessToUser(userId string, authRequest *model.Author
|
||||
|
||||
// This saves the OAuth2 app as authorized
|
||||
authorizedApp := model.Preference{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Category: model.PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP,
|
||||
Name: authRequest.ClientId,
|
||||
Value: authRequest.Scope,
|
||||
@@ -224,7 +224,7 @@ func (a *App) AllowOAuthAppAccessToUser(userId string, authRequest *model.Author
|
||||
return redirectURI, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthAccessTokenForImplicitFlow(userId string, authRequest *model.AuthorizeRequest) (*model.Session, *model.AppError) {
|
||||
func (a *App) GetOAuthAccessTokenForImplicitFlow(userID string, authRequest *model.AuthorizeRequest) (*model.Session, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -234,7 +234,7 @@ func (a *App) GetOAuthAccessTokenForImplicitFlow(userId string, authRequest *mod
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusNotFound)
|
||||
}
|
||||
|
||||
user, err := a.GetUser(userId)
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -409,11 +409,11 @@ func (a *App) newSessionUpdateToken(appName string, accessData *model.AccessData
|
||||
return accessRsp, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthLoginEndpoint(w http.ResponseWriter, r *http.Request, service, teamId, action, redirectTo, loginHint string, isMobile bool) (string, *model.AppError) {
|
||||
func (a *App) GetOAuthLoginEndpoint(w http.ResponseWriter, r *http.Request, service, teamID, action, redirectTo, loginHint string, isMobile bool) (string, *model.AppError) {
|
||||
stateProps := map[string]string{}
|
||||
stateProps["action"] = action
|
||||
if teamId != "" {
|
||||
stateProps["team_id"] = teamId
|
||||
if teamID != "" {
|
||||
stateProps["team_id"] = teamID
|
||||
}
|
||||
|
||||
if redirectTo != "" {
|
||||
@@ -430,11 +430,11 @@ func (a *App) GetOAuthLoginEndpoint(w http.ResponseWriter, r *http.Request, serv
|
||||
return authUrl, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthSignupEndpoint(w http.ResponseWriter, r *http.Request, service, teamId string) (string, *model.AppError) {
|
||||
func (a *App) GetOAuthSignupEndpoint(w http.ResponseWriter, r *http.Request, service, teamID string) (string, *model.AppError) {
|
||||
stateProps := map[string]string{}
|
||||
stateProps["action"] = model.OAUTH_ACTION_SIGNUP
|
||||
if teamId != "" {
|
||||
stateProps["team_id"] = teamId
|
||||
if teamID != "" {
|
||||
stateProps["team_id"] = teamID
|
||||
}
|
||||
|
||||
authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, "")
|
||||
@@ -445,12 +445,12 @@ func (a *App) GetOAuthSignupEndpoint(w http.ResponseWriter, r *http.Request, ser
|
||||
return authUrl, nil
|
||||
}
|
||||
|
||||
func (a *App) GetAuthorizedAppsForUser(userId string, page, perPage int) ([]*model.OAuthApp, *model.AppError) {
|
||||
func (a *App) GetAuthorizedAppsForUser(userID string, page, perPage int) ([]*model.OAuthApp, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
return nil, model.NewAppError("GetAuthorizedAppsForUser", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
apps, err := a.Srv().Store.OAuth().GetAuthorizedApps(userId, page*perPage, perPage)
|
||||
apps, err := a.Srv().Store.OAuth().GetAuthorizedApps(userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetAuthorizedAppsForUser", "app.oauth.get_apps.find.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -463,13 +463,13 @@ func (a *App) GetAuthorizedAppsForUser(userId string, page, perPage int) ([]*mod
|
||||
return apps, nil
|
||||
}
|
||||
|
||||
func (a *App) DeauthorizeOAuthAppForUser(userId, appId string) *model.AppError {
|
||||
func (a *App) DeauthorizeOAuthAppForUser(userID, appId string) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
return model.NewAppError("DeauthorizeOAuthAppForUser", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// Revoke app sessions
|
||||
accessData, err := a.Srv().Store.OAuth().GetAccessDataByUserForApp(userId, appId)
|
||||
accessData, err := a.Srv().Store.OAuth().GetAccessDataByUserForApp(userID, appId)
|
||||
if err != nil {
|
||||
return model.NewAppError("DeauthorizeOAuthAppForUser", "app.oauth.get_access_data_by_user_for_app.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -485,7 +485,7 @@ func (a *App) DeauthorizeOAuthAppForUser(userId, appId string) *model.AppError {
|
||||
}
|
||||
|
||||
// Deauthorize the app
|
||||
if err := a.Srv().Store.Preference().Delete(userId, model.PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP, appId); err != nil {
|
||||
if err := a.Srv().Store.Preference().Delete(userID, model.PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP, appId); err != nil {
|
||||
return model.NewAppError("DeauthorizeOAuthAppForUser", "app.preference.delete.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -544,22 +544,22 @@ func (a *App) RevokeAccessToken(token string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) CompleteOAuth(service string, body io.ReadCloser, teamId string, props map[string]string, tokenUser *model.User) (*model.User, *model.AppError) {
|
||||
func (a *App) CompleteOAuth(service string, body io.ReadCloser, teamID string, props map[string]string, tokenUser *model.User) (*model.User, *model.AppError) {
|
||||
defer body.Close()
|
||||
|
||||
action := props["action"]
|
||||
|
||||
switch action {
|
||||
case model.OAUTH_ACTION_SIGNUP:
|
||||
return a.CreateOAuthUser(service, body, teamId, tokenUser)
|
||||
return a.CreateOAuthUser(service, body, teamID, tokenUser)
|
||||
case model.OAUTH_ACTION_LOGIN:
|
||||
return a.LoginByOAuth(service, body, teamId, tokenUser)
|
||||
return a.LoginByOAuth(service, body, teamID, tokenUser)
|
||||
case model.OAUTH_ACTION_EMAIL_TO_SSO:
|
||||
return a.CompleteSwitchWithOAuth(service, body, props["email"], tokenUser)
|
||||
case model.OAUTH_ACTION_SSO_TO_EMAIL:
|
||||
return a.LoginByOAuth(service, body, teamId, tokenUser)
|
||||
return a.LoginByOAuth(service, body, teamID, tokenUser)
|
||||
default:
|
||||
return a.LoginByOAuth(service, body, teamId, tokenUser)
|
||||
return a.LoginByOAuth(service, body, teamID, tokenUser)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ func (a *App) getSSOProvider(service string) (einterfaces.OauthProvider, *model.
|
||||
return provider, nil
|
||||
}
|
||||
|
||||
func (a *App) LoginByOAuth(service string, userData io.Reader, teamId string, tokenUser *model.User) (*model.User, *model.AppError) {
|
||||
func (a *App) LoginByOAuth(service string, userData io.Reader, teamID string, tokenUser *model.User) (*model.User, *model.AppError) {
|
||||
provider, e := a.getSSOProvider(service)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
@@ -606,7 +606,7 @@ func (a *App) LoginByOAuth(service string, userData io.Reader, teamId string, to
|
||||
user, err := a.GetUserByAuth(model.NewString(*authUser.AuthData), service)
|
||||
if err != nil {
|
||||
if err.Id == MissingAuthAccountError {
|
||||
user, err = a.CreateOAuthUser(service, bytes.NewReader(buf.Bytes()), teamId, tokenUser)
|
||||
user, err = a.CreateOAuthUser(service, bytes.NewReader(buf.Bytes()), teamID, tokenUser)
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
@@ -621,8 +621,8 @@ func (a *App) LoginByOAuth(service string, userData io.Reader, teamId string, to
|
||||
if err = a.UpdateOAuthUserAttrs(bytes.NewReader(buf.Bytes()), user, provider, service, tokenUser); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if teamId != "" {
|
||||
err = a.AddUserToTeamByTeamId(teamId, user)
|
||||
if teamID != "" {
|
||||
err = a.AddUserToTeamByTeamId(teamID, user)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -833,7 +833,7 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
|
||||
|
||||
http.SetCookie(w, httpCookie)
|
||||
|
||||
teamId := stateProps["team_id"]
|
||||
teamID := stateProps["team_id"]
|
||||
|
||||
p := url.Values{}
|
||||
p.Set("client_id", *sso.Id)
|
||||
@@ -912,7 +912,7 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
|
||||
}
|
||||
|
||||
// Note that resp.Body is not closed here, so it must be closed by the caller
|
||||
return resp.Body, teamId, stateProps, userFromToken, nil
|
||||
return resp.Body, teamID, stateProps, userFromToken, nil
|
||||
}
|
||||
|
||||
func (a *App) SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email, password, code, service string) (string, *model.AppError) {
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -66,8 +66,8 @@ func (api *PluginAPI) RegisterCommand(command *model.Command) error {
|
||||
return api.app.RegisterPluginCommand(api.id, command)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UnregisterCommand(teamId, trigger string) error {
|
||||
api.app.UnregisterPluginCommand(api.id, teamId, trigger)
|
||||
func (api *PluginAPI) UnregisterCommand(teamID, trigger string) error {
|
||||
api.app.UnregisterPluginCommand(api.id, teamID, trigger)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -155,16 +155,16 @@ func (api *PluginAPI) CreateTeam(team *model.Team) (*model.Team, *model.AppError
|
||||
return api.app.CreateTeam(team)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteTeam(teamId string) *model.AppError {
|
||||
return api.app.SoftDeleteTeam(teamId)
|
||||
func (api *PluginAPI) DeleteTeam(teamID string) *model.AppError {
|
||||
return api.app.SoftDeleteTeam(teamID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeams() ([]*model.Team, *model.AppError) {
|
||||
return api.app.GetAllTeams()
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeam(teamId string) (*model.Team, *model.AppError) {
|
||||
return api.app.GetTeam(teamId)
|
||||
func (api *PluginAPI) GetTeam(teamID string) (*model.Team, *model.AppError) {
|
||||
return api.app.GetTeam(teamID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchTeams(term string) ([]*model.Team, *model.AppError) {
|
||||
@@ -176,64 +176,64 @@ func (api *PluginAPI) GetTeamByName(name string) (*model.Team, *model.AppError)
|
||||
return api.app.GetTeamByName(name)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamsUnreadForUser(userId string) ([]*model.TeamUnread, *model.AppError) {
|
||||
return api.app.GetTeamsUnreadForUser("", userId)
|
||||
func (api *PluginAPI) GetTeamsUnreadForUser(userID string) ([]*model.TeamUnread, *model.AppError) {
|
||||
return api.app.GetTeamsUnreadForUser("", userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
|
||||
return api.app.UpdateTeam(team)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) {
|
||||
return api.app.GetTeamsForUser(userId)
|
||||
func (api *PluginAPI) GetTeamsForUser(userID string) ([]*model.Team, *model.AppError) {
|
||||
return api.app.GetTeamsForUser(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) {
|
||||
return api.app.AddTeamMember(teamId, userId)
|
||||
func (api *PluginAPI) CreateTeamMember(teamID, userID string) (*model.TeamMember, *model.AppError) {
|
||||
return api.app.AddTeamMember(teamID, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateTeamMembers(teamId string, userIds []string, requestorId string) ([]*model.TeamMember, *model.AppError) {
|
||||
members, err := api.app.AddTeamMembers(teamId, userIds, requestorId, false)
|
||||
func (api *PluginAPI) CreateTeamMembers(teamID string, userIDs []string, requestorId string) ([]*model.TeamMember, *model.AppError) {
|
||||
members, err := api.app.AddTeamMembers(teamID, userIDs, requestorId, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.TeamMembersWithErrorToTeamMembers(members), nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateTeamMembersGracefully(teamId string, userIds []string, requestorId string) ([]*model.TeamMemberWithError, *model.AppError) {
|
||||
return api.app.AddTeamMembers(teamId, userIds, requestorId, true)
|
||||
func (api *PluginAPI) CreateTeamMembersGracefully(teamID string, userIDs []string, requestorId string) ([]*model.TeamMemberWithError, *model.AppError) {
|
||||
return api.app.AddTeamMembers(teamID, userIDs, requestorId, true)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteTeamMember(teamId, userId, requestorId string) *model.AppError {
|
||||
return api.app.RemoveUserFromTeam(teamId, userId, requestorId)
|
||||
func (api *PluginAPI) DeleteTeamMember(teamID, userID, requestorId string) *model.AppError {
|
||||
return api.app.RemoveUserFromTeam(teamID, userID, requestorId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamMembers(teamId string, page, perPage int) ([]*model.TeamMember, *model.AppError) {
|
||||
return api.app.GetTeamMembers(teamId, page*perPage, perPage, nil)
|
||||
func (api *PluginAPI) GetTeamMembers(teamID string, page, perPage int) ([]*model.TeamMember, *model.AppError) {
|
||||
return api.app.GetTeamMembers(teamID, page*perPage, perPage, nil)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) {
|
||||
return api.app.GetTeamMember(teamId, userId)
|
||||
func (api *PluginAPI) GetTeamMember(teamID, userID string) (*model.TeamMember, *model.AppError) {
|
||||
return api.app.GetTeamMember(teamID, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamMembersForUser(userId string, page int, perPage int) ([]*model.TeamMember, *model.AppError) {
|
||||
return api.app.GetTeamMembersForUserWithPagination(userId, page, perPage)
|
||||
func (api *PluginAPI) GetTeamMembersForUser(userID string, page int, perPage int) ([]*model.TeamMember, *model.AppError) {
|
||||
return api.app.GetTeamMembersForUserWithPagination(userID, page, perPage)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateTeamMemberRoles(teamId, userId, newRoles string) (*model.TeamMember, *model.AppError) {
|
||||
return api.app.UpdateTeamMemberRoles(teamId, userId, newRoles)
|
||||
func (api *PluginAPI) UpdateTeamMemberRoles(teamID, userID, newRoles string) (*model.TeamMember, *model.AppError) {
|
||||
return api.app.UpdateTeamMemberRoles(teamID, userID, newRoles)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamStats(teamId string) (*model.TeamStats, *model.AppError) {
|
||||
return api.app.GetTeamStats(teamId, nil)
|
||||
func (api *PluginAPI) GetTeamStats(teamID string) (*model.TeamStats, *model.AppError) {
|
||||
return api.app.GetTeamStats(teamID, nil)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateUser(user *model.User) (*model.User, *model.AppError) {
|
||||
return api.app.CreateUser(user)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteUser(userId string) *model.AppError {
|
||||
user, err := api.app.GetUser(userId)
|
||||
func (api *PluginAPI) DeleteUser(userID string) *model.AppError {
|
||||
user, err := api.app.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -245,8 +245,8 @@ func (api *PluginAPI) GetUsers(options *model.UserGetOptions) ([]*model.User, *m
|
||||
return api.app.GetUsers(options)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetUser(userId string) (*model.User, *model.AppError) {
|
||||
return api.app.GetUser(userId)
|
||||
func (api *PluginAPI) GetUser(userID string) (*model.User, *model.AppError) {
|
||||
return api.app.GetUser(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetUserByEmail(email string) (*model.User, *model.AppError) {
|
||||
@@ -261,54 +261,54 @@ func (api *PluginAPI) GetUsersByUsernames(usernames []string) ([]*model.User, *m
|
||||
return api.app.GetUsersByUsernames(usernames, true, nil)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetUsersInTeam(teamId string, page int, perPage int) ([]*model.User, *model.AppError) {
|
||||
options := &model.UserGetOptions{InTeamId: teamId, Page: page, PerPage: perPage}
|
||||
func (api *PluginAPI) GetUsersInTeam(teamID string, page int, perPage int) ([]*model.User, *model.AppError) {
|
||||
options := &model.UserGetOptions{InTeamId: teamID, Page: page, PerPage: perPage}
|
||||
return api.app.GetUsersInTeam(options)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPreferencesForUser(userId string) ([]model.Preference, *model.AppError) {
|
||||
return api.app.GetPreferencesForUser(userId)
|
||||
func (api *PluginAPI) GetPreferencesForUser(userID string) ([]model.Preference, *model.AppError) {
|
||||
return api.app.GetPreferencesForUser(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdatePreferencesForUser(userId string, preferences []model.Preference) *model.AppError {
|
||||
return api.app.UpdatePreferences(userId, preferences)
|
||||
func (api *PluginAPI) UpdatePreferencesForUser(userID string, preferences []model.Preference) *model.AppError {
|
||||
return api.app.UpdatePreferences(userID, preferences)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeletePreferencesForUser(userId string, preferences []model.Preference) *model.AppError {
|
||||
return api.app.DeletePreferences(userId, preferences)
|
||||
func (api *PluginAPI) DeletePreferencesForUser(userID string, preferences []model.Preference) *model.AppError {
|
||||
return api.app.DeletePreferences(userID, preferences)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateUser(user *model.User) (*model.User, *model.AppError) {
|
||||
return api.app.UpdateUser(user, true)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateUserActive(userId string, active bool) *model.AppError {
|
||||
return api.app.UpdateUserActive(userId, active)
|
||||
func (api *PluginAPI) UpdateUserActive(userID string, active bool) *model.AppError {
|
||||
return api.app.UpdateUserActive(userID, active)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetUserStatus(userId string) (*model.Status, *model.AppError) {
|
||||
return api.app.GetStatus(userId)
|
||||
func (api *PluginAPI) GetUserStatus(userID string) (*model.Status, *model.AppError) {
|
||||
return api.app.GetStatus(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) {
|
||||
return api.app.GetUserStatusesByIds(userIds)
|
||||
func (api *PluginAPI) GetUserStatusesByIds(userIDs []string) ([]*model.Status, *model.AppError) {
|
||||
return api.app.GetUserStatusesByIds(userIDs)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateUserStatus(userId, status string) (*model.Status, *model.AppError) {
|
||||
func (api *PluginAPI) UpdateUserStatus(userID, status string) (*model.Status, *model.AppError) {
|
||||
switch status {
|
||||
case model.STATUS_ONLINE:
|
||||
api.app.SetStatusOnline(userId, true)
|
||||
api.app.SetStatusOnline(userID, true)
|
||||
case model.STATUS_OFFLINE:
|
||||
api.app.SetStatusOffline(userId, true)
|
||||
api.app.SetStatusOffline(userID, true)
|
||||
case model.STATUS_AWAY:
|
||||
api.app.SetStatusAwayIfNeeded(userId, true)
|
||||
api.app.SetStatusAwayIfNeeded(userID, true)
|
||||
case model.STATUS_DND:
|
||||
api.app.SetStatusDoNotDisturb(userId)
|
||||
api.app.SetStatusDoNotDisturb(userID)
|
||||
default:
|
||||
return nil, model.NewAppError("UpdateUserStatus", "plugin.api.update_user_status.bad_status", nil, "unrecognized status", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return api.app.GetStatus(userId)
|
||||
return api.app.GetStatus(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetUsersInChannel(channelId, sortBy string, page, perPage int) ([]*model.User, *model.AppError) {
|
||||
@@ -330,12 +330,12 @@ func (api *PluginAPI) GetUsersInChannel(channelId, sortBy string, page, perPage
|
||||
}
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetLDAPUserAttributes(userId string, attributes []string) (map[string]string, *model.AppError) {
|
||||
func (api *PluginAPI) GetLDAPUserAttributes(userID string, attributes []string) (map[string]string, *model.AppError) {
|
||||
if api.app.Ldap() == nil {
|
||||
return nil, model.NewAppError("GetLdapUserAttributes", "ent.ldap.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
user, err := api.app.GetUser(userId)
|
||||
user, err := api.app.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -365,8 +365,8 @@ func (api *PluginAPI) DeleteChannel(channelId string) *model.AppError {
|
||||
return api.app.DeleteChannel(channel, "")
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPublicChannelsForTeam(teamId string, page, perPage int) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.GetPublicChannelsForTeam(teamId, page*perPage, perPage)
|
||||
func (api *PluginAPI) GetPublicChannelsForTeam(teamID string, page, perPage int) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.GetPublicChannelsForTeam(teamID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -377,16 +377,16 @@ func (api *PluginAPI) GetChannel(channelId string) (*model.Channel, *model.AppEr
|
||||
return api.app.GetChannel(channelId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelByName(teamId, name string, includeDeleted bool) (*model.Channel, *model.AppError) {
|
||||
return api.app.GetChannelByName(name, teamId, includeDeleted)
|
||||
func (api *PluginAPI) GetChannelByName(teamID, name string, includeDeleted bool) (*model.Channel, *model.AppError) {
|
||||
return api.app.GetChannelByName(name, teamID, includeDeleted)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelByNameForTeamName(teamName, channelName string, includeDeleted bool) (*model.Channel, *model.AppError) {
|
||||
return api.app.GetChannelByNameForTeamName(channelName, teamName, includeDeleted)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.GetChannelsForUser(teamId, userId, includeDeleted, 0)
|
||||
func (api *PluginAPI) GetChannelsForTeamForUser(teamID, userID string, includeDeleted bool) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.GetChannelsForUser(teamID, userID, includeDeleted, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -405,20 +405,20 @@ func (api *PluginAPI) GetChannelStats(channelId string) (*model.ChannelStats, *m
|
||||
return &model.ChannelStats{ChannelId: channelId, MemberCount: memberCount, GuestCount: guestCount}, nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError) {
|
||||
return api.app.GetOrCreateDirectChannel(userId1, userId2)
|
||||
func (api *PluginAPI) GetDirectChannel(userID1, userID2 string) (*model.Channel, *model.AppError) {
|
||||
return api.app.GetOrCreateDirectChannel(userID1, userID2)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
|
||||
return api.app.CreateGroupChannel(userIds, "")
|
||||
func (api *PluginAPI) GetGroupChannel(userIDs []string) (*model.Channel, *model.AppError) {
|
||||
return api.app.CreateGroupChannel(userIDs, "")
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
|
||||
return api.app.UpdateChannel(channel)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchChannels(teamId string, term string) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.SearchChannels(teamId, term)
|
||||
func (api *PluginAPI) SearchChannels(teamID string, term string) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.SearchChannels(teamID, term)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -434,15 +434,15 @@ func (api *PluginAPI) SearchUsers(search *model.UserSearch) ([]*model.User, *mod
|
||||
return api.app.SearchUsers(search, pluginSearchUsersOptions)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchPostsInTeam(teamId string, paramsList []*model.SearchParams) ([]*model.Post, *model.AppError) {
|
||||
postList, err := api.app.SearchPostsInTeam(teamId, paramsList)
|
||||
func (api *PluginAPI) SearchPostsInTeam(teamID string, paramsList []*model.SearchParams) ([]*model.Post, *model.AppError) {
|
||||
postList, err := api.app.SearchPostsInTeam(teamID, paramsList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return postList.ToSlice(), nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchPostsInTeamForUser(teamId string, userId string, searchParams model.SearchParameter) (*model.PostSearchResults, *model.AppError) {
|
||||
func (api *PluginAPI) SearchPostsInTeamForUser(teamID string, userID string, searchParams model.SearchParameter) (*model.PostSearchResults, *model.AppError) {
|
||||
var terms string
|
||||
if searchParams.Terms != nil {
|
||||
terms = *searchParams.Terms
|
||||
@@ -473,10 +473,10 @@ func (api *PluginAPI) SearchPostsInTeamForUser(teamId string, userId string, sea
|
||||
includeDeletedChannels = *searchParams.IncludeDeletedChannels
|
||||
}
|
||||
|
||||
return api.app.SearchPostsInTeamForUser(terms, userId, teamId, isOrSearch, includeDeletedChannels, timeZoneOffset, page, perPage)
|
||||
return api.app.SearchPostsInTeamForUser(terms, userID, teamID, isOrSearch, includeDeletedChannels, timeZoneOffset, page, perPage)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) AddChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
func (api *PluginAPI) AddChannelMember(channelId, userID string) (*model.ChannelMember, *model.AppError) {
|
||||
// For now, don't allow overriding these via the plugin API.
|
||||
userRequestorId := ""
|
||||
postRootId := ""
|
||||
@@ -486,10 +486,10 @@ func (api *PluginAPI) AddChannelMember(channelId, userId string) (*model.Channel
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api.app.AddChannelMember(userId, channel, userRequestorId, postRootId)
|
||||
return api.app.AddChannelMember(userID, channel, userRequestorId, postRootId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) AddUserToChannel(channelId, userId, asUserId string) (*model.ChannelMember, *model.AppError) {
|
||||
func (api *PluginAPI) AddUserToChannel(channelId, userID, asUserId string) (*model.ChannelMember, *model.AppError) {
|
||||
postRootId := ""
|
||||
|
||||
channel, err := api.GetChannel(channelId)
|
||||
@@ -497,35 +497,35 @@ func (api *PluginAPI) AddUserToChannel(channelId, userId, asUserId string) (*mod
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api.app.AddChannelMember(userId, channel, asUserId, postRootId)
|
||||
return api.app.AddChannelMember(userID, channel, asUserId, postRootId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
return api.app.GetChannelMember(channelId, userId)
|
||||
func (api *PluginAPI) GetChannelMember(channelId, userID string) (*model.ChannelMember, *model.AppError) {
|
||||
return api.app.GetChannelMember(channelId, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelMembers(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError) {
|
||||
return api.app.GetChannelMembersPage(channelId, page, perPage)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) {
|
||||
return api.app.GetChannelMembersByIds(channelId, userIds)
|
||||
func (api *PluginAPI) GetChannelMembersByIds(channelId string, userIDs []string) (*model.ChannelMembers, *model.AppError) {
|
||||
return api.app.GetChannelMembersByIds(channelId, userIDs)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelMembersForUser(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
||||
return api.app.GetChannelMembersForUserWithPagination(teamId, userId, page, perPage)
|
||||
func (api *PluginAPI) GetChannelMembersForUser(teamID, userID string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
||||
return api.app.GetChannelMembersForUserWithPagination(teamID, userID, page, perPage)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateChannelMemberRoles(channelId, userId, newRoles string) (*model.ChannelMember, *model.AppError) {
|
||||
return api.app.UpdateChannelMemberRoles(channelId, userId, newRoles)
|
||||
func (api *PluginAPI) UpdateChannelMemberRoles(channelId, userID, newRoles string) (*model.ChannelMember, *model.AppError) {
|
||||
return api.app.UpdateChannelMemberRoles(channelId, userID, newRoles)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateChannelMemberNotifications(channelId, userId string, notifications map[string]string) (*model.ChannelMember, *model.AppError) {
|
||||
return api.app.UpdateChannelMemberNotifyProps(notifications, channelId, userId)
|
||||
func (api *PluginAPI) UpdateChannelMemberNotifications(channelId, userID string, notifications map[string]string) (*model.ChannelMember, *model.AppError) {
|
||||
return api.app.UpdateChannelMemberNotifyProps(notifications, channelId, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteChannelMember(channelId, userId string) *model.AppError {
|
||||
return api.app.LeaveChannel(channelId, userId)
|
||||
func (api *PluginAPI) DeleteChannelMember(channelId, userID string) *model.AppError {
|
||||
return api.app.LeaveChannel(channelId, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroup(groupId string) (*model.Group, *model.AppError) {
|
||||
@@ -536,8 +536,8 @@ func (api *PluginAPI) GetGroupByName(name string) (*model.Group, *model.AppError
|
||||
return api.app.GetGroupByName(name, model.GroupSearchOpts{})
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroupsForUser(userId string) ([]*model.Group, *model.AppError) {
|
||||
return api.app.GetGroupsByUserId(userId)
|
||||
func (api *PluginAPI) GetGroupsForUser(userID string) ([]*model.Group, *model.AppError) {
|
||||
return api.app.GetGroupsByUserId(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
|
||||
@@ -556,16 +556,16 @@ func (api *PluginAPI) GetReactions(postId string) ([]*model.Reaction, *model.App
|
||||
return api.app.GetReactionsForPost(postId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SendEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
return api.app.SendEphemeralPost(userId, post)
|
||||
func (api *PluginAPI) SendEphemeralPost(userID string, post *model.Post) *model.Post {
|
||||
return api.app.SendEphemeralPost(userID, post)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
return api.app.UpdateEphemeralPost(userId, post)
|
||||
func (api *PluginAPI) UpdateEphemeralPost(userID string, post *model.Post) *model.Post {
|
||||
return api.app.UpdateEphemeralPost(userID, post)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteEphemeralPost(userId, postId string) {
|
||||
api.app.DeleteEphemeralPost(userId, postId)
|
||||
func (api *PluginAPI) DeleteEphemeralPost(userID, postId string) {
|
||||
api.app.DeleteEphemeralPost(userID, postId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeletePost(postId string) *model.AppError {
|
||||
@@ -601,8 +601,8 @@ func (api *PluginAPI) UpdatePost(post *model.Post) (*model.Post, *model.AppError
|
||||
return api.app.UpdatePost(post, false)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetProfileImage(userId string) ([]byte, *model.AppError) {
|
||||
user, err := api.app.GetUser(userId)
|
||||
func (api *PluginAPI) GetProfileImage(userID string) ([]byte, *model.AppError) {
|
||||
user, err := api.app.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -611,13 +611,13 @@ func (api *PluginAPI) GetProfileImage(userId string) ([]byte, *model.AppError) {
|
||||
return data, err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SetProfileImage(userId string, data []byte) *model.AppError {
|
||||
_, err := api.app.GetUser(userId)
|
||||
func (api *PluginAPI) SetProfileImage(userID string, data []byte) *model.AppError {
|
||||
_, err := api.app.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return api.app.SetProfileImageFromFile(userId, bytes.NewReader(data))
|
||||
return api.app.SetProfileImageFromFile(userID, bytes.NewReader(data))
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetEmojiList(sortBy string, page, perPage int) ([]*model.Emoji, *model.AppError) {
|
||||
@@ -632,8 +632,8 @@ func (api *PluginAPI) GetEmoji(emojiId string) (*model.Emoji, *model.AppError) {
|
||||
return api.app.GetEmoji(emojiId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CopyFileInfos(userId string, fileIds []string) ([]string, *model.AppError) {
|
||||
return api.app.CopyFileInfos(userId, fileIds)
|
||||
func (api *PluginAPI) CopyFileInfos(userID string, fileIds []string) ([]string, *model.AppError) {
|
||||
return api.app.CopyFileInfos(userID, fileIds)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetFileInfo(fileId string) (*model.FileInfo, *model.AppError) {
|
||||
@@ -677,8 +677,8 @@ func (api *PluginAPI) GetEmojiImage(emojiId string) ([]byte, string, *model.AppE
|
||||
return api.app.GetEmojiImage(emojiId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamIcon(teamId string) ([]byte, *model.AppError) {
|
||||
team, err := api.app.GetTeam(teamId)
|
||||
func (api *PluginAPI) GetTeamIcon(teamID string) ([]byte, *model.AppError) {
|
||||
team, err := api.app.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -690,8 +690,8 @@ func (api *PluginAPI) GetTeamIcon(teamId string) ([]byte, *model.AppError) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SetTeamIcon(teamId string, data []byte) *model.AppError {
|
||||
team, err := api.app.GetTeam(teamId)
|
||||
func (api *PluginAPI) SetTeamIcon(teamID string, data []byte) *model.AppError {
|
||||
team, err := api.app.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -703,13 +703,13 @@ func (api *PluginAPI) OpenInteractiveDialog(dialog model.OpenDialogRequest) *mod
|
||||
return api.app.OpenInteractiveDialog(dialog)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
_, err := api.app.GetTeam(teamId)
|
||||
func (api *PluginAPI) RemoveTeamIcon(teamID string) *model.AppError {
|
||||
_, err := api.app.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = api.app.RemoveTeamIcon(teamId)
|
||||
err = api.app.RemoveTeamIcon(teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -824,16 +824,16 @@ func (api *PluginAPI) PublishWebSocketEvent(event string, payload map[string]int
|
||||
api.app.Publish(ev)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) HasPermissionTo(userId string, permission *model.Permission) bool {
|
||||
return api.app.HasPermissionTo(userId, permission)
|
||||
func (api *PluginAPI) HasPermissionTo(userID string, permission *model.Permission) bool {
|
||||
return api.app.HasPermissionTo(userID, permission)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) HasPermissionToTeam(userId, teamId string, permission *model.Permission) bool {
|
||||
return api.app.HasPermissionToTeam(userId, teamId, permission)
|
||||
func (api *PluginAPI) HasPermissionToTeam(userID, teamID string, permission *model.Permission) bool {
|
||||
return api.app.HasPermissionToTeam(userID, teamID, permission)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) HasPermissionToChannel(userId, channelId string, permission *model.Permission) bool {
|
||||
return api.app.HasPermissionToChannel(userId, channelId, permission)
|
||||
func (api *PluginAPI) HasPermissionToChannel(userID, channelId string, permission *model.Permission) bool {
|
||||
return api.app.HasPermissionToChannel(userID, channelId, permission)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) LogDebug(msg string, keyValuePairs ...interface{}) {
|
||||
@@ -865,12 +865,12 @@ func (api *PluginAPI) CreateBot(bot *model.Bot) (*model.Bot, *model.AppError) {
|
||||
return api.app.CreateBot(bot)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) PatchBot(userId string, botPatch *model.BotPatch) (*model.Bot, *model.AppError) {
|
||||
return api.app.PatchBot(userId, botPatch)
|
||||
func (api *PluginAPI) PatchBot(userID string, botPatch *model.BotPatch) (*model.Bot, *model.AppError) {
|
||||
return api.app.PatchBot(userID, botPatch)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetBot(userId string, includeDeleted bool) (*model.Bot, *model.AppError) {
|
||||
return api.app.GetBot(userId, includeDeleted)
|
||||
func (api *PluginAPI) GetBot(userID string, includeDeleted bool) (*model.Bot, *model.AppError) {
|
||||
return api.app.GetBot(userID, includeDeleted)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetBots(options *model.BotGetOptions) ([]*model.Bot, *model.AppError) {
|
||||
@@ -879,40 +879,40 @@ func (api *PluginAPI) GetBots(options *model.BotGetOptions) ([]*model.Bot, *mode
|
||||
return []*model.Bot(bots), err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateBotActive(userId string, active bool) (*model.Bot, *model.AppError) {
|
||||
return api.app.UpdateBotActive(userId, active)
|
||||
func (api *PluginAPI) UpdateBotActive(userID string, active bool) (*model.Bot, *model.AppError) {
|
||||
return api.app.UpdateBotActive(userID, active)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) PermanentDeleteBot(userId string) *model.AppError {
|
||||
return api.app.PermanentDeleteBot(userId)
|
||||
func (api *PluginAPI) PermanentDeleteBot(userID string) *model.AppError {
|
||||
return api.app.PermanentDeleteBot(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetBotIconImage(userId string) ([]byte, *model.AppError) {
|
||||
if _, err := api.app.GetBot(userId, true); err != nil {
|
||||
func (api *PluginAPI) GetBotIconImage(userID string) ([]byte, *model.AppError) {
|
||||
if _, err := api.app.GetBot(userID, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api.app.GetBotIconImage(userId)
|
||||
return api.app.GetBotIconImage(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SetBotIconImage(userId string, data []byte) *model.AppError {
|
||||
if _, err := api.app.GetBot(userId, true); err != nil {
|
||||
func (api *PluginAPI) SetBotIconImage(userID string, data []byte) *model.AppError {
|
||||
if _, err := api.app.GetBot(userID, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return api.app.SetBotIconImage(userId, bytes.NewReader(data))
|
||||
return api.app.SetBotIconImage(userID, bytes.NewReader(data))
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteBotIconImage(userId string) *model.AppError {
|
||||
if _, err := api.app.GetBot(userId, true); err != nil {
|
||||
func (api *PluginAPI) DeleteBotIconImage(userID string) *model.AppError {
|
||||
if _, err := api.app.GetBot(userID, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return api.app.DeleteBotIconImage(userId)
|
||||
return api.app.DeleteBotIconImage(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) PublishUserTyping(userId, channelId, parentId string) *model.AppError {
|
||||
return api.app.PublishUserTyping(userId, channelId, parentId)
|
||||
func (api *PluginAPI) PublishUserTyping(userID, channelId, parentId string) *model.AppError {
|
||||
return api.app.PublishUserTyping(userID, channelId, parentId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) PluginHTTP(request *http.Request) *http.Response {
|
||||
|
||||
@@ -1275,10 +1275,10 @@ func TestPluginCreatePostWithUploadedFile(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, data, actualData)
|
||||
|
||||
userId := th.BasicUser.Id
|
||||
userID := th.BasicUser.Id
|
||||
post, err := api.CreatePost(&model.Post{
|
||||
Message: "test",
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
ChannelId: channelId,
|
||||
FileIds: model.StringArray{fileInfo.Id},
|
||||
})
|
||||
@@ -1711,8 +1711,8 @@ func TestPluginAPISearchPostsInTeamByUser(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
description string
|
||||
teamId string
|
||||
userId string
|
||||
teamID string
|
||||
userID string
|
||||
params model.SearchParameter
|
||||
expectedPostsLen int
|
||||
}{
|
||||
@@ -1741,7 +1741,7 @@ func TestPluginAPISearchPostsInTeamByUser(t *testing.T) {
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.description, func(t *testing.T) {
|
||||
searchResults, err := api.SearchPostsInTeamForUser(testCase.teamId, testCase.userId, testCase.params)
|
||||
searchResults, err := api.SearchPostsInTeamForUser(testCase.teamID, testCase.userID, testCase.params)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, testCase.expectedPostsLen, len(searchResults.Posts))
|
||||
})
|
||||
@@ -1753,7 +1753,7 @@ func TestPluginAPICreateCommandAndListCommands(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
foundCommand := func(listXCommand func(teamId string) ([]*model.Command, error)) bool {
|
||||
foundCommand := func(listXCommand func(teamID string) ([]*model.Command, error)) bool {
|
||||
cmds, appErr := listXCommand(th.BasicTeam.Id)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ func (a *App) RegisterPluginCommand(pluginId string, command *model.Command) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UnregisterPluginCommand(pluginId, teamId, trigger string) {
|
||||
func (a *App) UnregisterPluginCommand(pluginId, teamID, trigger string) {
|
||||
trigger = strings.ToLower(trigger)
|
||||
|
||||
a.Srv().pluginCommandsLock.Lock()
|
||||
@@ -80,7 +80,7 @@ func (a *App) UnregisterPluginCommand(pluginId, teamId, trigger string) {
|
||||
|
||||
var remaining []*PluginCommand
|
||||
for _, pc := range a.Srv().pluginCommands {
|
||||
if pc.Command.TeamId != teamId || pc.Command.Trigger != trigger {
|
||||
if pc.Command.TeamId != teamID || pc.Command.Trigger != trigger {
|
||||
remaining = append(remaining, pc)
|
||||
}
|
||||
}
|
||||
@@ -100,13 +100,13 @@ func (a *App) UnregisterPluginCommands(pluginId string) {
|
||||
a.Srv().pluginCommands = remaining
|
||||
}
|
||||
|
||||
func (a *App) PluginCommandsForTeam(teamId string) []*model.Command {
|
||||
func (a *App) PluginCommandsForTeam(teamID string) []*model.Command {
|
||||
a.Srv().pluginCommandsLock.RLock()
|
||||
defer a.Srv().pluginCommandsLock.RUnlock()
|
||||
|
||||
var commands []*model.Command
|
||||
for _, pc := range a.Srv().pluginCommands {
|
||||
if pc.Command.TeamId == "" || pc.Command.TeamId == teamId {
|
||||
if pc.Command.TeamId == "" || pc.Command.TeamId == teamID {
|
||||
commands = append(commands, pc.Command)
|
||||
}
|
||||
}
|
||||
@@ -148,8 +148,8 @@ func (a *App) tryExecutePluginCommand(args *model.CommandArgs) (*model.Command,
|
||||
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command.error.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for username, userId := range a.MentionsToTeamMembers(args.Command, args.TeamId) {
|
||||
args.AddUserMention(username, userId)
|
||||
for username, userID := range a.MentionsToTeamMembers(args.Command, args.TeamId) {
|
||||
args.AddUserMention(username, userID)
|
||||
}
|
||||
|
||||
for channelName, channelId := range a.MentionsToPublicChannels(args.Command, args.TeamId) {
|
||||
|
||||
@@ -157,18 +157,18 @@ func (a *App) servePluginRequest(w http.ResponseWriter, r *http.Request, handler
|
||||
if r.Header.Get(model.HEADER_REQUESTED_WITH) == model.HEADER_REQUESTED_WITH_XML && !csrfCheckPassed {
|
||||
csrfErrorMessage := "CSRF Check failed for request - Please migrate your plugin to either send a CSRF Header or Form Field, XMLHttpRequest is deprecated"
|
||||
sid := ""
|
||||
userId := ""
|
||||
userID := ""
|
||||
|
||||
if session != nil {
|
||||
sid = session.Id
|
||||
userId = session.UserId
|
||||
userID = session.UserId
|
||||
}
|
||||
|
||||
fields := []mlog.Field{
|
||||
mlog.String("path", r.URL.Path),
|
||||
mlog.String("ip", r.RemoteAddr),
|
||||
mlog.String("session_id", sid),
|
||||
mlog.String("user_id", userId),
|
||||
mlog.String("user_id", userID),
|
||||
}
|
||||
|
||||
if *a.Config().ServiceSettings.ExperimentalStrictCSRFEnforcement {
|
||||
|
||||
80
app/post.go
80
app/post.go
@@ -483,7 +483,7 @@ func (a *App) handlePostEvents(post *model.Post, user *model.User, channel *mode
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
func (a *App) SendEphemeralPost(userID string, post *model.Post) *model.Post {
|
||||
post.Type = model.POST_EPHEMERAL
|
||||
|
||||
// fill in fields which haven't been specified which have sensible defaults
|
||||
@@ -498,7 +498,7 @@ func (a *App) SendEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
}
|
||||
|
||||
post.GenerateActionIds()
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_EPHEMERAL_MESSAGE, "", post.ChannelId, userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_EPHEMERAL_MESSAGE, "", post.ChannelId, userID, nil)
|
||||
post = a.PreparePostForClient(post, true, false)
|
||||
post = model.AddPostActionCookies(post, a.PostActionCookieSecret())
|
||||
message.Add("post", post.ToJson())
|
||||
@@ -507,7 +507,7 @@ func (a *App) SendEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) UpdateEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
func (a *App) UpdateEphemeralPost(userID string, post *model.Post) *model.Post {
|
||||
post.Type = model.POST_EPHEMERAL
|
||||
|
||||
post.UpdateAt = model.GetMillis()
|
||||
@@ -516,7 +516,7 @@ func (a *App) UpdateEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
}
|
||||
|
||||
post.GenerateActionIds()
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_EDITED, "", post.ChannelId, userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_EDITED, "", post.ChannelId, userID, nil)
|
||||
post = a.PreparePostForClient(post, true, false)
|
||||
post = model.AddPostActionCookies(post, a.PostActionCookieSecret())
|
||||
message.Add("post", post.ToJson())
|
||||
@@ -525,16 +525,16 @@ func (a *App) UpdateEphemeralPost(userId string, post *model.Post) *model.Post {
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) DeleteEphemeralPost(userId, postId string) {
|
||||
func (a *App) DeleteEphemeralPost(userID, postId string) {
|
||||
post := &model.Post{
|
||||
Id: postId,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Type: model.POST_EPHEMERAL,
|
||||
DeleteAt: model.GetMillis(),
|
||||
UpdateAt: model.GetMillis(),
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_DELETED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_DELETED, "", "", userID, nil)
|
||||
message.Add("post", post.ToJson())
|
||||
a.Publish(message)
|
||||
}
|
||||
@@ -764,8 +764,8 @@ func (a *App) GetPostThread(postId string, skipFetchThreads, collapsedThreads, c
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (a *App) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPosts(userId, offset, limit)
|
||||
func (a *App) GetFlaggedPosts(userID string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPosts(userID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetFlaggedPosts", "app.post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -773,8 +773,8 @@ func (a *App) GetFlaggedPosts(userId string, offset int, limit int) (*model.Post
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPostsForTeam(userId, teamId, offset, limit)
|
||||
func (a *App) GetFlaggedPostsForTeam(userID, teamID string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPostsForTeam(userID, teamID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetFlaggedPostsForTeam", "app.post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -782,8 +782,8 @@ func (a *App) GetFlaggedPostsForTeam(userId, teamId string, offset int, limit in
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPostsForChannel(userId, channelId, offset, limit)
|
||||
func (a *App) GetFlaggedPostsForChannel(userID, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPostsForChannel(userID, channelId, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetFlaggedPostsForChannel", "app.post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -791,7 +791,7 @@ func (a *App) GetFlaggedPostsForChannel(userId, channelId string, offset int, li
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPermalinkPost(postId string, userId string) (*model.PostList, *model.AppError) {
|
||||
func (a *App) GetPermalinkPost(postId string, userID string) (*model.PostList, *model.AppError) {
|
||||
list, nErr := a.Srv().Store.Post().Get(postId, false, false, false)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
@@ -816,7 +816,7 @@ func (a *App) GetPermalinkPost(postId string, userId string) (*model.PostList, *
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = a.JoinChannel(channel, userId); err != nil {
|
||||
if err = a.JoinChannel(channel, userID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -975,10 +975,10 @@ func (a *App) AddCursorIdsForPostList(originalList *model.PostList, afterPost, b
|
||||
originalList.NextPostId = nextPostId
|
||||
originalList.PrevPostId = prevPostId
|
||||
}
|
||||
func (a *App) GetPostsForChannelAroundLastUnread(channelId, userId string, limitBefore, limitAfter int, skipFetchThreads bool, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, *model.AppError) {
|
||||
func (a *App) GetPostsForChannelAroundLastUnread(channelId, userID string, limitBefore, limitAfter int, skipFetchThreads bool, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, *model.AppError) {
|
||||
var member *model.ChannelMember
|
||||
var err *model.AppError
|
||||
if member, err = a.GetChannelMember(channelId, userId); err != nil {
|
||||
if member, err = a.GetChannelMember(channelId, userID); err != nil {
|
||||
return nil, err
|
||||
} else if member.LastViewedAt == 0 {
|
||||
return model.NewPostList(), nil
|
||||
@@ -1083,18 +1083,18 @@ func (a *App) DeletePostFiles(post *model.Post) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) parseAndFetchChannelIdByNameFromInFilter(channelName, userId, teamId string, includeDeleted bool) (*model.Channel, error) {
|
||||
func (a *App) parseAndFetchChannelIdByNameFromInFilter(channelName, userID, teamID string, includeDeleted bool) (*model.Channel, error) {
|
||||
if strings.HasPrefix(channelName, "@") && strings.Contains(channelName, ",") {
|
||||
var userIds []string
|
||||
var userIDs []string
|
||||
users, err := a.GetUsersByUsernames(strings.Split(channelName[1:], ","), false, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, user := range users {
|
||||
userIds = append(userIds, user.Id)
|
||||
userIDs = append(userIDs, user.Id)
|
||||
}
|
||||
|
||||
channel, err := a.GetGroupChannel(userIds)
|
||||
channel, err := a.GetGroupChannel(userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1106,21 +1106,21 @@ func (a *App) parseAndFetchChannelIdByNameFromInFilter(channelName, userId, team
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
channel, err := a.GetOrCreateDirectChannel(userId, user.Id)
|
||||
channel, err := a.GetOrCreateDirectChannel(userID, user.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
channel, err := a.GetChannelByName(channelName, teamId, includeDeleted)
|
||||
channel, err := a.GetChannelByName(channelName, teamID, includeDeleted)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (a *App) searchPostsInTeam(teamId string, userId string, paramsList []*model.SearchParams, modifierFun func(*model.SearchParams)) (*model.PostList, *model.AppError) {
|
||||
func (a *App) searchPostsInTeam(teamID string, userID string, paramsList []*model.SearchParams, modifierFun func(*model.SearchParams)) (*model.PostList, *model.AppError) {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
pchan := make(chan store.StoreResult, len(paramsList))
|
||||
@@ -1135,7 +1135,7 @@ func (a *App) searchPostsInTeam(teamId string, userId string, paramsList []*mode
|
||||
|
||||
go func(params *model.SearchParams) {
|
||||
defer wg.Done()
|
||||
postList, err := a.Srv().Store.Post().Search(teamId, userId, params)
|
||||
postList, err := a.Srv().Store.Post().Search(teamID, userID, params)
|
||||
pchan <- store.StoreResult{Data: postList, NErr: err}
|
||||
}(params)
|
||||
}
|
||||
@@ -1157,9 +1157,9 @@ func (a *App) searchPostsInTeam(teamId string, userId string, paramsList []*mode
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (a *App) convertChannelNamesToChannelIds(channels []string, userId string, teamId string, includeDeletedChannels bool) []string {
|
||||
func (a *App) convertChannelNamesToChannelIds(channels []string, userID string, teamID string, includeDeletedChannels bool) []string {
|
||||
for idx, channelName := range channels {
|
||||
channel, err := a.parseAndFetchChannelIdByNameFromInFilter(channelName, userId, teamId, includeDeletedChannels)
|
||||
channel, err := a.parseAndFetchChannelIdByNameFromInFilter(channelName, userID, teamID, includeDeletedChannels)
|
||||
if err != nil {
|
||||
mlog.Warn("error getting channel id by name from in filter", mlog.Err(err))
|
||||
continue
|
||||
@@ -1181,22 +1181,22 @@ func (a *App) convertUserNameToUserIds(usernames []string) []string {
|
||||
return usernames
|
||||
}
|
||||
|
||||
func (a *App) SearchPostsInTeam(teamId string, paramsList []*model.SearchParams) (*model.PostList, *model.AppError) {
|
||||
func (a *App) SearchPostsInTeam(teamID string, paramsList []*model.SearchParams) (*model.PostList, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnablePostSearch {
|
||||
return nil, model.NewAppError("SearchPostsInTeam", "store.sql_post.search.disabled", nil, fmt.Sprintf("teamId=%v", teamId), http.StatusNotImplemented)
|
||||
return nil, model.NewAppError("SearchPostsInTeam", "store.sql_post.search.disabled", nil, fmt.Sprintf("teamId=%v", teamID), http.StatusNotImplemented)
|
||||
}
|
||||
return a.searchPostsInTeam(teamId, "", paramsList, func(params *model.SearchParams) {
|
||||
return a.searchPostsInTeam(teamID, "", paramsList, func(params *model.SearchParams) {
|
||||
params.SearchWithoutUserId = true
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (a *App) SearchPostsInTeamForUser(terms string, userID string, teamID string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
var postSearchResults *model.PostSearchResults
|
||||
paramsList := model.ParseSearchParams(strings.TrimSpace(terms), timeZoneOffset)
|
||||
includeDeleted := includeDeletedChannels && *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
if !*a.Config().ServiceSettings.EnablePostSearch {
|
||||
return nil, model.NewAppError("SearchPostsInTeamForUser", "store.sql_post.search.disabled", nil, fmt.Sprintf("teamId=%v userId=%v", teamId, userId), http.StatusNotImplemented)
|
||||
return nil, model.NewAppError("SearchPostsInTeamForUser", "store.sql_post.search.disabled", nil, fmt.Sprintf("teamId=%v userId=%v", teamID, userID), http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
finalParamsList := []*model.SearchParams{}
|
||||
@@ -1207,8 +1207,8 @@ func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId strin
|
||||
// Don't allow users to search for "*"
|
||||
if params.Terms != "*" {
|
||||
// Convert channel names to channel IDs
|
||||
params.InChannels = a.convertChannelNamesToChannelIds(params.InChannels, userId, teamId, includeDeletedChannels)
|
||||
params.ExcludedChannels = a.convertChannelNamesToChannelIds(params.ExcludedChannels, userId, teamId, includeDeletedChannels)
|
||||
params.InChannels = a.convertChannelNamesToChannelIds(params.InChannels, userID, teamID, includeDeletedChannels)
|
||||
params.ExcludedChannels = a.convertChannelNamesToChannelIds(params.ExcludedChannels, userID, teamID, includeDeletedChannels)
|
||||
|
||||
// Convert usernames to user IDs
|
||||
params.FromUsers = a.convertUserNameToUserIds(params.FromUsers)
|
||||
@@ -1223,7 +1223,7 @@ func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId strin
|
||||
return model.MakePostSearchResults(model.NewPostList(), nil), nil
|
||||
}
|
||||
|
||||
postSearchResults, nErr := a.Srv().Store.Post().SearchPostsInTeamForUser(finalParamsList, userId, teamId, page, perPage)
|
||||
postSearchResults, nErr := a.Srv().Store.Post().SearchPostsInTeamForUser(finalParamsList, userID, teamID, page, perPage)
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
@@ -1342,7 +1342,7 @@ func (a *App) MaxPostSize() int {
|
||||
}
|
||||
|
||||
// countThreadMentions returns the number of times the user is mentioned in a specified thread after the timestamp.
|
||||
func (a *App) countThreadMentions(user *model.User, post *model.Post, teamId string, timestamp int64) (int64, *model.AppError) {
|
||||
func (a *App) countThreadMentions(user *model.User, post *model.Post, teamID string, timestamp int64) (int64, *model.AppError) {
|
||||
channel, err := a.GetChannel(post.ChannelId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -1376,8 +1376,8 @@ func (a *App) countThreadMentions(user *model.User, post *model.Post, teamId str
|
||||
}
|
||||
|
||||
var team *model.Team
|
||||
if teamId != "" {
|
||||
team, err = a.GetTeam(teamId)
|
||||
if teamID != "" {
|
||||
team, err = a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -1543,6 +1543,6 @@ func isPostMention(user *model.User, post *model.Post, keywords map[string][]str
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *App) GetThreadMembershipsForUser(userId, teamId string) ([]*model.ThreadMembership, error) {
|
||||
return a.Srv().Store.Thread().GetMembershipsForUser(userId, teamId)
|
||||
func (a *App) GetThreadMembershipsForUser(userID, teamID string) ([]*model.ThreadMembership, error) {
|
||||
return a.Srv().Store.Thread().GetMembershipsForUser(userID, teamID)
|
||||
}
|
||||
|
||||
@@ -624,13 +624,13 @@ func TestDeletePostWithFileAttachments(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
// Create a post with a file attachment.
|
||||
teamId := th.BasicTeam.Id
|
||||
teamID := th.BasicTeam.Id
|
||||
channelId := th.BasicChannel.Id
|
||||
userId := th.BasicUser.Id
|
||||
userID := th.BasicUser.Id
|
||||
filename := "test"
|
||||
data := []byte("abcd")
|
||||
|
||||
info1, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamId, channelId, userId, filename, data)
|
||||
info1, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamID, channelId, userID, filename, data)
|
||||
require.Nil(t, err)
|
||||
defer func() {
|
||||
th.App.Srv().Store.FileInfo().PermanentDelete(info1.Id)
|
||||
@@ -641,7 +641,7 @@ func TestDeletePostWithFileAttachments(t *testing.T) {
|
||||
Message: "asd",
|
||||
ChannelId: channelId,
|
||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
CreateAt: 0,
|
||||
FileIds: []string{info1.Id},
|
||||
}
|
||||
@@ -650,7 +650,7 @@ func TestDeletePostWithFileAttachments(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Delete the post.
|
||||
post, err = th.App.DeletePost(post.Id, userId)
|
||||
post, err = th.App.DeletePost(post.Id, userID)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Wait for the cleanup routine to finish.
|
||||
|
||||
@@ -10,16 +10,16 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
func (a *App) GetPreferencesForUser(userId string) (model.Preferences, *model.AppError) {
|
||||
preferences, err := a.Srv().Store.Preference().GetAll(userId)
|
||||
func (a *App) GetPreferencesForUser(userID string) (model.Preferences, *model.AppError) {
|
||||
preferences, err := a.Srv().Store.Preference().GetAll(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPreferencesForUser", "app.preference.get_all.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
return preferences, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPreferenceByCategoryForUser(userId string, category string) (model.Preferences, *model.AppError) {
|
||||
preferences, err := a.Srv().Store.Preference().GetCategory(userId, category)
|
||||
func (a *App) GetPreferenceByCategoryForUser(userID string, category string) (model.Preferences, *model.AppError) {
|
||||
preferences, err := a.Srv().Store.Preference().GetCategory(userID, category)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPreferenceByCategoryForUser", "app.preference.get_category.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -30,19 +30,19 @@ func (a *App) GetPreferenceByCategoryForUser(userId string, category string) (mo
|
||||
return preferences, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPreferenceByCategoryAndNameForUser(userId string, category string, preferenceName string) (*model.Preference, *model.AppError) {
|
||||
res, err := a.Srv().Store.Preference().Get(userId, category, preferenceName)
|
||||
func (a *App) GetPreferenceByCategoryAndNameForUser(userID string, category string, preferenceName string) (*model.Preference, *model.AppError) {
|
||||
res, err := a.Srv().Store.Preference().Get(userID, category, preferenceName)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPreferenceByCategoryAndNameForUser", "app.preference.get.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdatePreferences(userId string, preferences model.Preferences) *model.AppError {
|
||||
func (a *App) UpdatePreferences(userID string, preferences model.Preferences) *model.AppError {
|
||||
for _, preference := range preferences {
|
||||
if userId != preference.UserId {
|
||||
if userID != preference.UserId {
|
||||
return model.NewAppError("savePreferences", "api.preference.update_preferences.set.app_error", nil,
|
||||
"userId="+userId+", preference.UserId="+preference.UserId, http.StatusForbidden)
|
||||
"userId="+userID+", preference.UserId="+preference.UserId, http.StatusForbidden)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,28 +60,28 @@ func (a *App) UpdatePreferences(userId string, preferences model.Preferences) *m
|
||||
return model.NewAppError("UpdatePreferences", "api.preference.update_preferences.update_sidebar.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, "", "", userID, nil)
|
||||
// TODO this needs to be updated to include information on which categories changed
|
||||
a.Publish(message)
|
||||
|
||||
message = model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PREFERENCES_CHANGED, "", "", userId, nil)
|
||||
message = model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PREFERENCES_CHANGED, "", "", userID, nil)
|
||||
message.Add("preferences", preferences.ToJson())
|
||||
a.Publish(message)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) DeletePreferences(userId string, preferences model.Preferences) *model.AppError {
|
||||
func (a *App) DeletePreferences(userID string, preferences model.Preferences) *model.AppError {
|
||||
for _, preference := range preferences {
|
||||
if userId != preference.UserId {
|
||||
if userID != preference.UserId {
|
||||
err := model.NewAppError("DeletePreferences", "api.preference.delete_preferences.delete.app_error", nil,
|
||||
"userId="+userId+", preference.UserId="+preference.UserId, http.StatusForbidden)
|
||||
"userId="+userID+", preference.UserId="+preference.UserId, http.StatusForbidden)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, preference := range preferences {
|
||||
if err := a.Srv().Store.Preference().Delete(userId, preference.Category, preference.Name); err != nil {
|
||||
if err := a.Srv().Store.Preference().Delete(userID, preference.Category, preference.Name); err != nil {
|
||||
return model.NewAppError("DeletePreferences", "app.preference.delete.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
@@ -90,11 +90,11 @@ func (a *App) DeletePreferences(userId string, preferences model.Preferences) *m
|
||||
return model.NewAppError("DeletePreferences", "api.preference.delete_preferences.update_sidebar.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, "", "", userID, nil)
|
||||
// TODO this needs to be updated to include information on which categories changed
|
||||
a.Publish(message)
|
||||
|
||||
message = model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PREFERENCES_DELETED, "", "", userId, nil)
|
||||
message = model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PREFERENCES_DELETED, "", "", userID, nil)
|
||||
message.Add("preferences", preferences.ToJson())
|
||||
a.Publish(message)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ func cleanupVersion(originalVersion string) string {
|
||||
return strings.Join(versionPartsOut, ".")
|
||||
}
|
||||
|
||||
func noticeMatchesConditions(config *model.Config, preferences store.PreferenceStore, userId string,
|
||||
func noticeMatchesConditions(config *model.Config, preferences store.PreferenceStore, userID string,
|
||||
client model.NoticeClientType, clientVersion string, postCount int64, userCount int64, isSystemAdmin bool,
|
||||
isTeamAdmin bool, isCloud bool, sku string, notice *model.ProductNotice) (bool, error) {
|
||||
cnd := notice.Conditions
|
||||
@@ -153,7 +153,7 @@ func noticeMatchesConditions(config *model.Config, preferences store.PreferenceS
|
||||
|
||||
// check if user's config matches the notice
|
||||
for k, v := range cnd.UserConfig {
|
||||
res, err := validateUserConfigEntry(preferences, userId, k, v)
|
||||
res, err := validateUserConfigEntry(preferences, userID, k, v)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func noticeMatchesConditions(config *model.Config, preferences store.PreferenceS
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func validateUserConfigEntry(preferences store.PreferenceStore, userId string, key string, expectedValue interface{}) (bool, error) {
|
||||
func validateUserConfigEntry(preferences store.PreferenceStore, userID string, key string, expectedValue interface{}) (bool, error) {
|
||||
parts := strings.Split(key, ".")
|
||||
if len(parts) != 2 {
|
||||
return false, errors.New("Invalid format of user config. Must be in form of Category.SettingName")
|
||||
@@ -180,7 +180,7 @@ func validateUserConfigEntry(preferences store.PreferenceStore, userId string, k
|
||||
if _, ok := expectedValue.(string); !ok {
|
||||
return false, errors.New("Invalid format of user config. Value should be string")
|
||||
}
|
||||
pref, err := preferences.Get(userId, parts[0], parts[1])
|
||||
pref, err := preferences.Get(userID, parts[0], parts[1])
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@@ -204,9 +204,9 @@ func validateConfigEntry(conf *model.Config, path string, expectedValue interfac
|
||||
}
|
||||
|
||||
// GetProductNotices is called from the frontend to fetch the product notices that are relevant to the caller
|
||||
func (a *App) GetProductNotices(userId, teamId string, client model.NoticeClientType, clientVersion string, locale string) (model.NoticeMessages, *model.AppError) {
|
||||
func (a *App) GetProductNotices(userID, teamID string, client model.NoticeClientType, clientVersion string, locale string) (model.NoticeMessages, *model.AppError) {
|
||||
isSystemAdmin := a.SessionHasPermissionTo(*a.Session(), model.PERMISSION_MANAGE_SYSTEM)
|
||||
isTeamAdmin := a.SessionHasPermissionToTeam(*a.Session(), teamId, model.PERMISSION_MANAGE_TEAM)
|
||||
isTeamAdmin := a.SessionHasPermissionToTeam(*a.Session(), teamID, model.PERMISSION_MANAGE_TEAM)
|
||||
|
||||
// check if notices for regular users are disabled
|
||||
if !*a.Srv().Config().AnnouncementSettings.UserNoticesEnabled && !isSystemAdmin {
|
||||
@@ -218,7 +218,7 @@ func (a *App) GetProductNotices(userId, teamId string, client model.NoticeClient
|
||||
return []model.NoticeMessage{}, nil
|
||||
}
|
||||
|
||||
views, err := a.Srv().Store.ProductNotices().GetViews(userId)
|
||||
views, err := a.Srv().Store.ProductNotices().GetViews(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetProductNotices", "api.system.update_viewed_notices.failed", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -253,7 +253,7 @@ func (a *App) GetProductNotices(userId, teamId string, client model.NoticeClient
|
||||
result, err := noticeMatchesConditions(
|
||||
a.Config(),
|
||||
a.Srv().Store.Preference(),
|
||||
userId,
|
||||
userID,
|
||||
client,
|
||||
clientVersion,
|
||||
cachedPostCount,
|
||||
@@ -281,8 +281,8 @@ func (a *App) GetProductNotices(userId, teamId string, client model.NoticeClient
|
||||
}
|
||||
|
||||
// UpdateViewedProductNotices is called from the frontend to mark a set of notices as 'viewed' by user
|
||||
func (a *App) UpdateViewedProductNotices(userId string, noticeIds []string) *model.AppError {
|
||||
if err := a.Srv().Store.ProductNotices().View(userId, noticeIds); err != nil {
|
||||
func (a *App) UpdateViewedProductNotices(userID string, noticeIds []string) *model.AppError {
|
||||
if err := a.Srv().Store.ProductNotices().View(userID, noticeIds); err != nil {
|
||||
return model.NewAppError("UpdateViewedProductNotices", "api.system.update_viewed_notices.failed", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
return nil
|
||||
@@ -290,13 +290,13 @@ func (a *App) UpdateViewedProductNotices(userId string, noticeIds []string) *mod
|
||||
|
||||
// UpdateViewedProductNoticesForNewUser is called when new user is created to mark all current notices for this
|
||||
// user as viewed in order to avoid showing them imminently on first login
|
||||
func (a *App) UpdateViewedProductNoticesForNewUser(userId string) {
|
||||
func (a *App) UpdateViewedProductNoticesForNewUser(userID string) {
|
||||
var noticeIds []string
|
||||
for _, notice := range cachedNotices {
|
||||
noticeIds = append(noticeIds, notice.ID)
|
||||
}
|
||||
if err := a.Srv().Store.ProductNotices().View(userId, noticeIds); err != nil {
|
||||
mlog.Error("Cannot update product notices viewed state for user", mlog.String("userId", userId))
|
||||
if err := a.Srv().Store.ProductNotices().View(userID, noticeIds); err != nil {
|
||||
mlog.Error("Cannot update product notices viewed state for user", mlog.String("userId", userID))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ func (rl *RateLimiter) RateLimitWriter(key string, w http.ResponseWriter) bool {
|
||||
return limited
|
||||
}
|
||||
|
||||
func (rl *RateLimiter) UserIdRateLimit(userId string, w http.ResponseWriter) bool {
|
||||
func (rl *RateLimiter) UserIdRateLimit(userID string, w http.ResponseWriter) bool {
|
||||
if rl.useAuth {
|
||||
return rl.RateLimitWriter(userId, w)
|
||||
return rl.RateLimitWriter(userID, w)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -144,9 +144,9 @@ func (a *App) GetSession(token string) (*model.Session, *model.AppError) {
|
||||
return session, nil
|
||||
}
|
||||
|
||||
func (a *App) GetSessions(userId string) ([]*model.Session, *model.AppError) {
|
||||
func (a *App) GetSessions(userID string) ([]*model.Session, *model.AppError) {
|
||||
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userId)
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetSessions", "app.session.get_sessions.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -154,10 +154,10 @@ func (a *App) GetSessions(userId string) ([]*model.Session, *model.AppError) {
|
||||
return sessions, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateSessionsIsGuest(userId string, isGuest bool) {
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userId)
|
||||
func (a *App) UpdateSessionsIsGuest(userID string, isGuest bool) {
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userID)
|
||||
if err != nil {
|
||||
mlog.Error("Unable to get user sessions", mlog.String("user_id", userId), mlog.Err(err))
|
||||
mlog.Error("Unable to get user sessions", mlog.String("user_id", userID), mlog.Err(err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -172,8 +172,8 @@ func (a *App) UpdateSessionsIsGuest(userId string, isGuest bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) RevokeAllSessions(userId string) *model.AppError {
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userId)
|
||||
func (a *App) RevokeAllSessions(userID string) *model.AppError {
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userID)
|
||||
if err != nil {
|
||||
return model.NewAppError("RevokeAllSessions", "app.session.get_sessions.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -187,7 +187,7 @@ func (a *App) RevokeAllSessions(userId string) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
a.ClearSessionCacheForUser(userId)
|
||||
a.ClearSessionCacheForUser(userID)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -209,14 +209,14 @@ func (a *App) RevokeSessionsFromAllUsers() *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ClearSessionCacheForUser(userId string) {
|
||||
a.ClearSessionCacheForUserSkipClusterSend(userId)
|
||||
func (a *App) ClearSessionCacheForUser(userID string) {
|
||||
a.ClearSessionCacheForUserSkipClusterSend(userID)
|
||||
|
||||
if a.Cluster() != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER,
|
||||
SendType: model.CLUSTER_SEND_RELIABLE,
|
||||
Data: userId,
|
||||
Data: userID,
|
||||
}
|
||||
a.Cluster().SendClusterMessage(msg)
|
||||
}
|
||||
@@ -234,12 +234,12 @@ func (a *App) ClearSessionCacheForAllUsers() {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) ClearSessionCacheForUserSkipClusterSend(userId string) {
|
||||
func (a *App) ClearSessionCacheForUserSkipClusterSend(userID string) {
|
||||
if keys, err := a.Srv().sessionCache.Keys(); err == nil {
|
||||
var session *model.Session
|
||||
for _, key := range keys {
|
||||
if err := a.Srv().sessionCache.Get(key, &session); err == nil {
|
||||
if session.UserId == userId {
|
||||
if session.UserId == userID {
|
||||
a.Srv().sessionCache.Remove(key)
|
||||
if a.Metrics() != nil {
|
||||
a.Metrics().IncrementMemCacheInvalidationCounterSession()
|
||||
@@ -249,7 +249,7 @@ func (a *App) ClearSessionCacheForUserSkipClusterSend(userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
a.InvalidateWebConnSessionCacheForUser(userId)
|
||||
a.InvalidateWebConnSessionCacheForUser(userID)
|
||||
}
|
||||
|
||||
func (a *App) ClearSessionCacheForAllUsersSkipClusterSend() {
|
||||
@@ -268,14 +268,14 @@ func (a *App) SessionCacheLength() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *App) RevokeSessionsForDeviceId(userId string, deviceId string, currentSessionId string) *model.AppError {
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userId)
|
||||
func (a *App) RevokeSessionsForDeviceId(userID string, deviceId string, currentSessionId string) *model.AppError {
|
||||
sessions, err := a.Srv().Store.Session().GetSessions(userID)
|
||||
if err != nil {
|
||||
return model.NewAppError("RevokeSessionsForDeviceId", "app.session.get_sessions.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
for _, session := range sessions {
|
||||
if session.DeviceId == deviceId && session.Id != currentSessionId {
|
||||
mlog.Debug("Revoking sessionId for userId. Re-login with the same device Id", mlog.String("session_id", session.Id), mlog.String("user_id", userId))
|
||||
mlog.Debug("Revoking sessionId for userId. Re-login with the same device Id", mlog.String("session_id", session.Id), mlog.String("user_id", userID))
|
||||
if err := a.RevokeSession(session); err != nil {
|
||||
mlog.Warn("Could not revoke session for device", mlog.String("device_id", deviceId), mlog.Err(err))
|
||||
}
|
||||
@@ -590,8 +590,8 @@ func (a *App) GetUserAccessTokens(page, perPage int) ([]*model.UserAccessToken,
|
||||
return tokens, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUserAccessTokensForUser(userId string, page, perPage int) ([]*model.UserAccessToken, *model.AppError) {
|
||||
tokens, err := a.Srv().Store.UserAccessToken().GetByUser(userId, page*perPage, perPage)
|
||||
func (a *App) GetUserAccessTokensForUser(userID string, page, perPage int) ([]*model.UserAccessToken, *model.AppError) {
|
||||
tokens, err := a.Srv().Store.UserAccessToken().GetByUser(userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUserAccessTokensForUser", "app.user_access_token.get_by_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -603,8 +603,8 @@ func (a *App) GetUserAccessTokensForUser(userId string, page, perPage int) ([]*m
|
||||
|
||||
}
|
||||
|
||||
func (a *App) GetUserAccessToken(tokenId string, sanitize bool) (*model.UserAccessToken, *model.AppError) {
|
||||
token, err := a.Srv().Store.UserAccessToken().Get(tokenId)
|
||||
func (a *App) GetUserAccessToken(tokenID string, sanitize bool) (*model.UserAccessToken, *model.AppError) {
|
||||
token, err := a.Srv().Store.UserAccessToken().Get(tokenID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
|
||||
@@ -82,13 +82,13 @@ func expandAnnouncement(text string) string {
|
||||
func replaceUserIds(userStore store.UserStore, text string) string {
|
||||
rgx, err := regexp.Compile("<@([a-zA-Z0-9]+)>")
|
||||
if err == nil {
|
||||
userIds := make([]string, 0)
|
||||
userIDs := make([]string, 0)
|
||||
matches := rgx.FindAllStringSubmatch(text, -1)
|
||||
for _, match := range matches {
|
||||
userIds = append(userIds, match[1])
|
||||
userIDs = append(userIDs, match[1])
|
||||
}
|
||||
|
||||
if users, err := userStore.GetProfileByIds(userIds, nil, true); err == nil {
|
||||
if users, err := userStore.GetProfileByIds(userIDs, nil, true); err == nil {
|
||||
for _, user := range users {
|
||||
text = strings.Replace(text, "<@"+user.Id+">", "@"+user.Username, -1)
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ func TestProcessSlackText(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
userId := th.BasicUser.Id
|
||||
userID := th.BasicUser.Id
|
||||
username := th.BasicUser.Username
|
||||
if th.App.ProcessSlackText("<@"+userId+"> hello") != "@"+username+" hello" {
|
||||
if th.App.ProcessSlackText("<@"+userID+"> hello") != "@"+username+" hello" {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func TestProcessSlackAnnouncement(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
userId := th.BasicUser.Id
|
||||
userID := th.BasicUser.Id
|
||||
username := th.BasicUser.Username
|
||||
|
||||
attachments := []*model.SlackAttachment{
|
||||
@@ -53,13 +53,13 @@ func TestProcessSlackAnnouncement(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
Pretext: "<@" + userId + "> pretext",
|
||||
Text: "<@" + userId + "> text",
|
||||
Title: "<@" + userId + "> title",
|
||||
Pretext: "<@" + userID + "> pretext",
|
||||
Text: "<@" + userID + "> text",
|
||||
Title: "<@" + userID + "> title",
|
||||
Fields: []*model.SlackAttachmentField{
|
||||
{
|
||||
Title: "foo",
|
||||
Value: "<@" + userId + "> bar",
|
||||
Value: "<@" + userID + "> bar",
|
||||
Short: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
type AutoChannelCreator struct {
|
||||
a *app.App
|
||||
userId string
|
||||
userID string
|
||||
team *model.Team
|
||||
Fuzzy bool
|
||||
DisplayNameLen utils.Range
|
||||
@@ -21,11 +21,11 @@ type AutoChannelCreator struct {
|
||||
ChannelType string
|
||||
}
|
||||
|
||||
func NewAutoChannelCreator(a *app.App, team *model.Team, userId string) *AutoChannelCreator {
|
||||
func NewAutoChannelCreator(a *app.App, team *model.Team, userID string) *AutoChannelCreator {
|
||||
return &AutoChannelCreator{
|
||||
a: a,
|
||||
team: team,
|
||||
userId: userId,
|
||||
userID: userID,
|
||||
Fuzzy: false,
|
||||
DisplayNameLen: ChannelDisplayNameLen,
|
||||
DisplayNameCharset: utils.ALPHANUMERIC,
|
||||
@@ -49,7 +49,7 @@ func (cfg *AutoChannelCreator) createRandomChannel() (*model.Channel, error) {
|
||||
DisplayName: displayName,
|
||||
Name: name,
|
||||
Type: cfg.ChannelType,
|
||||
CreatorId: cfg.userId,
|
||||
CreatorId: cfg.userID,
|
||||
}
|
||||
|
||||
channel, err := cfg.a.CreateChannel(channel, true)
|
||||
|
||||
@@ -254,7 +254,7 @@ func (th *TestHelper) createChannel(team *model.Team, channelType string) *model
|
||||
return channel
|
||||
}
|
||||
|
||||
func (th *TestHelper) createChannelWithAnotherUser(team *model.Team, channelType, userId string) *model.Channel {
|
||||
func (th *TestHelper) createChannelWithAnotherUser(team *model.Team, channelType, userID string) *model.Channel {
|
||||
id := model.NewId()
|
||||
|
||||
channel := &model.Channel{
|
||||
@@ -262,7 +262,7 @@ func (th *TestHelper) createChannelWithAnotherUser(team *model.Team, channelType
|
||||
Name: "name_" + id,
|
||||
Type: channelType,
|
||||
TeamId: team.Id,
|
||||
CreatorId: userId,
|
||||
CreatorId: userID,
|
||||
}
|
||||
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
@@ -35,18 +35,18 @@ func (a *App) GetAllStatuses() map[string]*model.Status {
|
||||
}
|
||||
|
||||
statusMap := map[string]*model.Status{}
|
||||
if userIds, err := a.Srv().statusCache.Keys(); err == nil {
|
||||
for _, userId := range userIds {
|
||||
status := a.GetStatusFromCache(userId)
|
||||
if userIDs, err := a.Srv().statusCache.Keys(); err == nil {
|
||||
for _, userID := range userIDs {
|
||||
status := a.GetStatusFromCache(userID)
|
||||
if status != nil {
|
||||
statusMap[userId] = status
|
||||
statusMap[userID] = status
|
||||
}
|
||||
}
|
||||
}
|
||||
return statusMap
|
||||
}
|
||||
|
||||
func (a *App) GetStatusesByIds(userIds []string) (map[string]interface{}, *model.AppError) {
|
||||
func (a *App) GetStatusesByIds(userIDs []string) (map[string]interface{}, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return map[string]interface{}{}, nil
|
||||
}
|
||||
@@ -55,15 +55,15 @@ func (a *App) GetStatusesByIds(userIds []string) (map[string]interface{}, *model
|
||||
metrics := a.Metrics()
|
||||
|
||||
missingUserIds := []string{}
|
||||
for _, userId := range userIds {
|
||||
for _, userID := range userIDs {
|
||||
var status *model.Status
|
||||
if err := a.Srv().statusCache.Get(userId, &status); err == nil {
|
||||
statusMap[userId] = status.Status
|
||||
if err := a.Srv().statusCache.Get(userID, &status); err == nil {
|
||||
statusMap[userID] = status.Status
|
||||
if metrics != nil {
|
||||
metrics.IncrementMemCacheHitCounter("Status")
|
||||
}
|
||||
} else {
|
||||
missingUserIds = append(missingUserIds, userId)
|
||||
missingUserIds = append(missingUserIds, userID)
|
||||
if metrics != nil {
|
||||
metrics.IncrementMemCacheMissCounter("Status")
|
||||
}
|
||||
@@ -84,9 +84,9 @@ func (a *App) GetStatusesByIds(userIds []string) (map[string]interface{}, *model
|
||||
}
|
||||
|
||||
// For the case where the user does not have a row in the Status table and cache
|
||||
for _, userId := range missingUserIds {
|
||||
if _, ok := statusMap[userId]; !ok {
|
||||
statusMap[userId] = model.STATUS_OFFLINE
|
||||
for _, userID := range missingUserIds {
|
||||
if _, ok := statusMap[userID]; !ok {
|
||||
statusMap[userID] = model.STATUS_OFFLINE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (a *App) GetStatusesByIds(userIds []string) (map[string]interface{}, *model
|
||||
}
|
||||
|
||||
//GetUserStatusesByIds used by apiV4
|
||||
func (a *App) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) {
|
||||
func (a *App) GetUserStatusesByIds(userIDs []string) ([]*model.Status, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return []*model.Status{}, nil
|
||||
}
|
||||
@@ -103,15 +103,15 @@ func (a *App) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.Ap
|
||||
metrics := a.Metrics()
|
||||
|
||||
missingUserIds := []string{}
|
||||
for _, userId := range userIds {
|
||||
for _, userID := range userIDs {
|
||||
var status *model.Status
|
||||
if err := a.Srv().statusCache.Get(userId, &status); err == nil {
|
||||
if err := a.Srv().statusCache.Get(userID, &status); err == nil {
|
||||
statusMap = append(statusMap, status)
|
||||
if metrics != nil {
|
||||
metrics.IncrementMemCacheHitCounter("Status")
|
||||
}
|
||||
} else {
|
||||
missingUserIds = append(missingUserIds, userId)
|
||||
missingUserIds = append(missingUserIds, userID)
|
||||
if metrics != nil {
|
||||
metrics.IncrementMemCacheMissCounter("Status")
|
||||
}
|
||||
@@ -145,8 +145,8 @@ func (a *App) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.Ap
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, userId := range missingUserIds {
|
||||
statusMap = append(statusMap, &model.Status{UserId: userId, Status: "offline"})
|
||||
for _, userID := range missingUserIds {
|
||||
statusMap = append(statusMap, &model.Status{UserId: userID, Status: "offline"})
|
||||
}
|
||||
|
||||
return statusMap, nil
|
||||
@@ -155,20 +155,20 @@ func (a *App) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.Ap
|
||||
// SetStatusLastActivityAt sets the last activity at for a user on the local app server and updates
|
||||
// status to away if needed. Used by the WS to set status to away if an 'online' device disconnects
|
||||
// while an 'away' device is still connected
|
||||
func (a *App) SetStatusLastActivityAt(userId string, activityAt int64) {
|
||||
func (a *App) SetStatusLastActivityAt(userID string, activityAt int64) {
|
||||
var status *model.Status
|
||||
var err *model.AppError
|
||||
if status, err = a.GetStatus(userId); err != nil {
|
||||
if status, err = a.GetStatus(userID); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
status.LastActivityAt = activityAt
|
||||
|
||||
a.AddStatusCacheSkipClusterSend(status)
|
||||
a.SetStatusAwayIfNeeded(userId, false)
|
||||
a.SetStatusAwayIfNeeded(userID, false)
|
||||
}
|
||||
|
||||
func (a *App) SetStatusOnline(userId string, manual bool) {
|
||||
func (a *App) SetStatusOnline(userID string, manual bool) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return
|
||||
}
|
||||
@@ -181,8 +181,8 @@ func (a *App) SetStatusOnline(userId string, manual bool) {
|
||||
var status *model.Status
|
||||
var err *model.AppError
|
||||
|
||||
if status, err = a.GetStatus(userId); err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
if status, err = a.GetStatus(userID); err != nil {
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
broadcast = true
|
||||
} else {
|
||||
if status.Manual && !manual {
|
||||
@@ -209,11 +209,11 @@ func (a *App) SetStatusOnline(userId string, manual bool) {
|
||||
if status.Status != oldStatus || status.Manual != oldManual || status.LastActivityAt-oldTime > model.STATUS_MIN_UPDATE_TIME {
|
||||
if broadcast {
|
||||
if err := a.Srv().Store.Status().SaveOrUpdate(status); err != nil {
|
||||
mlog.Warn("Failed to save status", mlog.String("user_id", userId), mlog.Err(err), mlog.String("user_id", userId))
|
||||
mlog.Warn("Failed to save status", mlog.String("user_id", userID), mlog.Err(err), mlog.String("user_id", userID))
|
||||
}
|
||||
} else {
|
||||
if err := a.Srv().Store.Status().UpdateLastActivityAt(status.UserId, status.LastActivityAt); err != nil {
|
||||
mlog.Error("Failed to save status", mlog.String("user_id", userId), mlog.Err(err), mlog.String("user_id", userId))
|
||||
mlog.Error("Failed to save status", mlog.String("user_id", userID), mlog.Err(err), mlog.String("user_id", userID))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,30 +234,30 @@ func (a *App) BroadcastStatus(status *model.Status) {
|
||||
a.Publish(event)
|
||||
}
|
||||
|
||||
func (a *App) SetStatusOffline(userId string, manual bool) {
|
||||
func (a *App) SetStatusOffline(userID string, manual bool) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return
|
||||
}
|
||||
|
||||
status, err := a.GetStatus(userId)
|
||||
status, err := a.GetStatus(userID)
|
||||
if err == nil && status.Manual && !manual {
|
||||
return // manually set status always overrides non-manual one
|
||||
}
|
||||
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
|
||||
a.SaveAndBroadcastStatus(status)
|
||||
}
|
||||
|
||||
func (a *App) SetStatusAwayIfNeeded(userId string, manual bool) {
|
||||
func (a *App) SetStatusAwayIfNeeded(userID string, manual bool) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return
|
||||
}
|
||||
|
||||
status, err := a.GetStatus(userId)
|
||||
status, err := a.GetStatus(userID)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: 0, ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
if !manual && status.Manual {
|
||||
@@ -281,15 +281,15 @@ func (a *App) SetStatusAwayIfNeeded(userId string, manual bool) {
|
||||
a.SaveAndBroadcastStatus(status)
|
||||
}
|
||||
|
||||
func (a *App) SetStatusDoNotDisturb(userId string) {
|
||||
func (a *App) SetStatusDoNotDisturb(userID string) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return
|
||||
}
|
||||
|
||||
status, err := a.GetStatus(userId)
|
||||
status, err := a.GetStatus(userID)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
status.Status = model.STATUS_DND
|
||||
@@ -308,15 +308,15 @@ func (a *App) SaveAndBroadcastStatus(status *model.Status) {
|
||||
a.BroadcastStatus(status)
|
||||
}
|
||||
|
||||
func (a *App) SetStatusOutOfOffice(userId string) {
|
||||
func (a *App) SetStatusOutOfOffice(userID string) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return
|
||||
}
|
||||
|
||||
status, err := a.GetStatus(userId)
|
||||
status, err := a.GetStatus(userID)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OUT_OF_OFFICE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OUT_OF_OFFICE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
status.Status = model.STATUS_OUT_OF_OFFICE
|
||||
@@ -325,9 +325,9 @@ func (a *App) SetStatusOutOfOffice(userId string) {
|
||||
a.SaveAndBroadcastStatus(status)
|
||||
}
|
||||
|
||||
func (a *App) GetStatusFromCache(userId string) *model.Status {
|
||||
func (a *App) GetStatusFromCache(userID string) *model.Status {
|
||||
var status *model.Status
|
||||
if err := a.Srv().statusCache.Get(userId, &status); err == nil {
|
||||
if err := a.Srv().statusCache.Get(userID, &status); err == nil {
|
||||
statusCopy := &model.Status{}
|
||||
*statusCopy = *status
|
||||
return statusCopy
|
||||
@@ -336,17 +336,17 @@ func (a *App) GetStatusFromCache(userId string) *model.Status {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetStatus(userId string) (*model.Status, *model.AppError) {
|
||||
func (a *App) GetStatus(userID string) (*model.Status, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return &model.Status{}, nil
|
||||
}
|
||||
|
||||
status := a.GetStatusFromCache(userId)
|
||||
status := a.GetStatusFromCache(userID)
|
||||
if status != nil {
|
||||
return status, nil
|
||||
}
|
||||
|
||||
status, err := a.Srv().Store.Status().Get(userId)
|
||||
status, err := a.Srv().Store.Status().Get(userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
|
||||
222
app/team.go
222
app/team.go
@@ -48,8 +48,8 @@ func (a *App) CreateTeam(team *model.Team) (*model.Team, *model.AppError) {
|
||||
return rteam, nil
|
||||
}
|
||||
|
||||
func (a *App) CreateTeamWithUser(team *model.Team, userId string) (*model.Team, *model.AppError) {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) CreateTeamWithUser(team *model.Team, userID string) (*model.Team, *model.AppError) {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -237,8 +237,8 @@ func (a *App) UpdateTeamScheme(team *model.Team) (*model.Team, *model.AppError)
|
||||
return oldTeam, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateTeamPrivacy(teamId string, teamType string, allowOpenInvite bool) *model.AppError {
|
||||
oldTeam, err := a.GetTeam(teamId)
|
||||
func (a *App) UpdateTeamPrivacy(teamID string, teamType string, allowOpenInvite bool) *model.AppError {
|
||||
oldTeam, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -270,8 +270,8 @@ func (a *App) UpdateTeamPrivacy(teamId string, teamType string, allowOpenInvite
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) PatchTeam(teamId string, patch *model.TeamPatch) (*model.Team, *model.AppError) {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) PatchTeam(teamID string, patch *model.TeamPatch) (*model.Team, *model.AppError) {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -295,8 +295,8 @@ func (a *App) PatchTeam(teamId string, patch *model.TeamPatch) (*model.Team, *mo
|
||||
return team, nil
|
||||
}
|
||||
|
||||
func (a *App) RegenerateTeamInviteId(teamId string) (*model.Team, *model.AppError) {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) RegenerateTeamInviteId(teamID string) (*model.Team, *model.AppError) {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -327,18 +327,18 @@ func (a *App) sendTeamEvent(team *model.Team, event string) {
|
||||
*sanitizedTeam = *team
|
||||
sanitizedTeam.Sanitize()
|
||||
|
||||
teamId := "" // no filtering by teamId by default
|
||||
teamID := "" // no filtering by teamID by default
|
||||
if event == model.WEBSOCKET_EVENT_UPDATE_TEAM {
|
||||
// in case of update_team event - we send the message only to members of that team
|
||||
teamId = team.Id
|
||||
teamID = team.Id
|
||||
}
|
||||
message := model.NewWebSocketEvent(event, teamId, "", "", nil)
|
||||
message := model.NewWebSocketEvent(event, teamID, "", "", nil)
|
||||
message.Add("team", sanitizedTeam.ToJson())
|
||||
a.Publish(message)
|
||||
}
|
||||
|
||||
func (a *App) GetSchemeRolesForTeam(teamId string) (string, string, string, *model.AppError) {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) GetSchemeRolesForTeam(teamID string) (string, string, string, *model.AppError) {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
@@ -354,8 +354,8 @@ func (a *App) GetSchemeRolesForTeam(teamId string) (string, string, string, *mod
|
||||
return model.TEAM_GUEST_ROLE_ID, model.TEAM_USER_ROLE_ID, model.TEAM_ADMIN_ROLE_ID, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateTeamMemberRoles(teamId string, userId string, newRoles string) (*model.TeamMember, *model.AppError) {
|
||||
member, nErr := a.Srv().Store.Team().GetMember(teamId, userId)
|
||||
func (a *App) UpdateTeamMemberRoles(teamID string, userID string, newRoles string) (*model.TeamMember, *model.AppError) {
|
||||
member, nErr := a.Srv().Store.Team().GetMember(teamID, userID)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -367,10 +367,10 @@ func (a *App) UpdateTeamMemberRoles(teamId string, userId string, newRoles strin
|
||||
}
|
||||
|
||||
if member == nil {
|
||||
return nil, model.NewAppError("UpdateTeamMemberRoles", "api.team.update_member_roles.not_a_member", nil, "userId="+userId+" teamId="+teamId, http.StatusBadRequest)
|
||||
return nil, model.NewAppError("UpdateTeamMemberRoles", "api.team.update_member_roles.not_a_member", nil, "userId="+userID+" teamId="+teamID, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
schemeGuestRole, schemeUserRole, schemeAdminRole, err := a.GetSchemeRolesForTeam(teamId)
|
||||
schemeGuestRole, schemeUserRole, schemeAdminRole, err := a.GetSchemeRolesForTeam(teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -429,15 +429,15 @@ func (a *App) UpdateTeamMemberRoles(teamId string, userId string, newRoles strin
|
||||
}
|
||||
}
|
||||
|
||||
a.ClearSessionCacheForUser(userId)
|
||||
a.ClearSessionCacheForUser(userID)
|
||||
|
||||
a.sendUpdatedMemberRoleEvent(userId, member)
|
||||
a.sendUpdatedMemberRoleEvent(userID, member)
|
||||
|
||||
return member, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateTeamMemberSchemeRoles(teamId string, userId string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.TeamMember, *model.AppError) {
|
||||
member, err := a.GetTeamMember(teamId, userId)
|
||||
func (a *App) UpdateTeamMemberSchemeRoles(teamID string, userID string, isSchemeGuest bool, isSchemeUser bool, isSchemeAdmin bool) (*model.TeamMember, *model.AppError) {
|
||||
member, err := a.GetTeamMember(teamID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -466,30 +466,30 @@ func (a *App) UpdateTeamMemberSchemeRoles(teamId string, userId string, isScheme
|
||||
}
|
||||
}
|
||||
|
||||
a.ClearSessionCacheForUser(userId)
|
||||
a.ClearSessionCacheForUser(userID)
|
||||
|
||||
a.sendUpdatedMemberRoleEvent(userId, member)
|
||||
a.sendUpdatedMemberRoleEvent(userID, member)
|
||||
|
||||
return member, nil
|
||||
}
|
||||
|
||||
func (a *App) sendUpdatedMemberRoleEvent(userId string, member *model.TeamMember) {
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_MEMBERROLE_UPDATED, "", "", userId, nil)
|
||||
func (a *App) sendUpdatedMemberRoleEvent(userID string, member *model.TeamMember) {
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_MEMBERROLE_UPDATED, "", "", userID, nil)
|
||||
message.Add("member", member.ToJson())
|
||||
a.Publish(message)
|
||||
}
|
||||
|
||||
func (a *App) AddUserToTeam(teamId string, userId string, userRequestorId string) (*model.Team, *model.AppError) {
|
||||
func (a *App) AddUserToTeam(teamID string, userID string, userRequestorId string) (*model.Team, *model.AppError) {
|
||||
tchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
team, err := a.Srv().Store.Team().Get(teamId)
|
||||
team, err := a.Srv().Store.Team().Get(teamID)
|
||||
tchan <- store.StoreResult{Data: team, NErr: err}
|
||||
close(tchan)
|
||||
}()
|
||||
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
@@ -525,8 +525,8 @@ func (a *App) AddUserToTeam(teamId string, userId string, userRequestorId string
|
||||
return team, nil
|
||||
}
|
||||
|
||||
func (a *App) AddUserToTeamByTeamId(teamId string, user *model.User) *model.AppError {
|
||||
team, err := a.Srv().Store.Team().Get(teamId)
|
||||
func (a *App) AddUserToTeamByTeamId(teamID string, user *model.User) *model.AppError {
|
||||
team, err := a.Srv().Store.Team().Get(teamID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -540,8 +540,8 @@ func (a *App) AddUserToTeamByTeamId(teamId string, user *model.User) *model.AppE
|
||||
return a.JoinUserToTeam(team, user, "")
|
||||
}
|
||||
|
||||
func (a *App) AddUserToTeamByToken(userId string, tokenId string) (*model.Team, *model.AppError) {
|
||||
token, err := a.Srv().Store.Token().GetByToken(tokenId)
|
||||
func (a *App) AddUserToTeamByToken(userID string, tokenID string) (*model.Team, *model.AppError) {
|
||||
token, err := a.Srv().Store.Token().GetByToken(tokenID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("AddUserToTeamByToken", "api.user.create_user.signup_link_invalid.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -566,7 +566,7 @@ func (a *App) AddUserToTeamByToken(userId string, tokenId string) (*model.Team,
|
||||
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
@@ -631,7 +631,7 @@ func (a *App) AddUserToTeamByToken(userId string, tokenId string) (*model.Team,
|
||||
return team, nil
|
||||
}
|
||||
|
||||
func (a *App) AddUserToTeamByInviteId(inviteId string, userId string) (*model.Team, *model.AppError) {
|
||||
func (a *App) AddUserToTeamByInviteId(inviteId string, userID string) (*model.Team, *model.AppError) {
|
||||
tchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
team, err := a.Srv().Store.Team().GetByInviteId(inviteId)
|
||||
@@ -641,7 +641,7 @@ func (a *App) AddUserToTeamByInviteId(inviteId string, userId string) (*model.Te
|
||||
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
@@ -818,8 +818,8 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeam(teamId string) (*model.Team, *model.AppError) {
|
||||
team, err := a.Srv().Store.Team().Get(teamId)
|
||||
func (a *App) GetTeam(teamID string) (*model.Team, *model.AppError) {
|
||||
team, err := a.Srv().Store.Team().Get(teamID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -988,8 +988,8 @@ func (a *App) SearchPrivateTeams(term string) ([]*model.Team, *model.AppError) {
|
||||
return teams, nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) {
|
||||
teams, err := a.Srv().Store.Team().GetTeamsByUserId(userId)
|
||||
func (a *App) GetTeamsForUser(userID string) ([]*model.Team, *model.AppError) {
|
||||
teams, err := a.Srv().Store.Team().GetTeamsByUserId(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamsForUser", "app.team.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -997,8 +997,8 @@ func (a *App) GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) {
|
||||
return teams, nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) {
|
||||
teamMember, err := a.Srv().Store.Team().GetMember(teamId, userId)
|
||||
func (a *App) GetTeamMember(teamID, userID string) (*model.TeamMember, *model.AppError) {
|
||||
teamMember, err := a.Srv().Store.Team().GetMember(teamID, userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1012,8 +1012,8 @@ func (a *App) GetTeamMember(teamId, userId string) (*model.TeamMember, *model.Ap
|
||||
return teamMember, nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamMembersForUser(userId string) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetTeamsForUser(context.Background(), userId)
|
||||
func (a *App) GetTeamMembersForUser(userID string) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetTeamsForUser(context.Background(), userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamMembersForUser", "app.team.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1021,8 +1021,8 @@ func (a *App) GetTeamMembersForUser(userId string) ([]*model.TeamMember, *model.
|
||||
return teamMembers, nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamMembersForUserWithPagination(userId string, page, perPage int) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetTeamsForUserWithPagination(userId, page, perPage)
|
||||
func (a *App) GetTeamMembersForUserWithPagination(userID string, page, perPage int) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetTeamsForUserWithPagination(userID, page, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamMembersForUserWithPagination", "app.team.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1030,8 +1030,8 @@ func (a *App) GetTeamMembersForUserWithPagination(userId string, page, perPage i
|
||||
return teamMembers, nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamMembers(teamId string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetMembers(teamId, offset, limit, teamMembersGetOptions)
|
||||
func (a *App) GetTeamMembers(teamID string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetMembers(teamID, offset, limit, teamMembersGetOptions)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamMembers", "app.team.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1039,8 +1039,8 @@ func (a *App) GetTeamMembers(teamId string, offset int, limit int, teamMembersGe
|
||||
return teamMembers, nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamMembersByIds(teamId string, userIds []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetMembersByIds(teamId, userIds, restrictions)
|
||||
func (a *App) GetTeamMembersByIds(teamID string, userIDs []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError) {
|
||||
teamMembers, err := a.Srv().Store.Team().GetMembersByIds(teamID, userIDs, restrictions)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamMembersByIds", "app.team.get_members_by_ids.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1048,32 +1048,32 @@ func (a *App) GetTeamMembersByIds(teamId string, userIds []string, restrictions
|
||||
return teamMembers, nil
|
||||
}
|
||||
|
||||
func (a *App) AddTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) {
|
||||
if _, err := a.AddUserToTeam(teamId, userId, ""); err != nil {
|
||||
func (a *App) AddTeamMember(teamID, userID string) (*model.TeamMember, *model.AppError) {
|
||||
if _, err := a.AddUserToTeam(teamID, userID, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
teamMember, err := a.GetTeamMember(teamId, userId)
|
||||
teamMember, err := a.GetTeamMember(teamID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", userId, nil)
|
||||
message.Add("team_id", teamId)
|
||||
message.Add("user_id", userId)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", userID, nil)
|
||||
message.Add("team_id", teamID)
|
||||
message.Add("user_id", userID)
|
||||
a.Publish(message)
|
||||
|
||||
return teamMember, nil
|
||||
}
|
||||
|
||||
func (a *App) AddTeamMembers(teamId string, userIds []string, userRequestorId string, graceful bool) ([]*model.TeamMemberWithError, *model.AppError) {
|
||||
func (a *App) AddTeamMembers(teamID string, userIDs []string, userRequestorId string, graceful bool) ([]*model.TeamMemberWithError, *model.AppError) {
|
||||
var membersWithErrors []*model.TeamMemberWithError
|
||||
|
||||
for _, userId := range userIds {
|
||||
if _, err := a.AddUserToTeam(teamId, userId, userRequestorId); err != nil {
|
||||
for _, userID := range userIDs {
|
||||
if _, err := a.AddUserToTeam(teamID, userID, userRequestorId); err != nil {
|
||||
if graceful {
|
||||
membersWithErrors = append(membersWithErrors, &model.TeamMemberWithError{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Error: err,
|
||||
})
|
||||
continue
|
||||
@@ -1081,31 +1081,31 @@ func (a *App) AddTeamMembers(teamId string, userIds []string, userRequestorId st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
teamMember, err := a.GetTeamMember(teamId, userId)
|
||||
teamMember, err := a.GetTeamMember(teamID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
membersWithErrors = append(membersWithErrors, &model.TeamMemberWithError{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
Member: teamMember,
|
||||
})
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", userId, nil)
|
||||
message.Add("team_id", teamId)
|
||||
message.Add("user_id", userId)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", userID, nil)
|
||||
message.Add("team_id", teamID)
|
||||
message.Add("user_id", userID)
|
||||
a.Publish(message)
|
||||
}
|
||||
|
||||
return membersWithErrors, nil
|
||||
}
|
||||
|
||||
func (a *App) AddTeamMemberByToken(userId, tokenId string) (*model.TeamMember, *model.AppError) {
|
||||
team, err := a.AddUserToTeamByToken(userId, tokenId)
|
||||
func (a *App) AddTeamMemberByToken(userID, tokenID string) (*model.TeamMember, *model.AppError) {
|
||||
team, err := a.AddUserToTeamByToken(userID, tokenID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
teamMember, err := a.GetTeamMember(team.Id, userId)
|
||||
teamMember, err := a.GetTeamMember(team.Id, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1113,8 +1113,8 @@ func (a *App) AddTeamMemberByToken(userId, tokenId string) (*model.TeamMember, *
|
||||
return teamMember, nil
|
||||
}
|
||||
|
||||
func (a *App) AddTeamMemberByInviteId(inviteId, userId string) (*model.TeamMember, *model.AppError) {
|
||||
team, err := a.AddUserToTeamByInviteId(inviteId, userId)
|
||||
func (a *App) AddTeamMemberByInviteId(inviteId, userID string) (*model.TeamMember, *model.AppError) {
|
||||
team, err := a.AddUserToTeamByInviteId(inviteId, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1123,15 +1123,15 @@ func (a *App) AddTeamMemberByInviteId(inviteId, userId string) (*model.TeamMembe
|
||||
return nil, model.NewAppError("AddTeamMemberByInviteId", "app.team.invite_id.group_constrained.error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
teamMember, err := a.GetTeamMember(team.Id, userId)
|
||||
teamMember, err := a.GetTeamMember(team.Id, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return teamMember, nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamUnread(teamId, userId string) (*model.TeamUnread, *model.AppError) {
|
||||
channelUnreads, err := a.Srv().Store.Team().GetChannelUnreadsForTeam(teamId, userId)
|
||||
func (a *App) GetTeamUnread(teamID, userID string) (*model.TeamUnread, *model.AppError) {
|
||||
channelUnreads, err := a.Srv().Store.Team().GetChannelUnreadsForTeam(teamID, userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamUnread", "app.team.get_unread.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1139,7 +1139,7 @@ func (a *App) GetTeamUnread(teamId, userId string) (*model.TeamUnread, *model.Ap
|
||||
var teamUnread = &model.TeamUnread{
|
||||
MsgCount: 0,
|
||||
MentionCount: 0,
|
||||
TeamId: teamId,
|
||||
TeamId: teamID,
|
||||
}
|
||||
|
||||
for _, cu := range channelUnreads {
|
||||
@@ -1153,17 +1153,17 @@ func (a *App) GetTeamUnread(teamId, userId string) (*model.TeamUnread, *model.Ap
|
||||
return teamUnread, nil
|
||||
}
|
||||
|
||||
func (a *App) RemoveUserFromTeam(teamId string, userId string, requestorId string) *model.AppError {
|
||||
func (a *App) RemoveUserFromTeam(teamID string, userID string, requestorId string) *model.AppError {
|
||||
tchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
team, err := a.Srv().Store.Team().Get(teamId)
|
||||
team, err := a.Srv().Store.Team().Get(teamID)
|
||||
tchan <- store.StoreResult{Data: team, NErr: err}
|
||||
close(tchan)
|
||||
}()
|
||||
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
@@ -1358,10 +1358,10 @@ func (a *App) postRemoveFromTeamMessage(user *model.User, channel *model.Channel
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) prepareInviteNewUsersToTeam(teamId, senderId string) (*model.User, *model.Team, *model.AppError) {
|
||||
func (a *App) prepareInviteNewUsersToTeam(teamID, senderId string) (*model.User, *model.Team, *model.AppError) {
|
||||
tchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
team, err := a.Srv().Store.Team().Get(teamId)
|
||||
team, err := a.Srv().Store.Team().Get(teamID)
|
||||
tchan <- store.StoreResult{Data: team, NErr: err}
|
||||
close(tchan)
|
||||
}()
|
||||
@@ -1440,7 +1440,7 @@ func (a *App) GetErrorListForEmailsOverLimit(emailList []string, cloudUserLimit
|
||||
return emailList, invitesNotSent, nil
|
||||
}
|
||||
|
||||
func (a *App) InviteNewUsersToTeamGracefully(emailList []string, teamId, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||
func (a *App) InviteNewUsersToTeamGracefully(emailList []string, teamID, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||
return nil, model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -1449,7 +1449,7 @@ func (a *App) InviteNewUsersToTeamGracefully(emailList []string, teamId, senderI
|
||||
err := model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.no_one.app_error", nil, "", http.StatusBadRequest)
|
||||
return nil, err
|
||||
}
|
||||
user, team, err := a.prepareInviteNewUsersToTeam(teamId, senderId)
|
||||
user, team, err := a.prepareInviteNewUsersToTeam(teamID, senderId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1480,14 +1480,14 @@ func (a *App) InviteNewUsersToTeamGracefully(emailList []string, teamId, senderI
|
||||
return inviteListWithErrors, nil
|
||||
}
|
||||
|
||||
func (a *App) prepareInviteGuestsToChannels(teamId string, guestsInvite *model.GuestsInvite, senderId string) (*model.User, *model.Team, []*model.Channel, *model.AppError) {
|
||||
func (a *App) prepareInviteGuestsToChannels(teamID string, guestsInvite *model.GuestsInvite, senderId string) (*model.User, *model.Team, []*model.Channel, *model.AppError) {
|
||||
if err := guestsInvite.IsValid(); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
tchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
team, err := a.Srv().Store.Team().Get(teamId)
|
||||
team, err := a.Srv().Store.Team().Get(teamID)
|
||||
tchan <- store.StoreResult{Data: team, NErr: err}
|
||||
close(tchan)
|
||||
}()
|
||||
@@ -1535,19 +1535,19 @@ func (a *App) prepareInviteGuestsToChannels(teamId string, guestsInvite *model.G
|
||||
team := result.Data.(*model.Team)
|
||||
|
||||
for _, channel := range channels {
|
||||
if channel.TeamId != teamId {
|
||||
if channel.TeamId != teamID {
|
||||
return nil, nil, nil, model.NewAppError("prepareInviteGuestsToChannels", "api.team.invite_guests.channel_in_invalid_team.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
return user, team, channels, nil
|
||||
}
|
||||
|
||||
func (a *App) InviteGuestsToChannelsGracefully(teamId string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||
func (a *App) InviteGuestsToChannelsGracefully(teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||
return nil, model.NewAppError("InviteGuestsToChannelsGracefully", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
user, team, channels, err := a.prepareInviteGuestsToChannels(teamId, guestsInvite, senderId)
|
||||
user, team, channels, err := a.prepareInviteGuestsToChannels(teamID, guestsInvite, senderId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1582,7 +1582,7 @@ func (a *App) InviteGuestsToChannelsGracefully(teamId string, guestsInvite *mode
|
||||
return inviteListWithErrors, nil
|
||||
}
|
||||
|
||||
func (a *App) InviteNewUsersToTeam(emailList []string, teamId, senderId string) *model.AppError {
|
||||
func (a *App) InviteNewUsersToTeam(emailList []string, teamID, senderId string) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -1592,7 +1592,7 @@ func (a *App) InviteNewUsersToTeam(emailList []string, teamId, senderId string)
|
||||
return err
|
||||
}
|
||||
|
||||
user, team, err := a.prepareInviteNewUsersToTeam(teamId, senderId)
|
||||
user, team, err := a.prepareInviteNewUsersToTeam(teamID, senderId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1620,12 +1620,12 @@ func (a *App) InviteNewUsersToTeam(emailList []string, teamId, senderId string)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) InviteGuestsToChannels(teamId string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError {
|
||||
func (a *App) InviteGuestsToChannels(teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
user, team, channels, err := a.prepareInviteGuestsToChannels(teamId, guestsInvite, senderId)
|
||||
user, team, channels, err := a.prepareInviteGuestsToChannels(teamID, guestsInvite, senderId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1662,8 +1662,8 @@ func (a *App) FindTeamByName(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *App) GetTeamsUnreadForUser(excludeTeamId string, userId string) ([]*model.TeamUnread, *model.AppError) {
|
||||
data, err := a.Srv().Store.Team().GetChannelUnreadsForAllTeams(excludeTeamId, userId)
|
||||
func (a *App) GetTeamsUnreadForUser(excludeTeamId string, userID string) ([]*model.TeamUnread, *model.AppError) {
|
||||
data, err := a.Srv().Store.Team().GetChannelUnreadsForAllTeams(excludeTeamId, userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamsUnreadForUser", "app.team.get_unread.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1701,8 +1701,8 @@ func (a *App) GetTeamsUnreadForUser(excludeTeamId string, userId string) ([]*mod
|
||||
return members, nil
|
||||
}
|
||||
|
||||
func (a *App) PermanentDeleteTeamId(teamId string) *model.AppError {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) PermanentDeleteTeamId(teamID string) *model.AppError {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1753,8 +1753,8 @@ func (a *App) PermanentDeleteTeam(team *model.Team) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SoftDeleteTeam(teamId string) *model.AppError {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) SoftDeleteTeam(teamID string) *model.AppError {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1779,8 +1779,8 @@ func (a *App) SoftDeleteTeam(teamId string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RestoreTeam(teamId string) *model.AppError {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) RestoreTeam(teamID string) *model.AppError {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1804,22 +1804,22 @@ func (a *App) RestoreTeam(teamId string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamStats(teamId string, restrictions *model.ViewUsersRestrictions) (*model.TeamStats, *model.AppError) {
|
||||
func (a *App) GetTeamStats(teamID string, restrictions *model.ViewUsersRestrictions) (*model.TeamStats, *model.AppError) {
|
||||
tchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
totalMemberCount, err := a.Srv().Store.Team().GetTotalMemberCount(teamId, restrictions)
|
||||
totalMemberCount, err := a.Srv().Store.Team().GetTotalMemberCount(teamID, restrictions)
|
||||
tchan <- store.StoreResult{Data: totalMemberCount, NErr: err}
|
||||
close(tchan)
|
||||
}()
|
||||
achan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
memberCount, err := a.Srv().Store.Team().GetActiveMemberCount(teamId, restrictions)
|
||||
memberCount, err := a.Srv().Store.Team().GetActiveMemberCount(teamID, restrictions)
|
||||
achan <- store.StoreResult{Data: memberCount, NErr: err}
|
||||
close(achan)
|
||||
}()
|
||||
|
||||
stats := &model.TeamStats{}
|
||||
stats.TeamId = teamId
|
||||
stats.TeamId = teamID
|
||||
|
||||
result := <-tchan
|
||||
if result.NErr != nil {
|
||||
@@ -1837,11 +1837,11 @@ func (a *App) GetTeamStats(teamId string, restrictions *model.ViewUsersRestricti
|
||||
}
|
||||
|
||||
func (a *App) GetTeamIdFromQuery(query url.Values) (string, *model.AppError) {
|
||||
tokenId := query.Get("t")
|
||||
tokenID := query.Get("t")
|
||||
inviteId := query.Get("id")
|
||||
|
||||
if tokenId != "" {
|
||||
token, err := a.Srv().Store.Token().GetByToken(tokenId)
|
||||
if tokenID != "" {
|
||||
token, err := a.Srv().Store.Token().GetByToken(tokenID)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetTeamIdFromQuery", "api.oauth.singup_with_oauth.invalid_link.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -1910,17 +1910,17 @@ func (a *App) GetTeamIcon(team *model.Team) ([]byte, *model.AppError) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (a *App) SetTeamIcon(teamId string, imageData *multipart.FileHeader) *model.AppError {
|
||||
func (a *App) SetTeamIcon(teamID string, imageData *multipart.FileHeader) *model.AppError {
|
||||
file, err := imageData.Open()
|
||||
if err != nil {
|
||||
return model.NewAppError("SetTeamIcon", "api.team.set_team_icon.open.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
defer file.Close()
|
||||
return a.SetTeamIconFromMultiPartFile(teamId, file)
|
||||
return a.SetTeamIconFromMultiPartFile(teamID, file)
|
||||
}
|
||||
|
||||
func (a *App) SetTeamIconFromMultiPartFile(teamId string, file multipart.File) *model.AppError {
|
||||
team, getTeamErr := a.GetTeam(teamId)
|
||||
func (a *App) SetTeamIconFromMultiPartFile(teamID string, file multipart.File) *model.AppError {
|
||||
team, getTeamErr := a.GetTeam(teamID)
|
||||
|
||||
if getTeamErr != nil {
|
||||
return model.NewAppError("SetTeamIcon", "api.team.set_team_icon.get_team.app_error", nil, getTeamErr.Error(), http.StatusBadRequest)
|
||||
@@ -1988,13 +1988,13 @@ func (a *App) SetTeamIconFromFile(team *model.Team, file io.Reader) *model.AppEr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
team, err := a.GetTeam(teamId)
|
||||
func (a *App) RemoveTeamIcon(teamID string) *model.AppError {
|
||||
team, err := a.GetTeam(teamID)
|
||||
if err != nil {
|
||||
return model.NewAppError("RemoveTeamIcon", "api.team.remove_team_icon.get_team.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Team().UpdateLastTeamIconUpdate(teamId, 0); err != nil {
|
||||
if err := a.Srv().Store.Team().UpdateLastTeamIconUpdate(teamID, 0); err != nil {
|
||||
return model.NewAppError("RemoveTeamIcon", "api.team.team_icon.update.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -531,12 +531,12 @@ func TestSanitizeTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("not a user of the team", func(t *testing.T) {
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: model.NewId(),
|
||||
Roles: model.TEAM_USER_ROLE_ID,
|
||||
},
|
||||
@@ -549,12 +549,12 @@ func TestSanitizeTeam(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("user of the team", func(t *testing.T) {
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: team.Id,
|
||||
Roles: model.TEAM_USER_ROLE_ID,
|
||||
},
|
||||
@@ -567,12 +567,12 @@ func TestSanitizeTeam(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("team admin", func(t *testing.T) {
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: team.Id,
|
||||
Roles: model.TEAM_USER_ROLE_ID + " " + model.TEAM_ADMIN_ROLE_ID,
|
||||
},
|
||||
@@ -585,12 +585,12 @@ func TestSanitizeTeam(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("team admin of another team", func(t *testing.T) {
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: model.NewId(),
|
||||
Roles: model.TEAM_USER_ROLE_ID + " " + model.TEAM_ADMIN_ROLE_ID,
|
||||
},
|
||||
@@ -603,12 +603,12 @@ func TestSanitizeTeam(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("system admin, not a user of team", func(t *testing.T) {
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID + " " + model.SYSTEM_ADMIN_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: model.NewId(),
|
||||
Roles: model.TEAM_USER_ROLE_ID,
|
||||
},
|
||||
@@ -621,12 +621,12 @@ func TestSanitizeTeam(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("system admin, user of team", func(t *testing.T) {
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID + " " + model.SYSTEM_ADMIN_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: team.Id,
|
||||
Roles: model.TEAM_USER_ROLE_ID,
|
||||
},
|
||||
@@ -657,17 +657,17 @@ func TestSanitizeTeams(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: teams[0].Id,
|
||||
Roles: model.TEAM_USER_ROLE_ID,
|
||||
},
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: teams[1].Id,
|
||||
Roles: model.TEAM_USER_ROLE_ID + " " + model.TEAM_ADMIN_ROLE_ID,
|
||||
},
|
||||
@@ -694,12 +694,12 @@ func TestSanitizeTeams(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
userId := model.NewId()
|
||||
userID := model.NewId()
|
||||
session := model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID + " " + model.SYSTEM_ADMIN_ROLE_ID,
|
||||
TeamMembers: []*model.TeamMember{
|
||||
{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TeamId: teams[0].Id,
|
||||
Roles: model.TEAM_USER_ROLE_ID,
|
||||
},
|
||||
|
||||
@@ -11,13 +11,13 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
)
|
||||
|
||||
func (a *App) CreateTermsOfService(text, userId string) (*model.TermsOfService, *model.AppError) {
|
||||
func (a *App) CreateTermsOfService(text, userID string) (*model.TermsOfService, *model.AppError) {
|
||||
termsOfService := &model.TermsOfService{
|
||||
Text: text,
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
}
|
||||
|
||||
if _, appErr := a.GetUser(userId); appErr != nil {
|
||||
if _, appErr := a.GetUser(userID); appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
|
||||
@@ -153,8 +153,8 @@ func (a *App) GetUploadSession(uploadId string) (*model.UploadSession, *model.Ap
|
||||
return us, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUploadSessionsForUser(userId string) ([]*model.UploadSession, *model.AppError) {
|
||||
uss, err := a.Srv().Store.UploadSession().GetForUser(userId)
|
||||
func (a *App) GetUploadSessionsForUser(userID string) ([]*model.UploadSession, *model.AppError) {
|
||||
uss, err := a.Srv().Store.UploadSession().GetForUser(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUploadsForUser", "app.upload.get_for_user.app_error",
|
||||
nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
272
app/user.go
272
app/user.go
@@ -273,7 +273,7 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
// This message goes to everyone, so the teamId, channelId and userId are irrelevant
|
||||
// This message goes to everyone, so the teamID, channelId and userID are irrelevant
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_NEW_USER, "", "", "", nil)
|
||||
message.Add("user_id", ruser.Id)
|
||||
a.Publish(message)
|
||||
@@ -335,7 +335,7 @@ func (a *App) createUser(user *model.User) (*model.User, *model.AppError) {
|
||||
return ruser, nil
|
||||
}
|
||||
|
||||
func (a *App) CreateOAuthUser(service string, userData io.Reader, teamId string, tokenUser *model.User) (*model.User, *model.AppError) {
|
||||
func (a *App) CreateOAuthUser(service string, userData io.Reader, teamID string, tokenUser *model.User) (*model.User, *model.AppError) {
|
||||
if !*a.Config().TeamSettings.EnableUserCreation {
|
||||
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_user.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -393,13 +393,13 @@ func (a *App) CreateOAuthUser(service string, userData io.Reader, teamId string,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if teamId != "" {
|
||||
err = a.AddUserToTeamByTeamId(teamId, user)
|
||||
if teamID != "" {
|
||||
err = a.AddUserToTeamByTeamId(teamID, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = a.AddDirectChannels(teamId, user)
|
||||
err = a.AddDirectChannels(teamID, user)
|
||||
if err != nil {
|
||||
mlog.Warn("Failed to add direct channels", mlog.Err(err))
|
||||
}
|
||||
@@ -443,8 +443,8 @@ func (a *App) IsUsernameTaken(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *App) GetUser(userId string) (*model.User, *model.AppError) {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
func (a *App) GetUser(userID string) (*model.User, *model.AppError) {
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -535,8 +535,8 @@ func (a *App) GetUsersInTeam(options *model.UserGetOptions) ([]*model.User, *mod
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetProfilesNotInTeam(teamId, groupConstrained, offset, limit, viewRestrictions)
|
||||
func (a *App) GetUsersNotInTeam(teamID string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetProfilesNotInTeam(teamID, groupConstrained, offset, limit, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersNotInTeam", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -553,8 +553,8 @@ func (a *App) GetUsersInTeamPage(options *model.UserGetOptions, asAdmin bool) ([
|
||||
return a.sanitizeProfiles(users, asAdmin), nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInTeamPage(teamId string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.GetUsersNotInTeam(teamId, groupConstrained, page*perPage, perPage, viewRestrictions)
|
||||
func (a *App) GetUsersNotInTeamPage(teamID string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.GetUsersNotInTeam(teamID, groupConstrained, page*perPage, perPage, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -562,12 +562,12 @@ func (a *App) GetUsersNotInTeamPage(teamId string, groupConstrained bool, page i
|
||||
return a.sanitizeProfiles(users, asAdmin), nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInTeamEtag(teamId string, restrictionsHash string) string {
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv().Store.User().GetEtagForProfiles(teamId), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
func (a *App) GetUsersInTeamEtag(teamID string, restrictionsHash string) string {
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv().Store.User().GetEtagForProfiles(teamID), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInTeamEtag(teamId string, restrictionsHash string) string {
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv().Store.User().GetEtagForProfilesNotInTeam(teamId), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
func (a *App) GetUsersNotInTeamEtag(teamID string, restrictionsHash string) string {
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv().Store.User().GetEtagForProfilesNotInTeam(teamID), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInChannel(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
@@ -620,8 +620,8 @@ func (a *App) GetUsersInChannelPageByStatus(options *model.UserGetOptions, asAdm
|
||||
return a.sanitizeProfiles(users, asAdmin), nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
|
||||
func (a *App) GetUsersNotInChannel(teamID string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv().Store.User().GetProfilesNotInChannel(teamID, channelId, groupConstrained, offset, limit, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersNotInChannel", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -629,8 +629,8 @@ func (a *App) GetUsersNotInChannel(teamId string, channelId string, groupConstra
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInChannelMap(teamId string, channelId string, groupConstrained bool, offset int, limit int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) (map[string]*model.User, *model.AppError) {
|
||||
users, err := a.GetUsersNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
|
||||
func (a *App) GetUsersNotInChannelMap(teamID string, channelId string, groupConstrained bool, offset int, limit int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) (map[string]*model.User, *model.AppError) {
|
||||
users, err := a.GetUsersNotInChannel(teamID, channelId, groupConstrained, offset, limit, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -645,8 +645,8 @@ func (a *App) GetUsersNotInChannelMap(teamId string, channelId string, groupCons
|
||||
return userMap, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInChannelPage(teamId string, channelId string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.GetUsersNotInChannel(teamId, channelId, groupConstrained, page*perPage, perPage, viewRestrictions)
|
||||
func (a *App) GetUsersNotInChannelPage(teamID string, channelId string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.GetUsersNotInChannel(teamID, channelId, groupConstrained, page*perPage, perPage, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -692,10 +692,10 @@ func (a *App) GetChannelGroupUsers(channelID string) ([]*model.User, *model.AppE
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersByIds(userIds []string, options *store.UserGetByIdsOpts) ([]*model.User, *model.AppError) {
|
||||
func (a *App) GetUsersByIds(userIDs []string, options *store.UserGetByIdsOpts) ([]*model.User, *model.AppError) {
|
||||
allowFromCache := options.ViewRestrictions == nil
|
||||
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIds, options, allowFromCache)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIDs, options, allowFromCache)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersByIds", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -731,8 +731,8 @@ func (a *App) sanitizeProfiles(users []*model.User, asAdmin bool) []*model.User
|
||||
return users
|
||||
}
|
||||
|
||||
func (a *App) GenerateMfaSecret(userId string) (*model.MfaSecret, *model.AppError) {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) GenerateMfaSecret(userID string) (*model.MfaSecret, *model.AppError) {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -750,8 +750,8 @@ func (a *App) GenerateMfaSecret(userId string) (*model.MfaSecret, *model.AppErro
|
||||
return mfaSecret, nil
|
||||
}
|
||||
|
||||
func (a *App) ActivateMfa(userId, token string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
func (a *App) ActivateMfa(userID, token string) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -772,24 +772,24 @@ func (a *App) ActivateMfa(userId, token string) *model.AppError {
|
||||
}
|
||||
|
||||
// Make sure old MFA status is not cached locally or in cluster nodes.
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(userID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) DeactivateMfa(userId string) *model.AppError {
|
||||
func (a *App) DeactivateMfa(userID string) *model.AppError {
|
||||
mfaService := mfa.New(a, a.Srv().Store)
|
||||
if err := mfaService.Deactivate(userId); err != nil {
|
||||
if err := mfaService.Deactivate(userID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Make sure old MFA status is not cached locally or in cluster nodes.
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(userID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateProfileImage(username string, userId string, initialFont string) ([]byte, *model.AppError) {
|
||||
func CreateProfileImage(username string, userID string, initialFont string) ([]byte, *model.AppError) {
|
||||
colors := []color.NRGBA{
|
||||
{197, 8, 126, 255},
|
||||
{227, 207, 18, 255},
|
||||
@@ -820,7 +820,7 @@ func CreateProfileImage(username string, userId string, initialFont string) ([]b
|
||||
}
|
||||
|
||||
h := fnv.New32a()
|
||||
h.Write([]byte(userId))
|
||||
h.Write([]byte(userID))
|
||||
seed := h.Sum32()
|
||||
|
||||
initial := string(strings.ToUpper(username)[0])
|
||||
@@ -951,16 +951,16 @@ func (a *App) SetDefaultProfileImage(user *model.User) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImage(userId string, imageData *multipart.FileHeader) *model.AppError {
|
||||
func (a *App) SetProfileImage(userID string, imageData *multipart.FileHeader) *model.AppError {
|
||||
file, err := imageData.Open()
|
||||
if err != nil {
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.open.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
defer file.Close()
|
||||
return a.SetProfileImageFromMultiPartFile(userId, file)
|
||||
return a.SetProfileImageFromMultiPartFile(userID, file)
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImageFromMultiPartFile(userId string, file multipart.File) *model.AppError {
|
||||
func (a *App) SetProfileImageFromMultiPartFile(userID string, file multipart.File) *model.AppError {
|
||||
// Decode image config first to check dimensions before loading the whole thing into memory later on
|
||||
config, _, err := image.DecodeConfig(file)
|
||||
if err != nil {
|
||||
@@ -975,7 +975,7 @@ func (a *App) SetProfileImageFromMultiPartFile(userId string, file multipart.Fil
|
||||
|
||||
file.Seek(0, 0)
|
||||
|
||||
return a.SetProfileImageFromFile(userId, file)
|
||||
return a.SetProfileImageFromFile(userID, file)
|
||||
}
|
||||
|
||||
func (a *App) AdjustImage(file io.Reader) (*bytes.Buffer, *model.AppError) {
|
||||
@@ -1000,28 +1000,28 @@ func (a *App) AdjustImage(file io.Reader) (*bytes.Buffer, *model.AppError) {
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppError {
|
||||
func (a *App) SetProfileImageFromFile(userID string, file io.Reader) *model.AppError {
|
||||
|
||||
buf, err := a.AdjustImage(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := "users/" + userId + "/profile.png"
|
||||
path := "users/" + userID + "/profile.png"
|
||||
|
||||
if _, err := a.WriteFile(buf, path); err != nil {
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.upload_profile.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.User().UpdateLastPictureUpdate(userId); err != nil {
|
||||
if err := a.Srv().Store.User().UpdateLastPictureUpdate(userID); err != nil {
|
||||
mlog.Warn("Error with updating last picture update", mlog.Err(err))
|
||||
}
|
||||
a.invalidateUserCacheAndPublish(userId)
|
||||
a.invalidateUserCacheAndPublish(userID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdatePasswordAsUser(userId, currentPassword, newPassword string) *model.AppError {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) UpdatePasswordAsUser(userID, currentPassword, newPassword string) *model.AppError {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1048,14 +1048,14 @@ func (a *App) UpdatePasswordAsUser(userId, currentPassword, newPassword string)
|
||||
return a.UpdatePasswordSendEmail(user, newPassword, T("api.user.update_password.menu"))
|
||||
}
|
||||
|
||||
func (a *App) userDeactivated(userId string) *model.AppError {
|
||||
if err := a.RevokeAllSessions(userId); err != nil {
|
||||
func (a *App) userDeactivated(userID string) *model.AppError {
|
||||
if err := a.RevokeAllSessions(userID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.SetStatusOffline(userId, false)
|
||||
a.SetStatusOffline(userID, false)
|
||||
|
||||
user, err := a.GetUser(userId)
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1064,24 +1064,24 @@ func (a *App) userDeactivated(userId string) *model.AppError {
|
||||
// bots the user owns. Only notify once, when the user is the owner, not the
|
||||
// owners bots
|
||||
if !user.IsBot {
|
||||
a.notifySysadminsBotOwnerDeactivated(userId)
|
||||
a.notifySysadminsBotOwnerDeactivated(userID)
|
||||
}
|
||||
|
||||
if *a.Config().ServiceSettings.DisableBotsWhenOwnerIsDeactivated {
|
||||
a.disableUserBots(userId)
|
||||
a.disableUserBots(userID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) invalidateUserChannelMembersCaches(userId string) *model.AppError {
|
||||
teamsForUser, err := a.GetTeamsForUser(userId)
|
||||
func (a *App) invalidateUserChannelMembersCaches(userID string) *model.AppError {
|
||||
teamsForUser, err := a.GetTeamsForUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, team := range teamsForUser {
|
||||
channelsForUser, err := a.GetChannelsForUser(team.Id, userId, false, 0)
|
||||
channelsForUser, err := a.GetChannelsForUser(team.Id, userID, false, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1132,13 +1132,13 @@ func (a *App) UpdateActive(user *model.User, active bool) (*model.User, *model.A
|
||||
}
|
||||
|
||||
func (a *App) DeactivateGuests() *model.AppError {
|
||||
userIds, err := a.Srv().Store.User().DeactivateGuests()
|
||||
userIDs, err := a.Srv().Store.User().DeactivateGuests()
|
||||
if err != nil {
|
||||
return model.NewAppError("DeactivateGuests", "app.user.update_active_for_multiple_users.updating.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, userId := range userIds {
|
||||
if err := a.userDeactivated(userId); err != nil {
|
||||
for _, userID := range userIDs {
|
||||
if err := a.userDeactivated(userID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1177,8 +1177,8 @@ func (a *App) UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *mo
|
||||
return updatedUser, nil
|
||||
}
|
||||
|
||||
func (a *App) PatchUser(userId string, patch *model.UserPatch, asAdmin bool) (*model.User, *model.AppError) {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) PatchUser(userID string, patch *model.UserPatch, asAdmin bool) (*model.User, *model.AppError) {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1193,9 +1193,9 @@ func (a *App) PatchUser(userId string, patch *model.UserPatch, asAdmin bool) (*m
|
||||
return updatedUser, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateUserAuth(userId string, userAuth *model.UserAuth) (*model.UserAuth, *model.AppError) {
|
||||
func (a *App) UpdateUserAuth(userID string, userAuth *model.UserAuth) (*model.UserAuth, *model.AppError) {
|
||||
userAuth.Password = ""
|
||||
if _, err := a.Srv().Store.User().UpdateAuthData(userId, userAuth.AuthService, userAuth.AuthData, "", false); err != nil {
|
||||
if _, err := a.Srv().Store.User().UpdateAuthData(userID, userAuth.AuthService, userAuth.AuthData, "", false); err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
@@ -1315,8 +1315,8 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
return userUpdate.New, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateUserActive(userId string, active bool) *model.AppError {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) UpdateUserActive(userID string, active bool) *model.AppError {
|
||||
user, err := a.GetUser(userID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1328,8 +1328,8 @@ func (a *App) UpdateUserActive(userId string, active bool) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateUserNotifyProps(userId string, props map[string]string, sendNotifications bool) (*model.User, *model.AppError) {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) UpdateUserNotifyProps(userID string, props map[string]string, sendNotifications bool) (*model.User, *model.AppError) {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1344,19 +1344,19 @@ func (a *App) UpdateUserNotifyProps(userId string, props map[string]string, send
|
||||
return ruser, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateMfa(activate bool, userId, token string) *model.AppError {
|
||||
func (a *App) UpdateMfa(activate bool, userID, token string) *model.AppError {
|
||||
if activate {
|
||||
if err := a.ActivateMfa(userId, token); err != nil {
|
||||
if err := a.ActivateMfa(userID, token); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := a.DeactivateMfa(userId); err != nil {
|
||||
if err := a.DeactivateMfa(userID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
a.Srv().Go(func() {
|
||||
user, err := a.GetUser(userId)
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to get user", mlog.Err(err))
|
||||
return
|
||||
@@ -1370,8 +1370,8 @@ func (a *App) UpdateMfa(activate bool, userId, token string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdatePasswordByUserIdSendEmail(userId, newPassword, method string) *model.AppError {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) UpdatePasswordByUserIdSendEmail(userID, newPassword, method string) *model.AppError {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1409,8 +1409,8 @@ func (a *App) UpdatePasswordSendEmail(user *model.User, newPassword, method stri
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateHashedPasswordByUserId(userId, newHashedPassword string) *model.AppError {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) UpdateHashedPasswordByUserId(userID, newHashedPassword string) *model.AppError {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1491,13 +1491,13 @@ func (a *App) SendPasswordReset(email string, siteURL string) (bool, *model.AppE
|
||||
return a.Srv().EmailService.SendPasswordResetEmail(user.Email, token, user.Locale, siteURL)
|
||||
}
|
||||
|
||||
func (a *App) CreatePasswordRecoveryToken(userId, email string) (*model.Token, *model.AppError) {
|
||||
func (a *App) CreatePasswordRecoveryToken(userID, email string) (*model.Token, *model.AppError) {
|
||||
|
||||
tokenExtra := struct {
|
||||
UserId string
|
||||
Email string
|
||||
}{
|
||||
userId,
|
||||
userID,
|
||||
email,
|
||||
}
|
||||
jsonData, err := json.Marshal(tokenExtra)
|
||||
@@ -1540,8 +1540,8 @@ func (a *App) DeleteToken(token *model.Token) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError) {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) UpdateUserRoles(userID string, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError) {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
err.StatusCode = http.StatusBadRequest
|
||||
return nil, err
|
||||
@@ -1586,7 +1586,7 @@ func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent
|
||||
mlog.Warn("Failed during updating user roles", mlog.Err(result.NErr))
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(userID)
|
||||
a.ClearSessionCacheForUser(user.Id)
|
||||
|
||||
if sendWebSocketEvent {
|
||||
@@ -1818,14 +1818,14 @@ func (a *App) GetFilteredUsersStats(options *model.UserCountOptions) (*model.Use
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func (a *App) VerifyUserEmail(userId, email string) *model.AppError {
|
||||
if _, err := a.Srv().Store.User().VerifyEmail(userId, email); err != nil {
|
||||
func (a *App) VerifyUserEmail(userID, email string) *model.AppError {
|
||||
if _, err := a.Srv().Store.User().VerifyEmail(userID, email); err != nil {
|
||||
return model.NewAppError("VerifyUserEmail", "app.user.verify_email.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(userID)
|
||||
|
||||
user, err := a.GetUser(userId)
|
||||
user, err := a.GetUser(userID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1868,9 +1868,9 @@ func (a *App) SearchUsersInChannel(channelId string, term string, options *model
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (a *App) SearchUsersNotInChannel(teamID string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv().Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
||||
users, err := a.Srv().Store.User().SearchNotInChannel(teamID, channelId, term, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchUsersNotInChannel", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1882,10 +1882,10 @@ func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term stri
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersInTeam(teamId, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (a *App) SearchUsersInTeam(teamID, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
users, err := a.Srv().Store.User().Search(teamId, term, options)
|
||||
users, err := a.Srv().Store.User().Search(teamID, term, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchUsersInTeam", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1939,10 +1939,10 @@ func (a *App) SearchUsersInGroup(groupID string, term string, options *model.Use
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
func (a *App) AutocompleteUsersInChannel(teamID string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
autocomplete, err := a.Srv().Store.User().AutocompleteUsersInChannel(teamId, channelId, term, options)
|
||||
autocomplete, err := a.Srv().Store.User().AutocompleteUsersInChannel(teamID, channelId, term, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("AutocompleteUsersInChannel", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -1958,10 +1958,10 @@ func (a *App) AutocompleteUsersInChannel(teamId string, channelId string, term s
|
||||
return autocomplete, nil
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteUsersInTeam(teamId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError) {
|
||||
func (a *App) AutocompleteUsersInTeam(teamID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
users, err := a.Srv().Store.User().Search(teamId, term, options)
|
||||
users, err := a.Srv().Store.User().Search(teamID, term, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("AutocompleteUsersInTeam", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2031,8 +2031,8 @@ func (a *App) UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provide
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RestrictUsersGetByPermissions(userId string, options *model.UserGetOptions) (*model.UserGetOptions, *model.AppError) {
|
||||
restrictions, err := a.GetViewUsersRestrictions(userId)
|
||||
func (a *App) RestrictUsersGetByPermissions(userID string, options *model.UserGetOptions) (*model.UserGetOptions, *model.AppError) {
|
||||
restrictions, err := a.GetViewUsersRestrictions(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2043,29 +2043,29 @@ func (a *App) RestrictUsersGetByPermissions(userId string, options *model.UserGe
|
||||
|
||||
// FilterNonGroupTeamMembers returns the subset of the given user IDs of the users who are not members of groups
|
||||
// associated to the team excluding bots.
|
||||
func (a *App) FilterNonGroupTeamMembers(userIds []string, team *model.Team) ([]string, error) {
|
||||
func (a *App) FilterNonGroupTeamMembers(userIDs []string, team *model.Team) ([]string, error) {
|
||||
teamGroupUsers, err := a.GetTeamGroupUsers(team.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a.filterNonGroupUsers(userIds, teamGroupUsers)
|
||||
return a.filterNonGroupUsers(userIDs, teamGroupUsers)
|
||||
}
|
||||
|
||||
// FilterNonGroupChannelMembers returns the subset of the given user IDs of the users who are not members of groups
|
||||
// associated to the channel excluding bots
|
||||
func (a *App) FilterNonGroupChannelMembers(userIds []string, channel *model.Channel) ([]string, error) {
|
||||
func (a *App) FilterNonGroupChannelMembers(userIDs []string, channel *model.Channel) ([]string, error) {
|
||||
channelGroupUsers, err := a.GetChannelGroupUsers(channel.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a.filterNonGroupUsers(userIds, channelGroupUsers)
|
||||
return a.filterNonGroupUsers(userIDs, channelGroupUsers)
|
||||
}
|
||||
|
||||
// filterNonGroupUsers is a helper function that takes a list of user ids and a list of users
|
||||
// and returns the list of normal users present in userIds but not in groupUsers.
|
||||
func (a *App) filterNonGroupUsers(userIds []string, groupUsers []*model.User) ([]string, error) {
|
||||
// and returns the list of normal users present in userIDs but not in groupUsers.
|
||||
func (a *App) filterNonGroupUsers(userIDs []string, groupUsers []*model.User) ([]string, error) {
|
||||
nonMemberIds := []string{}
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIds, nil, false)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIDs, nil, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2087,8 +2087,8 @@ func (a *App) filterNonGroupUsers(userIds []string, groupUsers []*model.User) ([
|
||||
return nonMemberIds, nil
|
||||
}
|
||||
|
||||
func (a *App) RestrictUsersSearchByPermissions(userId string, options *model.UserSearchOptions) (*model.UserSearchOptions, *model.AppError) {
|
||||
restrictions, err := a.GetViewUsersRestrictions(userId)
|
||||
func (a *App) RestrictUsersSearchByPermissions(userID string, options *model.UserSearchOptions) (*model.UserSearchOptions, *model.AppError) {
|
||||
restrictions, err := a.GetViewUsersRestrictions(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2097,12 +2097,12 @@ func (a *App) RestrictUsersSearchByPermissions(userId string, options *model.Use
|
||||
return options, nil
|
||||
}
|
||||
|
||||
func (a *App) UserCanSeeOtherUser(userId string, otherUserId string) (bool, *model.AppError) {
|
||||
if userId == otherUserId {
|
||||
func (a *App) UserCanSeeOtherUser(userID string, otherUserId string) (bool, *model.AppError) {
|
||||
if userID == otherUserId {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
restrictions, err := a.GetViewUsersRestrictions(userId)
|
||||
restrictions, err := a.GetViewUsersRestrictions(userID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -2134,8 +2134,8 @@ func (a *App) UserCanSeeOtherUser(userId string, otherUserId string) (bool, *mod
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (a *App) userBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
|
||||
belongs, err := a.Srv().Store.Channel().UserBelongsToChannels(userId, channelIds)
|
||||
func (a *App) userBelongsToChannels(userID string, channelIds []string) (bool, *model.AppError) {
|
||||
belongs, err := a.Srv().Store.Channel().UserBelongsToChannels(userID, channelIds)
|
||||
if err != nil {
|
||||
return false, model.NewAppError("userBelongsToChannels", "app.channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2143,24 +2143,24 @@ func (a *App) userBelongsToChannels(userId string, channelIds []string) (bool, *
|
||||
return belongs, nil
|
||||
}
|
||||
|
||||
func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError) {
|
||||
if a.HasPermissionTo(userId, model.PERMISSION_VIEW_MEMBERS) {
|
||||
func (a *App) GetViewUsersRestrictions(userID string) (*model.ViewUsersRestrictions, *model.AppError) {
|
||||
if a.HasPermissionTo(userID, model.PERMISSION_VIEW_MEMBERS) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
teamIds, nErr := a.Srv().Store.Team().GetUserTeamIds(userId, true)
|
||||
teamIDs, nErr := a.Srv().Store.Team().GetUserTeamIds(userID, true)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetViewUsersRestrictions", "app.team.get_user_team_ids.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
teamIdsWithPermission := []string{}
|
||||
for _, teamId := range teamIds {
|
||||
if a.HasPermissionToTeam(userId, teamId, model.PERMISSION_VIEW_MEMBERS) {
|
||||
teamIdsWithPermission = append(teamIdsWithPermission, teamId)
|
||||
teamIDsWithPermission := []string{}
|
||||
for _, teamID := range teamIDs {
|
||||
if a.HasPermissionToTeam(userID, teamID, model.PERMISSION_VIEW_MEMBERS) {
|
||||
teamIDsWithPermission = append(teamIDsWithPermission, teamID)
|
||||
}
|
||||
}
|
||||
|
||||
userChannelMembers, err := a.Srv().Store.Channel().GetAllChannelMembersForUser(userId, true, true)
|
||||
userChannelMembers, err := a.Srv().Store.Channel().GetAllChannelMembersForUser(userID, true, true)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetViewUsersRestrictions", "app.channel.get_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2170,7 +2170,7 @@ func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestricti
|
||||
channelIds = append(channelIds, channelId)
|
||||
}
|
||||
|
||||
return &model.ViewUsersRestrictions{Teams: teamIdsWithPermission, Channels: channelIds}, nil
|
||||
return &model.ViewUsersRestrictions{Teams: teamIDsWithPermission, Channels: channelIds}, nil
|
||||
}
|
||||
|
||||
// PromoteGuestToUser Convert user's roles and all his mermbership's roles from
|
||||
@@ -2271,25 +2271,25 @@ func (a *App) DemoteUserToGuest(user *model.User) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) PublishUserTyping(userId, channelId, parentId string) *model.AppError {
|
||||
func (a *App) PublishUserTyping(userID, channelId, parentId string) *model.AppError {
|
||||
omitUsers := make(map[string]bool, 1)
|
||||
omitUsers[userId] = true
|
||||
omitUsers[userID] = true
|
||||
|
||||
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_TYPING, "", channelId, "", omitUsers)
|
||||
event.Add("parent_id", parentId)
|
||||
event.Add("user_id", userId)
|
||||
event.Add("user_id", userID)
|
||||
a.Publish(event)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// invalidateUserCacheAndPublish Invalidates cache for a user and publishes user updated event
|
||||
func (a *App) invalidateUserCacheAndPublish(userId string) {
|
||||
a.InvalidateCacheForUser(userId)
|
||||
func (a *App) invalidateUserCacheAndPublish(userID string) {
|
||||
a.InvalidateCacheForUser(userID)
|
||||
|
||||
user, userErr := a.GetUser(userId)
|
||||
user, userErr := a.GetUser(userID)
|
||||
if userErr != nil {
|
||||
mlog.Error("Error in getting users profile", mlog.String("user_id", userId), mlog.Err(userErr))
|
||||
mlog.Error("Error in getting users profile", mlog.String("user_id", userID), mlog.Err(userErr))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2356,8 +2356,8 @@ func (a *App) ConvertBotToUser(bot *model.Bot, userPatch *model.UserPatch, sysad
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (a *App) GetThreadsForUser(userId, teamId string, options model.GetUserThreadsOpts) (*model.Threads, *model.AppError) {
|
||||
threads, err := a.Srv().Store.Thread().GetThreadsForUser(userId, teamId, options)
|
||||
func (a *App) GetThreadsForUser(userID, teamID string, options model.GetUserThreadsOpts) (*model.Threads, *model.AppError) {
|
||||
threads, err := a.Srv().Store.Thread().GetThreadsForUser(userID, teamID, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetThreadsForUser", "app.user.get_threads_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2368,8 +2368,8 @@ func (a *App) GetThreadsForUser(userId, teamId string, options model.GetUserThre
|
||||
return threads, nil
|
||||
}
|
||||
|
||||
func (a *App) GetThreadForUser(userId, teamId, threadId string, extended bool) (*model.ThreadResponse, *model.AppError) {
|
||||
thread, err := a.Srv().Store.Thread().GetThreadForUser(userId, teamId, threadId, extended)
|
||||
func (a *App) GetThreadForUser(userID, teamID, threadId string, extended bool) (*model.ThreadResponse, *model.AppError) {
|
||||
thread, err := a.Srv().Store.Thread().GetThreadForUser(userID, teamID, threadId, extended)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetThreadForUser", "app.user.get_threads_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2381,34 +2381,34 @@ func (a *App) GetThreadForUser(userId, teamId, threadId string, extended bool) (
|
||||
return thread, nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateThreadsReadForUser(userId, teamId string) *model.AppError {
|
||||
nErr := a.Srv().Store.Thread().MarkAllAsRead(userId, teamId)
|
||||
func (a *App) UpdateThreadsReadForUser(userID, teamID string) *model.AppError {
|
||||
nErr := a.Srv().Store.Thread().MarkAllAsRead(userID, teamID)
|
||||
if nErr != nil {
|
||||
return model.NewAppError("UpdateThreadsReadForUser", "app.user.update_threads_read_for_user.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_READ_CHANGED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_READ_CHANGED, "", "", userID, nil)
|
||||
a.Publish(message)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateThreadFollowForUser(userId, threadId string, state bool) *model.AppError {
|
||||
err := a.Srv().Store.Thread().CreateMembershipIfNeeded(userId, threadId, state, false, true)
|
||||
func (a *App) UpdateThreadFollowForUser(userID, threadId string, state bool) *model.AppError {
|
||||
err := a.Srv().Store.Thread().CreateMembershipIfNeeded(userID, threadId, state, false, true)
|
||||
if err != nil {
|
||||
return model.NewAppError("UpdateThreadFollowForUser", "app.user.update_thread_follow_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_FOLLOW_CHANGED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_FOLLOW_CHANGED, "", "", userID, nil)
|
||||
message.Add("thread_id", threadId)
|
||||
message.Add("state", state)
|
||||
a.Publish(message)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateThreadReadForUser(userId, teamId, threadId string, timestamp int64) *model.AppError {
|
||||
user, err := a.GetUser(userId)
|
||||
func (a *App) UpdateThreadReadForUser(userID, teamID, threadId string, timestamp int64) *model.AppError {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
membership, nErr := a.Srv().Store.Thread().GetMembershipForUser(userId, threadId)
|
||||
membership, nErr := a.Srv().Store.Thread().GetMembershipForUser(userID, threadId)
|
||||
if nErr != nil {
|
||||
return model.NewAppError("UpdateThreadsReadForUser", "app.user.update_threads_read_for_user.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -2417,7 +2417,7 @@ func (a *App) UpdateThreadReadForUser(userId, teamId, threadId string, timestamp
|
||||
return err
|
||||
}
|
||||
|
||||
membership.UnreadMentions, err = a.countThreadMentions(user, post, teamId, timestamp)
|
||||
membership.UnreadMentions, err = a.countThreadMentions(user, post, teamID, timestamp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2427,11 +2427,11 @@ func (a *App) UpdateThreadReadForUser(userId, teamId, threadId string, timestamp
|
||||
return model.NewAppError("UpdateThreadsReadForUser", "app.user.update_threads_read_for_user.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
nErr = a.Srv().Store.Thread().MarkAsRead(userId, threadId, timestamp)
|
||||
nErr = a.Srv().Store.Thread().MarkAsRead(userID, threadId, timestamp)
|
||||
if nErr != nil {
|
||||
return model.NewAppError("UpdateThreadReadForUser", "app.user.update_thread_read_for_user.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_READ_CHANGED, "", "", userId, nil)
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_READ_CHANGED, "", "", userID, nil)
|
||||
message.Add("thread_id", threadId)
|
||||
message.Add("timestamp", timestamp)
|
||||
a.Publish(message)
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
)
|
||||
|
||||
func (a *App) GetUserTermsOfService(userId string) (*model.UserTermsOfService, *model.AppError) {
|
||||
u, err := a.Srv().Store.UserTermsOfService().GetByUser(userId)
|
||||
func (a *App) GetUserTermsOfService(userID string) (*model.UserTermsOfService, *model.AppError) {
|
||||
u, err := a.Srv().Store.UserTermsOfService().GetByUser(userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -26,10 +26,10 @@ func (a *App) GetUserTermsOfService(userId string) (*model.UserTermsOfService, *
|
||||
return u, nil
|
||||
}
|
||||
|
||||
func (a *App) SaveUserTermsOfService(userId, termsOfServiceId string, accepted bool) *model.AppError {
|
||||
func (a *App) SaveUserTermsOfService(userID, termsOfServiceId string, accepted bool) *model.AppError {
|
||||
if accepted {
|
||||
userTermsOfService := &model.UserTermsOfService{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
TermsOfServiceId: termsOfServiceId,
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (a *App) SaveUserTermsOfService(userId, termsOfServiceId string, accepted b
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := a.Srv().Store.UserTermsOfService().Delete(userId, termsOfServiceId); err != nil {
|
||||
if err := a.Srv().Store.UserTermsOfService().Delete(userID, termsOfServiceId); err != nil {
|
||||
return model.NewAppError("SaveUserTermsOfService", "app.user_terms_of_service.delete.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -717,7 +717,7 @@ func TestCreateUserWithToken(t *testing.T) {
|
||||
t.Run("invalid token type", func(t *testing.T) {
|
||||
token := model.NewToken(
|
||||
TokenTypeVerifyEmail,
|
||||
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
|
||||
model.MapToJson(map[string]string{"teamID": th.BasicTeam.Id, "email": user.Email}),
|
||||
)
|
||||
require.Nil(t, th.App.Srv().Store.Token().Save(token))
|
||||
defer th.App.DeleteToken(token)
|
||||
|
||||
@@ -311,7 +311,7 @@ func (wc *WebConn) createHelloMessage() *model.WebSocketEvent {
|
||||
}
|
||||
|
||||
func (wc *WebConn) shouldSendEventToGuest(msg *model.WebSocketEvent) bool {
|
||||
var userId string
|
||||
var userID string
|
||||
var canSee bool
|
||||
|
||||
switch msg.EventType() {
|
||||
@@ -321,14 +321,14 @@ func (wc *WebConn) shouldSendEventToGuest(msg *model.WebSocketEvent) bool {
|
||||
mlog.Debug("webhub.shouldSendEvent: user not found in message", mlog.Any("user", msg.GetData()["user"]))
|
||||
return false
|
||||
}
|
||||
userId = user.Id
|
||||
userID = user.Id
|
||||
case model.WEBSOCKET_EVENT_NEW_USER:
|
||||
userId = msg.GetData()["user_id"].(string)
|
||||
userID = msg.GetData()["user_id"].(string)
|
||||
default:
|
||||
return true
|
||||
}
|
||||
|
||||
canSee, err := wc.App.UserCanSeeOtherUser(wc.UserId, userId)
|
||||
canSee, err := wc.App.UserCanSeeOtherUser(wc.UserId, userID)
|
||||
if err != nil {
|
||||
mlog.Error("webhub.shouldSendEvent.", mlog.Err(err))
|
||||
return false
|
||||
@@ -414,8 +414,8 @@ func (wc *WebConn) shouldSendEvent(msg *model.WebSocketEvent) bool {
|
||||
}
|
||||
|
||||
// IsMemberOfTeam returns whether the user of the WebConn
|
||||
// is a member of the given teamId or not.
|
||||
func (wc *WebConn) isMemberOfTeam(teamId string) bool {
|
||||
// is a member of the given teamID or not.
|
||||
func (wc *WebConn) isMemberOfTeam(teamID string) bool {
|
||||
currentSession := wc.GetSession()
|
||||
|
||||
if currentSession == nil || currentSession.Token == "" {
|
||||
@@ -432,7 +432,7 @@ func (wc *WebConn) isMemberOfTeam(teamId string) bool {
|
||||
currentSession = session
|
||||
}
|
||||
|
||||
return currentSession.GetTeamByTeamId(teamId) != nil
|
||||
return currentSession.GetTeamByTeamId(teamID) != nil
|
||||
}
|
||||
|
||||
func (wc *WebConn) logSocketErr(source string, err error) {
|
||||
|
||||
@@ -19,7 +19,7 @@ const (
|
||||
)
|
||||
|
||||
type webConnActivityMessage struct {
|
||||
userId string
|
||||
userID string
|
||||
sessionToken string
|
||||
activityAt int64
|
||||
}
|
||||
@@ -30,7 +30,7 @@ type webConnDirectMessage struct {
|
||||
}
|
||||
|
||||
type webConnSessionMessage struct {
|
||||
userId string
|
||||
userID string
|
||||
sessionToken string
|
||||
isRegistered chan bool
|
||||
}
|
||||
@@ -94,19 +94,19 @@ func (a *App) HubStart() {
|
||||
a.srv.hubs = hubs
|
||||
}
|
||||
|
||||
func (a *App) invalidateCacheForUserSkipClusterSend(userId string) {
|
||||
a.Srv().Store.Channel().InvalidateAllChannelMembersForUser(userId)
|
||||
a.InvalidateWebConnSessionCacheForUser(userId)
|
||||
func (a *App) invalidateCacheForUserSkipClusterSend(userID string) {
|
||||
a.Srv().Store.Channel().InvalidateAllChannelMembersForUser(userID)
|
||||
a.InvalidateWebConnSessionCacheForUser(userID)
|
||||
}
|
||||
|
||||
func (a *App) invalidateCacheForWebhook(webhookId string) {
|
||||
a.Srv().Store.Webhook().InvalidateWebhookCache(webhookId)
|
||||
func (a *App) invalidateCacheForWebhook(webhookID string) {
|
||||
a.Srv().Store.Webhook().InvalidateWebhookCache(webhookID)
|
||||
}
|
||||
|
||||
func (a *App) InvalidateWebConnSessionCacheForUser(userId string) {
|
||||
hub := a.GetHubForUserId(userId)
|
||||
func (a *App) InvalidateWebConnSessionCacheForUser(userID string) {
|
||||
hub := a.GetHubForUserId(userID)
|
||||
if hub != nil {
|
||||
hub.InvalidateUser(userId)
|
||||
hub.InvalidateUser(userID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,20 +124,20 @@ func (a *App) HubStop() {
|
||||
}
|
||||
|
||||
// GetHubForUserId returns the hub for a given user id.
|
||||
func (s *Server) GetHubForUserId(userId string) *Hub {
|
||||
// TODO: check if caching the userId -> hub mapping
|
||||
func (s *Server) GetHubForUserId(userID string) *Hub {
|
||||
// TODO: check if caching the userID -> hub mapping
|
||||
// is worth the memory tradeoff.
|
||||
// https://mattermost.atlassian.net/browse/MM-26629.
|
||||
var hash maphash.Hash
|
||||
hash.SetSeed(s.hashSeed)
|
||||
hash.Write([]byte(userId))
|
||||
hash.Write([]byte(userID))
|
||||
index := hash.Sum64() % uint64(len(s.hubs))
|
||||
|
||||
return s.hubs[int(index)]
|
||||
}
|
||||
|
||||
func (a *App) GetHubForUserId(userId string) *Hub {
|
||||
return a.Srv().GetHubForUserId(userId)
|
||||
func (a *App) GetHubForUserId(userID string) *Hub {
|
||||
return a.Srv().GetHubForUserId(userID)
|
||||
}
|
||||
|
||||
// HubRegister registers a connection to a hub.
|
||||
@@ -254,12 +254,12 @@ func (a *App) invalidateCacheForChannelMembersNotifyPropsSkipClusterSend(channel
|
||||
a.Srv().Store.Channel().InvalidateCacheForChannelMembersNotifyProps(channelId)
|
||||
}
|
||||
|
||||
func (a *App) invalidateCacheForChannelByNameSkipClusterSend(teamId, name string) {
|
||||
if teamId == "" {
|
||||
teamId = "dm"
|
||||
func (a *App) invalidateCacheForChannelByNameSkipClusterSend(teamID, name string) {
|
||||
if teamID == "" {
|
||||
teamID = "dm"
|
||||
}
|
||||
|
||||
a.Srv().Store.Channel().InvalidateChannelByName(teamId, name)
|
||||
a.Srv().Store.Channel().InvalidateChannelByName(teamID, name)
|
||||
}
|
||||
|
||||
func (a *App) invalidateCacheForChannelPosts(channelId string) {
|
||||
@@ -267,31 +267,31 @@ func (a *App) invalidateCacheForChannelPosts(channelId string) {
|
||||
a.Srv().Store.Post().InvalidateLastPostTimeCache(channelId)
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForUser(userId string) {
|
||||
a.invalidateCacheForUserSkipClusterSend(userId)
|
||||
func (a *App) InvalidateCacheForUser(userID string) {
|
||||
a.invalidateCacheForUserSkipClusterSend(userID)
|
||||
|
||||
a.Srv().Store.User().InvalidateProfilesInChannelCacheByUser(userId)
|
||||
a.Srv().Store.User().InvalidateProfileCacheForUser(userId)
|
||||
a.Srv().Store.User().InvalidateProfilesInChannelCacheByUser(userID)
|
||||
a.Srv().Store.User().InvalidateProfileCacheForUser(userID)
|
||||
|
||||
if a.Cluster() != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER,
|
||||
SendType: model.CLUSTER_SEND_BEST_EFFORT,
|
||||
Data: userId,
|
||||
Data: userID,
|
||||
}
|
||||
a.Cluster().SendClusterMessage(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) invalidateCacheForUserTeams(userId string) {
|
||||
a.InvalidateWebConnSessionCacheForUser(userId)
|
||||
a.Srv().Store.Team().InvalidateAllTeamIdsForUser(userId)
|
||||
func (a *App) invalidateCacheForUserTeams(userID string) {
|
||||
a.InvalidateWebConnSessionCacheForUser(userID)
|
||||
a.Srv().Store.Team().InvalidateAllTeamIdsForUser(userID)
|
||||
|
||||
if a.Cluster() != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER_TEAMS,
|
||||
SendType: model.CLUSTER_SEND_BEST_EFFORT,
|
||||
Data: userId,
|
||||
Data: userID,
|
||||
}
|
||||
a.Cluster().SendClusterMessage(msg)
|
||||
}
|
||||
@@ -331,9 +331,9 @@ func (h *Hub) Unregister(webConn *WebConn) {
|
||||
}
|
||||
|
||||
// Determines if a user's session is registered a connection from the hub.
|
||||
func (h *Hub) IsRegistered(userId, sessionToken string) bool {
|
||||
func (h *Hub) IsRegistered(userID, sessionToken string) bool {
|
||||
ws := &webConnSessionMessage{
|
||||
userId: userId,
|
||||
userID: userID,
|
||||
sessionToken: sessionToken,
|
||||
isRegistered: make(chan bool),
|
||||
}
|
||||
@@ -366,19 +366,19 @@ func (h *Hub) Broadcast(message *model.WebSocketEvent) {
|
||||
}
|
||||
|
||||
// InvalidateUser invalidates the cache for the given user.
|
||||
func (h *Hub) InvalidateUser(userId string) {
|
||||
func (h *Hub) InvalidateUser(userID string) {
|
||||
select {
|
||||
case h.invalidateUser <- userId:
|
||||
case h.invalidateUser <- userID:
|
||||
case <-h.stop:
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateActivity sets the LastUserActivityAt field for the connection
|
||||
// of the user.
|
||||
func (h *Hub) UpdateActivity(userId, sessionToken string, activityAt int64) {
|
||||
func (h *Hub) UpdateActivity(userID, sessionToken string, activityAt int64) {
|
||||
select {
|
||||
case h.activity <- &webConnActivityMessage{
|
||||
userId: userId,
|
||||
userID: userID,
|
||||
sessionToken: sessionToken,
|
||||
activityAt: activityAt,
|
||||
}:
|
||||
@@ -417,7 +417,7 @@ func (h *Hub) Start() {
|
||||
for {
|
||||
select {
|
||||
case webSessionMessage := <-h.checkRegistered:
|
||||
conns := connIndex.ForUser(webSessionMessage.userId)
|
||||
conns := connIndex.ForUser(webSessionMessage.userID)
|
||||
var isRegistered bool
|
||||
for _, conn := range conns {
|
||||
if conn.GetSessionToken() == webSessionMessage.sessionToken {
|
||||
@@ -458,12 +458,12 @@ func (h *Hub) Start() {
|
||||
h.app.SetStatusLastActivityAt(webConn.UserId, latestActivity)
|
||||
})
|
||||
}
|
||||
case userId := <-h.invalidateUser:
|
||||
for _, webConn := range connIndex.ForUser(userId) {
|
||||
case userID := <-h.invalidateUser:
|
||||
for _, webConn := range connIndex.ForUser(userID) {
|
||||
webConn.InvalidateCache()
|
||||
}
|
||||
case activity := <-h.activity:
|
||||
for _, webConn := range connIndex.ForUser(activity.userId) {
|
||||
for _, webConn := range connIndex.ForUser(activity.userID) {
|
||||
if webConn.GetSessionToken() == activity.sessionToken {
|
||||
webConn.lastUserActivityAt = activity.activityAt
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ func dummyWebsocketHandler(t *testing.T) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func registerDummyWebConn(t *testing.T, a *App, addr net.Addr, userId string) *WebConn {
|
||||
func registerDummyWebConn(t *testing.T, a *App, addr net.Addr, userID string) *WebConn {
|
||||
session, appErr := a.CreateSession(&model.Session{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestHubSessionRevokeRace(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
for i := 0; i <= broadcastQueueSize; i++ {
|
||||
hub.Broadcast(model.NewWebSocketEvent("", "teamId", "", "", nil))
|
||||
hub.Broadcast(model.NewWebSocketEvent("", "teamID", "", "", nil))
|
||||
}
|
||||
close(done)
|
||||
}()
|
||||
|
||||
@@ -246,12 +246,12 @@ func SplitWebhookPost(post *model.Post, maxPostSize int) ([]*model.Post, *model.
|
||||
return splits, nil
|
||||
}
|
||||
|
||||
func (a *App) CreateWebhookPost(userId string, channel *model.Channel, text, overrideUsername, overrideIconUrl, overrideIconEmoji string, props model.StringInterface, postType string, postRootId string) (*model.Post, *model.AppError) {
|
||||
func (a *App) CreateWebhookPost(userID string, channel *model.Channel, text, overrideUsername, overrideIconURL, overrideIconEmoji string, props model.StringInterface, postType string, postRootId string) (*model.Post, *model.AppError) {
|
||||
// parse links into Markdown format
|
||||
linkWithTextRegex := regexp.MustCompile(`<([^\n<\|>]+)\|([^\n>]+)>`)
|
||||
text = linkWithTextRegex.ReplaceAllString(text, "[${2}](${1})")
|
||||
|
||||
post := &model.Post{UserId: userId, ChannelId: channel.Id, Message: text, Type: postType, RootId: postRootId}
|
||||
post := &model.Post{UserId: userID, ChannelId: channel.Id, Message: text, Type: postType, RootId: postRootId}
|
||||
post.AddProp("from_webhook", "true")
|
||||
|
||||
if strings.HasPrefix(post.Type, model.POST_SYSTEM_MESSAGE_PREFIX) {
|
||||
@@ -272,8 +272,8 @@ func (a *App) CreateWebhookPost(userId string, channel *model.Channel, text, ove
|
||||
}
|
||||
|
||||
if *a.Config().ServiceSettings.EnablePostIconOverride {
|
||||
if overrideIconUrl != "" {
|
||||
post.AddProp("override_icon_url", overrideIconUrl)
|
||||
if overrideIconURL != "" {
|
||||
post.AddProp("override_icon_url", overrideIconURL)
|
||||
}
|
||||
if overrideIconEmoji != "" {
|
||||
post.AddProp("override_icon_emoji", overrideIconEmoji)
|
||||
@@ -373,26 +373,26 @@ func (a *App) UpdateIncomingWebhook(oldHook, updatedHook *model.IncomingWebhook)
|
||||
return newWebhook, nil
|
||||
}
|
||||
|
||||
func (a *App) DeleteIncomingWebhook(hookId string) *model.AppError {
|
||||
func (a *App) DeleteIncomingWebhook(hookID string) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableIncomingWebhooks {
|
||||
return model.NewAppError("DeleteIncomingWebhook", "api.incoming_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Webhook().DeleteIncoming(hookId, model.GetMillis()); err != nil {
|
||||
if err := a.Srv().Store.Webhook().DeleteIncoming(hookID, model.GetMillis()); err != nil {
|
||||
return model.NewAppError("DeleteIncomingWebhook", "app.webhooks.delete_incoming.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
a.invalidateCacheForWebhook(hookId)
|
||||
a.invalidateCacheForWebhook(hookID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetIncomingWebhook(hookId string) (*model.IncomingWebhook, *model.AppError) {
|
||||
func (a *App) GetIncomingWebhook(hookID string) (*model.IncomingWebhook, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableIncomingWebhooks {
|
||||
return nil, model.NewAppError("GetIncomingWebhook", "api.incoming_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
webhook, err := a.Srv().Store.Webhook().GetIncoming(hookId, true)
|
||||
webhook, err := a.Srv().Store.Webhook().GetIncoming(hookID, true)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -406,16 +406,16 @@ func (a *App) GetIncomingWebhook(hookId string) (*model.IncomingWebhook, *model.
|
||||
return webhook, nil
|
||||
}
|
||||
|
||||
func (a *App) GetIncomingWebhooksForTeamPage(teamId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError) {
|
||||
return a.GetIncomingWebhooksForTeamPageByUser(teamId, "", page, perPage)
|
||||
func (a *App) GetIncomingWebhooksForTeamPage(teamID string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError) {
|
||||
return a.GetIncomingWebhooksForTeamPageByUser(teamID, "", page, perPage)
|
||||
}
|
||||
|
||||
func (a *App) GetIncomingWebhooksForTeamPageByUser(teamId string, userId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError) {
|
||||
func (a *App) GetIncomingWebhooksForTeamPageByUser(teamID string, userID string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableIncomingWebhooks {
|
||||
return nil, model.NewAppError("GetIncomingWebhooksForTeamPage", "api.incoming_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
webhooks, err := a.Srv().Store.Webhook().GetIncomingByTeamByUser(teamId, userId, page*perPage, perPage)
|
||||
webhooks, err := a.Srv().Store.Webhook().GetIncomingByTeamByUser(teamID, userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetIncomingWebhooksForTeamPage", "app.webhooks.get_incoming_by_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -423,12 +423,12 @@ func (a *App) GetIncomingWebhooksForTeamPageByUser(teamId string, userId string,
|
||||
return webhooks, nil
|
||||
}
|
||||
|
||||
func (a *App) GetIncomingWebhooksPageByUser(userId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError) {
|
||||
func (a *App) GetIncomingWebhooksPageByUser(userID string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableIncomingWebhooks {
|
||||
return nil, model.NewAppError("GetIncomingWebhooksPageByUser", "api.incoming_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
webhooks, err := a.Srv().Store.Webhook().GetIncomingListByUser(userId, page*perPage, perPage)
|
||||
webhooks, err := a.Srv().Store.Webhook().GetIncomingListByUser(userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetIncomingWebhooksPageByUser", "app.webhooks.get_incoming_by_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -548,12 +548,12 @@ func (a *App) UpdateOutgoingWebhook(oldHook, updatedHook *model.OutgoingWebhook)
|
||||
return webhook, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOutgoingWebhook(hookId string) (*model.OutgoingWebhook, *model.AppError) {
|
||||
func (a *App) GetOutgoingWebhook(hookID string) (*model.OutgoingWebhook, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOutgoingWebhooks {
|
||||
return nil, model.NewAppError("GetOutgoingWebhook", "api.outgoing_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
webhook, err := a.Srv().Store.Webhook().GetOutgoing(hookId)
|
||||
webhook, err := a.Srv().Store.Webhook().GetOutgoing(hookID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -571,12 +571,12 @@ func (a *App) GetOutgoingWebhooksPage(page, perPage int) ([]*model.OutgoingWebho
|
||||
return a.GetOutgoingWebhooksPageByUser("", page, perPage)
|
||||
}
|
||||
|
||||
func (a *App) GetOutgoingWebhooksPageByUser(userId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
func (a *App) GetOutgoingWebhooksPageByUser(userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOutgoingWebhooks {
|
||||
return nil, model.NewAppError("GetOutgoingWebhooksPageByUser", "api.outgoing_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
webhooks, err := a.Srv().Store.Webhook().GetOutgoingListByUser(userId, page*perPage, perPage)
|
||||
webhooks, err := a.Srv().Store.Webhook().GetOutgoingListByUser(userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetOutgoingWebhooksPageByUser", "app.webhooks.get_outgoing_by_channel.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -584,12 +584,12 @@ func (a *App) GetOutgoingWebhooksPageByUser(userId string, page, perPage int) ([
|
||||
return webhooks, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOutgoingWebhooksForChannelPageByUser(channelId string, userId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
func (a *App) GetOutgoingWebhooksForChannelPageByUser(channelId string, userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOutgoingWebhooks {
|
||||
return nil, model.NewAppError("GetOutgoingWebhooksForChannelPage", "api.outgoing_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
webhooks, err := a.Srv().Store.Webhook().GetOutgoingByChannelByUser(channelId, userId, page*perPage, perPage)
|
||||
webhooks, err := a.Srv().Store.Webhook().GetOutgoingByChannelByUser(channelId, userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetOutgoingWebhooksForChannelPage", "app.webhooks.get_outgoing_by_channel.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -597,16 +597,16 @@ func (a *App) GetOutgoingWebhooksForChannelPageByUser(channelId string, userId s
|
||||
return webhooks, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOutgoingWebhooksForTeamPage(teamId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
return a.GetOutgoingWebhooksForTeamPageByUser(teamId, "", page, perPage)
|
||||
func (a *App) GetOutgoingWebhooksForTeamPage(teamID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
return a.GetOutgoingWebhooksForTeamPageByUser(teamID, "", page, perPage)
|
||||
}
|
||||
|
||||
func (a *App) GetOutgoingWebhooksForTeamPageByUser(teamId string, userId string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
func (a *App) GetOutgoingWebhooksForTeamPageByUser(teamID string, userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOutgoingWebhooks {
|
||||
return nil, model.NewAppError("GetOutgoingWebhooksForTeamPageByUser", "api.outgoing_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
webhooks, err := a.Srv().Store.Webhook().GetOutgoingByTeamByUser(teamId, userId, page*perPage, perPage)
|
||||
webhooks, err := a.Srv().Store.Webhook().GetOutgoingByTeamByUser(teamID, userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetOutgoingWebhooksForTeamPageByUser", "app.webhooks.get_outgoing_by_team.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -614,12 +614,12 @@ func (a *App) GetOutgoingWebhooksForTeamPageByUser(teamId string, userId string,
|
||||
return webhooks, nil
|
||||
}
|
||||
|
||||
func (a *App) DeleteOutgoingWebhook(hookId string) *model.AppError {
|
||||
func (a *App) DeleteOutgoingWebhook(hookID string) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableOutgoingWebhooks {
|
||||
return model.NewAppError("DeleteOutgoingWebhook", "api.outgoing_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Webhook().DeleteOutgoing(hookId, model.GetMillis()); err != nil {
|
||||
if err := a.Srv().Store.Webhook().DeleteOutgoing(hookID, model.GetMillis()); err != nil {
|
||||
return model.NewAppError("DeleteOutgoingWebhook", "app.webhooks.delete_outgoing.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -641,14 +641,14 @@ func (a *App) RegenOutgoingWebhookToken(hook *model.OutgoingWebhook) (*model.Out
|
||||
return webhook, nil
|
||||
}
|
||||
|
||||
func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookRequest) *model.AppError {
|
||||
func (a *App) HandleIncomingWebhook(hookID string, req *model.IncomingWebhookRequest) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableIncomingWebhooks {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
hchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
webhook, err := a.Srv().Store.Webhook().GetIncoming(hookId, true)
|
||||
webhook, err := a.Srv().Store.Webhook().GetIncoming(hookID, true)
|
||||
hchan <- store.StoreResult{Data: webhook, NErr: err}
|
||||
close(hchan)
|
||||
}()
|
||||
@@ -775,18 +775,18 @@ func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookReq
|
||||
overrideUsername = req.Username
|
||||
}
|
||||
|
||||
overrideIconUrl := hook.IconURL
|
||||
overrideIconURL := hook.IconURL
|
||||
if req.IconURL != "" {
|
||||
overrideIconUrl = req.IconURL
|
||||
overrideIconURL = req.IconURL
|
||||
}
|
||||
|
||||
_, err := a.CreateWebhookPost(hook.UserId, channel, text, overrideUsername, overrideIconUrl, req.IconEmoji, req.Props, webhookType, "")
|
||||
_, err := a.CreateWebhookPost(hook.UserId, channel, text, overrideUsername, overrideIconURL, req.IconEmoji, req.Props, webhookType, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) CreateCommandWebhook(commandId string, args *model.CommandArgs) (*model.CommandWebhook, *model.AppError) {
|
||||
func (a *App) CreateCommandWebhook(commandID string, args *model.CommandArgs) (*model.CommandWebhook, *model.AppError) {
|
||||
hook := &model.CommandWebhook{
|
||||
CommandId: commandId,
|
||||
CommandId: commandID,
|
||||
UserId: args.UserId,
|
||||
ChannelId: args.ChannelId,
|
||||
RootId: args.RootId,
|
||||
@@ -810,17 +810,17 @@ func (a *App) CreateCommandWebhook(commandId string, args *model.CommandArgs) (*
|
||||
return savedHook, nil
|
||||
}
|
||||
|
||||
func (a *App) HandleCommandWebhook(hookId string, response *model.CommandResponse) *model.AppError {
|
||||
func (a *App) HandleCommandWebhook(hookID string, response *model.CommandResponse) *model.AppError {
|
||||
if response == nil {
|
||||
return model.NewAppError("HandleCommandWebhook", "app.command_webhook.handle_command_webhook.parse", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
hook, nErr := a.Srv().Store.CommandWebhook().Get(hookId)
|
||||
hook, nErr := a.Srv().Store.CommandWebhook().Get(hookID)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return model.NewAppError("HandleCommandWebhook", "app.command_webhook.get.missing", map[string]interface{}{"hook_id": hookId}, nfErr.Error(), http.StatusNotFound)
|
||||
return model.NewAppError("HandleCommandWebhook", "app.command_webhook.get.missing", map[string]interface{}{"hook_id": hookID}, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("HandleCommandWebhook", "app.command_webhook.get.internal_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -607,7 +607,7 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
|
||||
EnablePostUsernameOverride bool
|
||||
EnablePostIconOverride bool
|
||||
ExpectedUsername string
|
||||
ExpectedIconUrl string
|
||||
ExpectedIconURL string
|
||||
WebhookResponse *model.OutgoingWebhookResponse
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
|
||||
EnablePostUsernameOverride: true,
|
||||
EnablePostIconOverride: true,
|
||||
ExpectedUsername: "some-user-name",
|
||||
ExpectedIconUrl: "http://some-icon/",
|
||||
ExpectedIconURL: "http://some-icon/",
|
||||
},
|
||||
"Should not override username and Icon": {
|
||||
EnablePostUsernameOverride: false,
|
||||
@@ -647,7 +647,7 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
|
||||
EnablePostUsernameOverride: true,
|
||||
EnablePostIconOverride: true,
|
||||
ExpectedUsername: "webhookuser",
|
||||
ExpectedIconUrl: "http://webhok/icon",
|
||||
ExpectedIconURL: "http://webhok/icon",
|
||||
WebhookResponse: &model.OutgoingWebhookResponse{Text: &webHookResponse, Username: "webhookuser", IconURL: "http://webhok/icon"},
|
||||
},
|
||||
}
|
||||
@@ -692,8 +692,8 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
|
||||
case webhookPost := <-createdPost:
|
||||
assert.Equal(t, webhookPost.Message, "sample response text from test server")
|
||||
assert.Equal(t, webhookPost.GetProp("from_webhook"), "true")
|
||||
if testCase.ExpectedIconUrl != "" {
|
||||
assert.Equal(t, webhookPost.GetProp("override_icon_url"), testCase.ExpectedIconUrl)
|
||||
if testCase.ExpectedIconURL != "" {
|
||||
assert.Equal(t, webhookPost.GetProp("override_icon_url"), testCase.ExpectedIconURL)
|
||||
} else {
|
||||
assert.Nil(t, webhookPost.GetProp("override_icon_url"))
|
||||
}
|
||||
|
||||
@@ -73,9 +73,9 @@ func dummyWebsocketHandler() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func registerDummyWebConn(a *App, addr net.Addr, userId string) *WebConn {
|
||||
func registerDummyWebConn(a *App, addr net.Addr, userID string) *WebConn {
|
||||
session, appErr := a.CreateSession(&model.Session{
|
||||
UserId: userId,
|
||||
UserId: userID,
|
||||
})
|
||||
if appErr != nil {
|
||||
panic(appErr)
|
||||
|
||||
Ссылка в новой задаче
Block a user