MM-21898 - Part 1: Generate and use an interface instead of *A… (#13840)
* Generate and use an interface instead of *App
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
66fc096768
Коммит
17523fa5d9
228
app/user.go
228
app/user.go
@@ -62,12 +62,12 @@ func (a *App) CreateUserWithToken(user *model.User, token *model.Token) (*model.
|
||||
|
||||
tokenData := model.MapFromJson(strings.NewReader(token.Extra))
|
||||
|
||||
team, err := a.Srv.Store.Team().Get(tokenData["teamId"])
|
||||
team, err := a.Srv().Store.Team().Get(tokenData["teamId"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
channels, err := a.Srv.Store.Channel().GetChannelsByIds(strings.Split(tokenData["channels"], " "))
|
||||
channels, err := a.Srv().Store.Channel().GetChannelsByIds(strings.Split(tokenData["channels"], " "))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (a *App) CreateUserWithInviteId(user *model.User, inviteId string) (*model.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
team, err := a.Srv.Store.Team().GetByInviteId(inviteId)
|
||||
team, err := a.Srv().Store.Team().GetByInviteId(inviteId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func (a *App) IsUserSignUpAllowed() *model.AppError {
|
||||
|
||||
func (a *App) IsFirstUserAccount() bool {
|
||||
if a.SessionCacheLength() == 0 {
|
||||
count, err := a.Srv.Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
count, err := a.Srv().Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
if err != nil {
|
||||
mlog.Error("There was a error fetching if first user account", mlog.Err(err))
|
||||
return false
|
||||
@@ -204,7 +204,7 @@ func (a *App) IsFirstUserAccount() bool {
|
||||
// indexUser fetches the required information to index a user from the database and
|
||||
// calls the elasticsearch interface method
|
||||
func (a *App) indexUser(user *model.User) *model.AppError {
|
||||
userTeams, err := a.Srv.Store.Team().GetTeamsByUserId(user.Id)
|
||||
userTeams, err := a.Srv().Store.Team().GetTeamsByUserId(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (a *App) indexUser(user *model.User) *model.AppError {
|
||||
userTeamsIds = append(userTeamsIds, team.Id)
|
||||
}
|
||||
|
||||
userChannelMembers, err := a.Srv.Store.Channel().GetAllChannelMembersForUser(user.Id, false, true)
|
||||
userChannelMembers, err := a.Srv().Store.Channel().GetAllChannelMembersForUser(user.Id, false, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (a *App) indexUser(user *model.User) *model.AppError {
|
||||
userChannelsIds = append(userChannelsIds, channelId)
|
||||
}
|
||||
|
||||
return a.Elasticsearch.IndexUser(user, userTeamsIds, userChannelsIds)
|
||||
return a.Elasticsearch().IndexUser(user, userTeamsIds, userChannelsIds)
|
||||
}
|
||||
|
||||
func (a *App) indexUserFromId(userId string) *model.AppError {
|
||||
@@ -263,7 +263,7 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
|
||||
|
||||
// Below is a special case where the first user in the entire
|
||||
// system is granted the system_admin role
|
||||
count, err := a.Srv.Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
count, err := a.Srv().Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -285,7 +285,7 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
|
||||
a.Publish(message)
|
||||
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
pluginContext := a.PluginContext()
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.UserHasBeenCreated(pluginContext, user)
|
||||
@@ -295,7 +295,7 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
|
||||
}
|
||||
|
||||
if a.IsESIndexingEnabled() {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.indexUser(user); err != nil {
|
||||
mlog.Error("Encountered error indexing user", mlog.String("user_id", user.Id), mlog.Err(err))
|
||||
}
|
||||
@@ -312,7 +312,7 @@ func (a *App) createUser(user *model.User) (*model.User, *model.AppError) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ruser, err := a.Srv.Store.User().Save(user)
|
||||
ruser, err := a.Srv().Store.User().Save(user)
|
||||
if err != nil {
|
||||
mlog.Error("Couldn't save the user", mlog.Err(err))
|
||||
return nil, err
|
||||
@@ -325,7 +325,7 @@ func (a *App) createUser(user *model.User) (*model.User, *model.AppError) {
|
||||
}
|
||||
|
||||
pref := model.Preference{UserId: ruser.Id, Category: model.PREFERENCE_CATEGORY_TUTORIAL_STEPS, Name: ruser.Id, Value: "0"}
|
||||
if err := a.Srv.Store.Preference().Save(&model.Preferences{pref}); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(&model.Preferences{pref}); err != nil {
|
||||
mlog.Error("Encountered error saving tutorial preference", mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -351,12 +351,12 @@ func (a *App) CreateOAuthUser(service string, userData io.Reader, teamId string)
|
||||
suchan := make(chan store.StoreResult, 1)
|
||||
euchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
userByAuth, err := a.Srv.Store.User().GetByAuth(user.AuthData, service)
|
||||
userByAuth, err := a.Srv().Store.User().GetByAuth(user.AuthData, service)
|
||||
suchan <- store.StoreResult{Data: userByAuth, Err: err}
|
||||
close(suchan)
|
||||
}()
|
||||
go func() {
|
||||
userByEmail, err := a.Srv.Store.User().GetByEmail(user.Email)
|
||||
userByEmail, err := a.Srv().Store.User().GetByEmail(user.Email)
|
||||
euchan <- store.StoreResult{Data: userByEmail, Err: err}
|
||||
close(euchan)
|
||||
}()
|
||||
@@ -432,7 +432,7 @@ func (a *App) IsUsernameTaken(name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if _, err := a.Srv.Store.User().GetByUsername(name); err != nil {
|
||||
if _, err := a.Srv().Store.User().GetByUsername(name); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -440,11 +440,11 @@ func (a *App) IsUsernameTaken(name string) bool {
|
||||
}
|
||||
|
||||
func (a *App) GetUser(userId string) (*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().Get(userId)
|
||||
return a.Srv().Store.User().Get(userId)
|
||||
}
|
||||
|
||||
func (a *App) GetUserByUsername(username string) (*model.User, *model.AppError) {
|
||||
result, err := a.Srv.Store.User().GetByUsername(username)
|
||||
result, err := a.Srv().Store.User().GetByUsername(username)
|
||||
if err != nil && err.Id == "store.sql_user.get_by_username.app_error" {
|
||||
err.StatusCode = http.StatusNotFound
|
||||
return nil, err
|
||||
@@ -453,7 +453,7 @@ func (a *App) GetUserByUsername(username string) (*model.User, *model.AppError)
|
||||
}
|
||||
|
||||
func (a *App) GetUserByEmail(email string) (*model.User, *model.AppError) {
|
||||
user, err := a.Srv.Store.User().GetByEmail(email)
|
||||
user, err := a.Srv().Store.User().GetByEmail(email)
|
||||
if err != nil {
|
||||
if err.Id == "store.sql_user.missing_account.const" {
|
||||
err.StatusCode = http.StatusNotFound
|
||||
@@ -466,11 +466,11 @@ func (a *App) GetUserByEmail(email string) (*model.User, *model.AppError) {
|
||||
}
|
||||
|
||||
func (a *App) GetUserByAuth(authData *string, authService string) (*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetByAuth(authData, authService)
|
||||
return a.Srv().Store.User().GetByAuth(authData, authService)
|
||||
}
|
||||
|
||||
func (a *App) GetUsers(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetAllProfiles(options)
|
||||
return a.Srv().Store.User().GetAllProfiles(options)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError) {
|
||||
@@ -483,15 +483,15 @@ func (a *App) GetUsersPage(options *model.UserGetOptions, asAdmin bool) ([]*mode
|
||||
}
|
||||
|
||||
func (a *App) GetUsersEtag(restrictionsHash string) string {
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv.Store.User().GetEtagForAllProfiles(), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv().Store.User().GetEtagForAllProfiles(), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetProfiles(options)
|
||||
return a.Srv().Store.User().GetProfiles(options)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetProfilesNotInTeam(teamId, groupConstrained, offset, limit, viewRestrictions)
|
||||
return a.Srv().Store.User().GetProfilesNotInTeam(teamId, groupConstrained, offset, limit, viewRestrictions)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError) {
|
||||
@@ -513,19 +513,19 @@ func (a *App) GetUsersNotInTeamPage(teamId string, groupConstrained bool, page i
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
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(channelId string, offset int, limit int) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetProfilesInChannel(channelId, offset, limit)
|
||||
return a.Srv().Store.User().GetProfilesInChannel(channelId, offset, limit)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInChannelByStatus(channelId string, offset int, limit int) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetProfilesInChannelByStatus(channelId, offset, limit)
|
||||
return a.Srv().Store.User().GetProfilesInChannelByStatus(channelId, offset, limit)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInChannelMap(channelId string, offset int, limit int, asAdmin bool) (map[string]*model.User, *model.AppError) {
|
||||
@@ -561,7 +561,7 @@ func (a *App) GetUsersInChannelPageByStatus(channelId string, page int, perPage
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
|
||||
return a.Srv().Store.User().GetProfilesNotInChannel(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) {
|
||||
@@ -599,23 +599,23 @@ func (a *App) GetUsersWithoutTeamPage(options *model.UserGetOptions, asAdmin boo
|
||||
}
|
||||
|
||||
func (a *App) GetUsersWithoutTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetProfilesWithoutTeam(options)
|
||||
return a.Srv().Store.User().GetProfilesWithoutTeam(options)
|
||||
}
|
||||
|
||||
// GetTeamGroupUsers returns the users who are associated to the team via GroupTeams and GroupMembers.
|
||||
func (a *App) GetTeamGroupUsers(teamID string) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetTeamGroupUsers(teamID)
|
||||
return a.Srv().Store.User().GetTeamGroupUsers(teamID)
|
||||
}
|
||||
|
||||
// GetChannelGroupUsers returns the users who are associated to the channel via GroupChannels and GroupMembers.
|
||||
func (a *App) GetChannelGroupUsers(channelID string) ([]*model.User, *model.AppError) {
|
||||
return a.Srv.Store.User().GetChannelGroupUsers(channelID)
|
||||
return a.Srv().Store.User().GetChannelGroupUsers(channelID)
|
||||
}
|
||||
|
||||
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, err
|
||||
}
|
||||
@@ -624,7 +624,7 @@ func (a *App) GetUsersByIds(userIds []string, options *store.UserGetByIdsOpts) (
|
||||
}
|
||||
|
||||
func (a *App) GetUsersByGroupChannelIds(channelIds []string, asAdmin bool) (map[string][]*model.User, *model.AppError) {
|
||||
usersByChannelId, err := a.Srv.Store.User().GetProfileByGroupChannelIdsForUser(a.Session.UserId, channelIds)
|
||||
usersByChannelId, err := a.Srv().Store.User().GetProfileByGroupChannelIdsForUser(a.Session().UserId, channelIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -636,7 +636,7 @@ func (a *App) GetUsersByGroupChannelIds(channelIds []string, asAdmin bool) (map[
|
||||
}
|
||||
|
||||
func (a *App) GetUsersByUsernames(usernames []string, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
users, err := a.Srv.Store.User().GetProfilesByUsernames(usernames, viewRestrictions)
|
||||
users, err := a.Srv().Store.User().GetProfilesByUsernames(usernames, viewRestrictions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -657,7 +657,7 @@ func (a *App) GenerateMfaSecret(userId string) (*model.MfaSecret, *model.AppErro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mfaService := mfa.New(a, a.Srv.Store)
|
||||
mfaService := mfa.New(a, a.Srv().Store)
|
||||
secret, img, err := mfaService.GenerateSecret(user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -668,7 +668,7 @@ func (a *App) GenerateMfaSecret(userId string) (*model.MfaSecret, *model.AppErro
|
||||
}
|
||||
|
||||
func (a *App) ActivateMfa(userId, token string) *model.AppError {
|
||||
user, err := a.Srv.Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -677,7 +677,7 @@ func (a *App) ActivateMfa(userId, token string) *model.AppError {
|
||||
return model.NewAppError("ActivateMfa", "api.user.activate_mfa.email_and_ldap_only.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
mfaService := mfa.New(a, a.Srv.Store)
|
||||
mfaService := mfa.New(a, a.Srv().Store)
|
||||
if err := mfaService.Activate(user, token); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -686,7 +686,7 @@ func (a *App) ActivateMfa(userId, token string) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) DeactivateMfa(userId string) *model.AppError {
|
||||
mfaService := mfa.New(a, a.Srv.Store)
|
||||
mfaService := mfa.New(a, a.Srv().Store)
|
||||
if err := mfaService.Deactivate(userId); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -834,7 +834,7 @@ func (a *App) SetDefaultProfileImage(user *model.User) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.User().ResetLastPictureUpdate(user.Id); err != nil {
|
||||
if err := a.Srv().Store.User().ResetLastPictureUpdate(user.Id); err != nil {
|
||||
mlog.Error("Failed to reset last picture update", mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppE
|
||||
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.Error("Error with updating last picture update", mlog.Err(err))
|
||||
}
|
||||
a.invalidateUserCacheAndPublish(userId)
|
||||
@@ -997,7 +997,7 @@ func (a *App) UpdateActive(user *model.User, active bool) (*model.User, *model.A
|
||||
user.DeleteAt = user.UpdateAt
|
||||
}
|
||||
|
||||
userUpdate, err := a.Srv.Store.User().Update(user, true)
|
||||
userUpdate, err := a.Srv().Store.User().Update(user, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1018,7 +1018,7 @@ 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 err
|
||||
}
|
||||
@@ -1029,8 +1029,8 @@ func (a *App) DeactivateGuests() *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
a.Srv.Store.Channel().ClearCaches()
|
||||
a.Srv.Store.User().ClearCaches()
|
||||
a.Srv().Store.Channel().ClearCaches()
|
||||
a.Srv().Store.User().ClearCaches()
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_GUESTS_DEACTIVATED, "", "", "", nil)
|
||||
a.Publish(message)
|
||||
@@ -1093,13 +1093,13 @@ func (a *App) UpdateUserAuth(userId string, userAuth *model.UserAuth) (*model.Us
|
||||
}
|
||||
password := model.HashPassword(userAuth.Password)
|
||||
|
||||
if err := a.Srv.Store.User().UpdatePassword(userId, password); err != nil {
|
||||
if err := a.Srv().Store.User().UpdatePassword(userId, password); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ func (a *App) sendUpdatedUserEvent(user model.User) {
|
||||
}
|
||||
|
||||
func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User, *model.AppError) {
|
||||
prev, err := a.Srv.Store.User().Get(user.Id)
|
||||
prev, err := a.Srv().Store.User().Get(user.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1160,7 +1160,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
}
|
||||
}
|
||||
|
||||
userUpdate, err := a.Srv.Store.User().Update(user, false)
|
||||
userUpdate, err := a.Srv().Store.User().Update(user, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1168,13 +1168,13 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
if sendNotifications {
|
||||
if userUpdate.New.Email != userUpdate.Old.Email || newEmail != "" {
|
||||
if *a.Config().EmailSettings.RequireEmailVerification {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendEmailVerification(userUpdate.New, newEmail); err != nil {
|
||||
mlog.Error("Failed to send email verification", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendEmailChangeEmail(userUpdate.Old.Email, userUpdate.New.Email, userUpdate.New.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send email change email", mlog.Err(err))
|
||||
}
|
||||
@@ -1183,7 +1183,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
}
|
||||
|
||||
if userUpdate.New.Username != userUpdate.Old.Username {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendChangeUsernameEmail(userUpdate.Old.Username, userUpdate.New.Username, userUpdate.New.Email, userUpdate.New.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send change username email", mlog.Err(err))
|
||||
}
|
||||
@@ -1194,7 +1194,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
|
||||
if a.IsESIndexingEnabled() {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.indexUser(user); err != nil {
|
||||
mlog.Error("Encountered error indexing user", mlog.String("user_id", user.Id), mlog.Err(err))
|
||||
}
|
||||
@@ -1244,7 +1244,7 @@ func (a *App) UpdateMfa(activate bool, userId, token string) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
user, err := a.GetUser(userId)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to get user", mlog.Err(err))
|
||||
@@ -1275,7 +1275,7 @@ func (a *App) UpdatePassword(user *model.User, newPassword string) *model.AppErr
|
||||
|
||||
hashedPassword := model.HashPassword(newPassword)
|
||||
|
||||
if err := a.Srv.Store.User().UpdatePassword(user.Id, hashedPassword); err != nil {
|
||||
if err := a.Srv().Store.User().UpdatePassword(user.Id, hashedPassword); err != nil {
|
||||
return model.NewAppError("UpdatePassword", "api.user.update_password.failed.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -1287,7 +1287,7 @@ func (a *App) UpdatePasswordSendEmail(user *model.User, newPassword, method stri
|
||||
return err
|
||||
}
|
||||
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendPasswordChangeEmail(user.Email, method, user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send password change email", mlog.Err(err))
|
||||
}
|
||||
@@ -1376,7 +1376,7 @@ func (a *App) CreatePasswordRecoveryToken(userId, email string) (*model.Token, *
|
||||
|
||||
token := model.NewToken(TOKEN_TYPE_PASSWORD_RECOVERY, string(jsonData))
|
||||
|
||||
if err := a.Srv.Store.Token().Save(token); err != nil {
|
||||
if err := a.Srv().Store.Token().Save(token); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1384,7 +1384,7 @@ func (a *App) CreatePasswordRecoveryToken(userId, email string) (*model.Token, *
|
||||
}
|
||||
|
||||
func (a *App) GetPasswordRecoveryToken(token string) (*model.Token, *model.AppError) {
|
||||
rtoken, err := a.Srv.Store.Token().GetByToken(token)
|
||||
rtoken, err := a.Srv().Store.Token().GetByToken(token)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPasswordRecoveryToken", "api.user.reset_password.invalid_link.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -1395,7 +1395,7 @@ func (a *App) GetPasswordRecoveryToken(token string) (*model.Token, *model.AppEr
|
||||
}
|
||||
|
||||
func (a *App) DeleteToken(token *model.Token) *model.AppError {
|
||||
return a.Srv.Store.Token().Delete(token.Token)
|
||||
return a.Srv().Store.Token().Delete(token.Token)
|
||||
}
|
||||
|
||||
func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError) {
|
||||
@@ -1412,14 +1412,14 @@ func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent
|
||||
user.Roles = newRoles
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
userUpdate, err := a.Srv.Store.User().Update(user, true)
|
||||
userUpdate, err := a.Srv().Store.User().Update(user, true)
|
||||
uchan <- store.StoreResult{Data: userUpdate, Err: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
schan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
userId, err := a.Srv.Store.Session().UpdateRoles(user.Id, newRoles)
|
||||
userId, err := a.Srv().Store.Session().UpdateRoles(user.Id, newRoles)
|
||||
schan <- store.StoreResult{Data: userId, Err: err}
|
||||
close(schan)
|
||||
}()
|
||||
@@ -1458,51 +1458,51 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Session().PermanentDeleteSessionsByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Session().PermanentDeleteSessionsByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.UserAccessToken().DeleteAllForUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.UserAccessToken().DeleteAllForUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.OAuth().PermanentDeleteAuthDataByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.OAuth().PermanentDeleteAuthDataByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Webhook().PermanentDeleteIncomingByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Webhook().PermanentDeleteIncomingByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Webhook().PermanentDeleteOutgoingByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Webhook().PermanentDeleteOutgoingByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Command().PermanentDeleteByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Command().PermanentDeleteByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Preference().PermanentDeleteByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Preference().PermanentDeleteByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Channel().PermanentDeleteMembersByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Channel().PermanentDeleteMembersByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Group().PermanentDeleteMembersByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Group().PermanentDeleteMembersByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Post().PermanentDeleteByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Post().PermanentDeleteByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Bot().PermanentDelete(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Bot().PermanentDelete(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
infos, err := a.Srv.Store.FileInfo().GetForUser(user.Id)
|
||||
infos, err := a.Srv().Store.FileInfo().GetForUser(user.Id)
|
||||
if err != nil {
|
||||
mlog.Warn("Error getting file list for user from FileInfoStore", mlog.Err(err))
|
||||
}
|
||||
@@ -1534,27 +1534,27 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := a.Srv.Store.FileInfo().PermanentDeleteByUser(user.Id); err != nil {
|
||||
if _, err := a.Srv().Store.FileInfo().PermanentDeleteByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.User().PermanentDelete(user.Id); err != nil {
|
||||
if err := a.Srv().Store.User().PermanentDelete(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Audit().PermanentDeleteByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Audit().PermanentDeleteByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Team().RemoveAllMembersByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store.Team().RemoveAllMembersByUser(user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Warn("Permanently deleted account", mlog.String("user_email", user.Email), mlog.String("user_id", user.Id))
|
||||
|
||||
if a.IsESIndexingEnabled() {
|
||||
a.Srv.Go(func() {
|
||||
if err := a.Elasticsearch.DeleteUser(user); err != nil {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.Elasticsearch().DeleteUser(user); err != nil {
|
||||
mlog.Error("Encountered error deleting user", mlog.String("user_id", user.Id), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -1564,7 +1564,7 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) PermanentDeleteAllUsers() *model.AppError {
|
||||
users, err := a.Srv.Store.User().GetAll()
|
||||
users, err := a.Srv().Store.User().GetAll()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1617,7 +1617,7 @@ func (a *App) VerifyEmailFromToken(userSuppliedTokenString string) *model.AppErr
|
||||
}
|
||||
|
||||
if user.Email != tokenData.Email {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendEmailChangeEmail(user.Email, tokenData.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send email change email", mlog.Err(err))
|
||||
}
|
||||
@@ -1647,7 +1647,7 @@ func (a *App) CreateVerifyEmailToken(userId string, newEmail string) (*model.Tok
|
||||
|
||||
token := model.NewToken(TOKEN_TYPE_VERIFY_EMAIL, string(jsonData))
|
||||
|
||||
if err := a.Srv.Store.Token().Save(token); err != nil {
|
||||
if err := a.Srv().Store.Token().Save(token); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1655,7 +1655,7 @@ func (a *App) CreateVerifyEmailToken(userId string, newEmail string) (*model.Tok
|
||||
}
|
||||
|
||||
func (a *App) GetVerifyEmailToken(token string) (*model.Token, *model.AppError) {
|
||||
rtoken, err := a.Srv.Store.Token().GetByToken(token)
|
||||
rtoken, err := a.Srv().Store.Token().GetByToken(token)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetVerifyEmailToken", "api.user.verify_email.bad_link.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
@@ -1667,7 +1667,7 @@ func (a *App) GetVerifyEmailToken(token string) (*model.Token, *model.AppError)
|
||||
|
||||
// GetTotalUsersStats is used for the DM list total
|
||||
func (a *App) GetTotalUsersStats(viewRestrictions *model.ViewUsersRestrictions) (*model.UsersStats, *model.AppError) {
|
||||
count, err := a.Srv.Store.User().Count(model.UserCountOptions{
|
||||
count, err := a.Srv().Store.User().Count(model.UserCountOptions{
|
||||
IncludeBotAccounts: true,
|
||||
ViewRestrictions: viewRestrictions,
|
||||
})
|
||||
@@ -1681,7 +1681,7 @@ func (a *App) GetTotalUsersStats(viewRestrictions *model.ViewUsersRestrictions)
|
||||
}
|
||||
|
||||
func (a *App) VerifyUserEmail(userId, email string) *model.AppError {
|
||||
_, err := a.Srv.Store.User().VerifyEmail(userId, email)
|
||||
_, err := a.Srv().Store.User().VerifyEmail(userId, email)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1715,7 +1715,7 @@ func (a *App) SearchUsers(props *model.UserSearch, options *model.UserSearchOpti
|
||||
|
||||
func (a *App) SearchUsersInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv.Store.User().SearchInChannel(channelId, term, options)
|
||||
users, err := a.Srv().Store.User().SearchInChannel(channelId, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1728,7 +1728,7 @@ func (a *App) SearchUsersInChannel(channelId string, term string, options *model
|
||||
|
||||
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, err
|
||||
}
|
||||
@@ -1741,7 +1741,7 @@ func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term stri
|
||||
}
|
||||
|
||||
func (a *App) esSearchUsersInTeam(teamId, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
listOfAllowedChannels, err := a.GetViewUsersRestrictionsForTeam(a.Session.UserId, teamId)
|
||||
listOfAllowedChannels, err := a.GetViewUsersRestrictionsForTeam(a.Session().UserId, teamId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1749,12 +1749,12 @@ func (a *App) esSearchUsersInTeam(teamId, term string, options *model.UserSearch
|
||||
return []*model.User{}, nil
|
||||
}
|
||||
|
||||
usersIds, err := a.Elasticsearch.SearchUsersInTeam(teamId, listOfAllowedChannels, term, options)
|
||||
usersIds, err := a.Elasticsearch().SearchUsersInTeam(teamId, listOfAllowedChannels, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users, err := a.Srv.Store.User().GetProfileByIds(usersIds, nil, false)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(usersIds, nil, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1779,7 +1779,7 @@ func (a *App) SearchUsersInTeam(teamId, term string, options *model.UserSearchOp
|
||||
}
|
||||
|
||||
if !a.IsESAutocompletionEnabled() || err != nil {
|
||||
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, err
|
||||
}
|
||||
@@ -1794,7 +1794,7 @@ func (a *App) SearchUsersInTeam(teamId, term string, options *model.UserSearchOp
|
||||
|
||||
func (a *App) SearchUsersNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv.Store.User().SearchNotInTeam(notInTeamId, term, options)
|
||||
users, err := a.Srv().Store.User().SearchNotInTeam(notInTeamId, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1808,7 +1808,7 @@ func (a *App) SearchUsersNotInTeam(notInTeamId string, term string, options *mod
|
||||
|
||||
func (a *App) SearchUsersWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv.Store.User().SearchWithoutTeam(term, options)
|
||||
users, err := a.Srv().Store.User().SearchWithoutTeam(term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1831,9 +1831,9 @@ func (a *App) esAutocompleteUsersInChannel(teamId, channelId, term string, optio
|
||||
uchanIds := []string{}
|
||||
nuchanIds := []string{}
|
||||
if !strings.Contains(strings.Join(listOfAllowedChannels, "."), channelId) {
|
||||
nuchanIds, err = a.Elasticsearch.SearchUsersInTeam(teamId, listOfAllowedChannels, term, options)
|
||||
nuchanIds, err = a.Elasticsearch().SearchUsersInTeam(teamId, listOfAllowedChannels, term, options)
|
||||
} else {
|
||||
uchanIds, nuchanIds, err = a.Elasticsearch.SearchUsersInChannel(teamId, channelId, listOfAllowedChannels, term, options)
|
||||
uchanIds, nuchanIds, err = a.Elasticsearch().SearchUsersInChannel(teamId, channelId, listOfAllowedChannels, term, options)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1841,14 +1841,14 @@ func (a *App) esAutocompleteUsersInChannel(teamId, channelId, term string, optio
|
||||
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
users, err := a.Srv.Store.User().GetProfileByIds(uchanIds, nil, false)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(uchanIds, nil, false)
|
||||
uchan <- store.StoreResult{Data: users, Err: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
nuchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
users, err := a.Srv.Store.User().GetProfileByIds(nuchanIds, nil, false)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(nuchanIds, nil, false)
|
||||
nuchan <- store.StoreResult{Data: users, Err: err}
|
||||
close(nuchan)
|
||||
}()
|
||||
@@ -1899,14 +1899,14 @@ func (a *App) AutocompleteUsersInChannel(teamId string, channelId string, term s
|
||||
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
users, err := a.Srv.Store.User().SearchInChannel(channelId, term, options)
|
||||
users, err := a.Srv().Store.User().SearchInChannel(channelId, term, options)
|
||||
uchan <- store.StoreResult{Data: users, Err: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
nuchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
users, err := a.Srv.Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
||||
users, err := a.Srv().Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
||||
nuchan <- store.StoreResult{Data: users, Err: err}
|
||||
close(nuchan)
|
||||
}()
|
||||
@@ -1949,12 +1949,12 @@ func (a *App) esAutocompleteUsersInTeam(teamId, term string, options *model.User
|
||||
return &model.UserAutocompleteInTeam{}, nil
|
||||
}
|
||||
|
||||
usersIds, err := a.Elasticsearch.SearchUsersInTeam(teamId, listOfAllowedChannels, term, options)
|
||||
usersIds, err := a.Elasticsearch().SearchUsersInTeam(teamId, listOfAllowedChannels, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users, err := a.Srv.Store.User().GetProfileByIds(usersIds, nil, false)
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(usersIds, nil, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1984,7 +1984,7 @@ func (a *App) AutocompleteUsersInTeam(teamId string, term string, options *model
|
||||
|
||||
if !a.IsESAutocompletionEnabled() || err != nil {
|
||||
autocomplete = &model.UserAutocompleteInTeam{}
|
||||
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, err
|
||||
}
|
||||
@@ -2034,7 +2034,7 @@ func (a *App) UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provide
|
||||
}
|
||||
|
||||
if userAttrsChanged {
|
||||
users, err := a.Srv.Store.User().Update(user, true)
|
||||
users, err := a.Srv().Store.User().Update(user, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2043,7 +2043,7 @@ func (a *App) UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provide
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
|
||||
if a.IsESIndexingEnabled() {
|
||||
a.Srv.Go(func() {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.indexUser(user); err != nil {
|
||||
mlog.Error("Encountered error indexing user", mlog.String("user_id", user.Id), mlog.Err(err))
|
||||
}
|
||||
@@ -2088,7 +2088,7 @@ func (a *App) FilterNonGroupChannelMembers(userIds []string, channel *model.Chan
|
||||
// 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
|
||||
}
|
||||
@@ -2135,7 +2135,7 @@ func (a *App) UserCanSeeOtherUser(userId string, otherUserId string) (bool, *mod
|
||||
}
|
||||
|
||||
if len(restrictions.Teams) > 0 {
|
||||
result, err := a.Srv.Store.Team().UserBelongsToTeams(otherUserId, restrictions.Teams)
|
||||
result, err := a.Srv().Store.Team().UserBelongsToTeams(otherUserId, restrictions.Teams)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -2158,7 +2158,7 @@ func (a *App) UserCanSeeOtherUser(userId string, otherUserId string) (bool, *mod
|
||||
}
|
||||
|
||||
func (a *App) userBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
|
||||
return a.Srv.Store.Channel().UserBelongsToChannels(userId, channelIds)
|
||||
return a.Srv().Store.Channel().UserBelongsToChannels(userId, channelIds)
|
||||
}
|
||||
|
||||
func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError) {
|
||||
@@ -2166,7 +2166,7 @@ func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestricti
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
teamIds, getTeamErr := a.Srv.Store.Team().GetUserTeamIds(userId, true)
|
||||
teamIds, getTeamErr := a.Srv().Store.Team().GetUserTeamIds(userId, true)
|
||||
if getTeamErr != nil {
|
||||
return nil, getTeamErr
|
||||
}
|
||||
@@ -2178,7 +2178,7 @@ func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestricti
|
||||
}
|
||||
}
|
||||
|
||||
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, err
|
||||
}
|
||||
@@ -2205,7 +2205,7 @@ func (a *App) GetViewUsersRestrictionsForTeam(userId string, teamId string) ([]s
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
members, err := a.Srv.Store.Channel().GetMembersForUser(teamId, userId)
|
||||
members, err := a.Srv().Store.Channel().GetMembersForUser(teamId, userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2221,7 +2221,7 @@ func (a *App) GetViewUsersRestrictionsForTeam(userId string, teamId string) ([]s
|
||||
func (a *App) getListOfAllowedChannelsForTeam(teamId string, viewRestrictions *model.ViewUsersRestrictions) ([]string, *model.AppError) {
|
||||
var listOfAllowedChannels []string
|
||||
if viewRestrictions == nil || strings.Contains(strings.Join(viewRestrictions.Teams, "."), teamId) {
|
||||
channels, err := a.Srv.Store.Channel().GetTeamChannels(teamId)
|
||||
channels, err := a.Srv().Store.Channel().GetTeamChannels(teamId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2233,7 +2233,7 @@ func (a *App) getListOfAllowedChannelsForTeam(teamId string, viewRestrictions *m
|
||||
return channelIds, nil
|
||||
}
|
||||
|
||||
channels, err := a.Srv.Store.Channel().GetChannelsByIds(viewRestrictions.Channels)
|
||||
channels, err := a.Srv().Store.Channel().GetChannelsByIds(viewRestrictions.Channels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2249,12 +2249,12 @@ func (a *App) getListOfAllowedChannelsForTeam(teamId string, viewRestrictions *m
|
||||
// PromoteGuestToUser Convert user's roles and all his mermbership's roles from
|
||||
// guest roles to regular user roles.
|
||||
func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.AppError {
|
||||
err := a.Srv.Store.User().PromoteGuestToUser(user.Id)
|
||||
err := a.Srv().Store.User().PromoteGuestToUser(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userTeams, err := a.Srv.Store.Team().GetTeamsByUserId(user.Id)
|
||||
userTeams, err := a.Srv().Store.Team().GetTeamsByUserId(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2303,7 +2303,7 @@ func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.Ap
|
||||
// DemoteUserToGuest Convert user's roles and all his mermbership's roles from
|
||||
// regular user roles to guest roles.
|
||||
func (a *App) DemoteUserToGuest(user *model.User) *model.AppError {
|
||||
err := a.Srv.Store.User().DemoteUserToGuest(user.Id)
|
||||
err := a.Srv().Store.User().DemoteUserToGuest(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Ссылка в новой задаче
Block a user