UserStore migration (#15563)
* Migration completed * Fix tests * Fix tests * Fix tests * Suggestions * Trigger CI * Suggestions * Merge with master * Trigger CI Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d51d843fcd
Коммит
96f1739f8f
@@ -44,13 +44,13 @@ func TestCreateUser(t *testing.T) {
|
||||
ruser.Username = GenerateTestUsername()
|
||||
ruser.Password = "passwd1"
|
||||
_, resp = th.Client.CreateUser(ruser)
|
||||
CheckErrorMessage(t, resp, "store.sql_user.save.email_exists.app_error")
|
||||
CheckErrorMessage(t, resp, "app.user.save.existing.app_error")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
ruser.Email = th.GenerateTestEmail()
|
||||
ruser.Username = user.Username
|
||||
_, resp = th.Client.CreateUser(ruser)
|
||||
CheckErrorMessage(t, resp, "store.sql_user.save.username_exists.app_error")
|
||||
CheckErrorMessage(t, resp, "app.user.save.existing.app_error")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
ruser.Email = ""
|
||||
@@ -1996,8 +1996,8 @@ func TestPermanentDeleteAllUsers(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
// Check that we have users and posts in the database
|
||||
users, err := th.App.Srv().Store.User().GetAll()
|
||||
require.Nil(t, err)
|
||||
users, nErr := th.App.Srv().Store.User().GetAll()
|
||||
require.Nil(t, nErr)
|
||||
require.Greater(t, len(users), 0)
|
||||
|
||||
postCount, nErr := th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
@@ -2009,8 +2009,8 @@ func TestPermanentDeleteAllUsers(t *testing.T) {
|
||||
require.Nil(t, resp.Error)
|
||||
|
||||
// Check that both user and post tables are empty
|
||||
users, err = th.App.Srv().Store.User().GetAll()
|
||||
require.Nil(t, err)
|
||||
users, nErr = th.App.Srv().Store.User().GetAll()
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, users, 0)
|
||||
|
||||
postCount, nErr = th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
@@ -2673,14 +2673,14 @@ func TestUserLoginMFAFlow(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Fake user has MFA enabled
|
||||
err = th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
|
||||
require.Nil(t, err)
|
||||
nErr := th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
err = th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
|
||||
require.Nil(t, err)
|
||||
nErr = th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
err = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
|
||||
require.Nil(t, err)
|
||||
nErr = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
user, resp := th.Client.Login(th.BasicUser.Email, th.BasicUser.Password)
|
||||
CheckErrorMessage(t, resp, "mfa.validate_token.authenticate.app_error")
|
||||
@@ -2706,11 +2706,11 @@ func TestUserLoginMFAFlow(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Fake user has MFA enabled
|
||||
err = th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
|
||||
require.Nil(t, err)
|
||||
nErr := th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
err = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
|
||||
require.Nil(t, err)
|
||||
nErr = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
code := dgoogauth.ComputeCode(secret.Secret, time.Now().UTC().Unix()/30)
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestApiResctrictedViewMembers(t *testing.T) {
|
||||
"Get not existing user without restrictions",
|
||||
"",
|
||||
model.NewId(),
|
||||
"store.sql_user.missing_account.const",
|
||||
"app.user.missing_account.const",
|
||||
},
|
||||
{
|
||||
"Get not existing user with restrictions to teams",
|
||||
@@ -161,7 +161,7 @@ func TestApiResctrictedViewMembers(t *testing.T) {
|
||||
"Get not existing user without restrictions",
|
||||
"",
|
||||
model.NewId(),
|
||||
"store.sql_user.get_by_username.app_error",
|
||||
"app.user.get_by_username.app_error",
|
||||
},
|
||||
{
|
||||
"Get not existing user with restrictions to teams",
|
||||
@@ -243,7 +243,7 @@ func TestApiResctrictedViewMembers(t *testing.T) {
|
||||
"Get not existing user without restrictions",
|
||||
"",
|
||||
th.GenerateTestEmail(),
|
||||
"store.sql_user.missing_account.const",
|
||||
"app.user.missing_account.const",
|
||||
},
|
||||
{
|
||||
"Get not existing user with restrictions to teams",
|
||||
@@ -325,7 +325,7 @@ func TestApiResctrictedViewMembers(t *testing.T) {
|
||||
"Get not existing user without restrictions",
|
||||
"",
|
||||
model.NewId(),
|
||||
"store.sql_user.missing_account.const",
|
||||
"app.user.missing_account.const",
|
||||
},
|
||||
{
|
||||
"Get not existing user with restrictions to teams",
|
||||
@@ -407,7 +407,7 @@ func TestApiResctrictedViewMembers(t *testing.T) {
|
||||
"Get not existing user without restrictions",
|
||||
"",
|
||||
model.NewId(),
|
||||
"store.sql_user.missing_account.const",
|
||||
"app.user.missing_account.const",
|
||||
},
|
||||
{
|
||||
"Get not existing user with restrictions to teams",
|
||||
|
||||
@@ -264,14 +264,14 @@ func TestWebSocketStatuses(t *testing.T) {
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser := Client.Must(Client.CreateUser(&user)).(*model.User)
|
||||
th.LinkUserToTeam(ruser, rteam)
|
||||
_, err = th.App.Srv().Store.User().VerifyEmail(ruser.Id, ruser.Email)
|
||||
require.Nil(t, err)
|
||||
_, nErr := th.App.Srv().Store.User().VerifyEmail(ruser.Id, ruser.Email)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser2 := Client.Must(Client.CreateUser(&user2)).(*model.User)
|
||||
th.LinkUserToTeam(ruser2, rteam)
|
||||
_, err = th.App.Srv().Store.User().VerifyEmail(ruser2.Id, ruser2.Email)
|
||||
require.Nil(t, err)
|
||||
_, nErr = th.App.Srv().Store.User().VerifyEmail(ruser2.Id, ruser2.Email)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
var systemUserCount int64
|
||||
systemUserCount, err := a.Srv().Store.User().Count(model.UserCountOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetAnalytics", "app.user.get_total_users_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if systemUserCount > int64(*a.Config().AnalyticsSettings.MaxUsersForStatistics) {
|
||||
@@ -62,14 +62,14 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
userInactiveChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.User().AnalyticsGetInactiveUsersCount()
|
||||
userInactiveChan <- store.StoreResult{Data: count, Err: err2}
|
||||
userInactiveChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(userInactiveChan)
|
||||
}()
|
||||
} else {
|
||||
userChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.User().Count(model.UserCountOptions{TeamId: teamId})
|
||||
userChan <- store.StoreResult{Data: count, Err: err2}
|
||||
userChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(userChan)
|
||||
}()
|
||||
}
|
||||
@@ -94,14 +94,14 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
dailyActiveChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
dailyActive, err2 := a.Srv().Store.User().AnalyticsActiveCount(DAY_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
dailyActiveChan <- store.StoreResult{Data: dailyActive, Err: err2}
|
||||
dailyActiveChan <- store.StoreResult{Data: dailyActive, NErr: err2}
|
||||
close(dailyActiveChan)
|
||||
}()
|
||||
|
||||
monthlyActiveChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
monthlyActive, err2 := a.Srv().Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
monthlyActiveChan <- store.StoreResult{Data: monthlyActive, Err: err2}
|
||||
monthlyActiveChan <- store.StoreResult{Data: monthlyActive, NErr: err2}
|
||||
close(monthlyActiveChan)
|
||||
}()
|
||||
|
||||
@@ -131,8 +131,8 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows[3].Value = float64(systemUserCount)
|
||||
} else {
|
||||
r = <-userChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.user.get_total_users_count.app_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[3].Value = float64(r.Data.(int64))
|
||||
}
|
||||
@@ -141,8 +141,8 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows[10].Value = -1
|
||||
} else {
|
||||
r = <-userInactiveChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.user.analytics_get_inactive_users_count.app_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[10].Value = float64(r.Data.(int64))
|
||||
}
|
||||
@@ -181,14 +181,14 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
}
|
||||
|
||||
r = <-dailyActiveChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.user.analytics_daily_active_users.app_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[8].Value = float64(r.Data.(int64))
|
||||
|
||||
r = <-monthlyActiveChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.user.analytics_daily_active_users.app_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[9].Value = float64(r.Data.(int64))
|
||||
|
||||
@@ -325,7 +325,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
|
||||
r = <-commandChan
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.analytics.getanalytics.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("GetAnalytics", "app.analytics.getanalytics.internal_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[4].Value = float64(r.Data.(int64))
|
||||
|
||||
@@ -344,7 +344,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
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, err
|
||||
return nil, model.NewAppError("GetRecentlyActiveUsersForTeam", "app.user.get_recently_active_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
userMap := make(map[string]*model.User)
|
||||
@@ -359,7 +359,7 @@ func (a *App) GetRecentlyActiveUsersForTeam(teamId string) (map[string]*model.Us
|
||||
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, err
|
||||
return nil, model.NewAppError("GetRecentlyActiveUsersForTeamPage", "app.user.get_recently_active_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return a.sanitizeProfiles(users, asAdmin), nil
|
||||
@@ -368,7 +368,7 @@ func (a *App) GetRecentlyActiveUsersForTeamPage(teamId string, page, perPage int
|
||||
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, err
|
||||
return nil, model.NewAppError("GetNewUsersForTeamPage", "app.user.get_new_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return a.sanitizeProfiles(users, asAdmin), nil
|
||||
|
||||
@@ -52,7 +52,7 @@ func (a *App) CheckPasswordAndAllCriteria(user *model.User, password string, mfa
|
||||
|
||||
if err := a.checkUserPassword(user, password); err != nil {
|
||||
if passErr := a.Srv().Store.User().UpdateFailedPasswordAttempts(user.Id, user.FailedAttempts+1); passErr != nil {
|
||||
return passErr
|
||||
return model.NewAppError("CheckPasswordAndAllCriteria", "app.user.update_failed_pwd_attempts.app_error", nil, passErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
@@ -65,7 +65,7 @@ func (a *App) CheckPasswordAndAllCriteria(user *model.User, password string, mfa
|
||||
// about the MFA state of the user in question
|
||||
if mfaToken != "" {
|
||||
if passErr := a.Srv().Store.User().UpdateFailedPasswordAttempts(user.Id, user.FailedAttempts+1); passErr != nil {
|
||||
return passErr
|
||||
return model.NewAppError("CheckPasswordAndAllCriteria", "app.user.update_failed_pwd_attempts.app_error", nil, passErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ func (a *App) CheckPasswordAndAllCriteria(user *model.User, password string, mfa
|
||||
}
|
||||
|
||||
if passErr := a.Srv().Store.User().UpdateFailedPasswordAttempts(user.Id, 0); passErr != nil {
|
||||
return passErr
|
||||
return model.NewAppError("CheckPasswordAndAllCriteria", "app.user.update_failed_pwd_attempts.app_error", nil, passErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
@@ -95,7 +95,7 @@ func (a *App) DoubleCheckPassword(user *model.User, password string) *model.AppE
|
||||
|
||||
if err := a.checkUserPassword(user, password); err != nil {
|
||||
if passErr := a.Srv().Store.User().UpdateFailedPasswordAttempts(user.Id, user.FailedAttempts+1); passErr != nil {
|
||||
return passErr
|
||||
return model.NewAppError("DoubleCheckPassword", "app.user.update_failed_pwd_attempts.app_error", nil, passErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
@@ -104,7 +104,7 @@ func (a *App) DoubleCheckPassword(user *model.User, password string) *model.AppE
|
||||
}
|
||||
|
||||
if passErr := a.Srv().Store.User().UpdateFailedPasswordAttempts(user.Id, 0); passErr != nil {
|
||||
return passErr
|
||||
return model.NewAppError("DoubleCheckPassword", "app.user.update_failed_pwd_attempts.app_error", nil, passErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
|
||||
86
app/bot.go
86
app/bot.go
@@ -18,9 +18,18 @@ import (
|
||||
|
||||
// CreateBot creates the given bot and corresponding user.
|
||||
func (a *App) CreateBot(bot *model.Bot) (*model.Bot, *model.AppError) {
|
||||
user, err := a.Srv().Store.User().Save(model.UserFromBot(bot))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Save(model.UserFromBot(bot))
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(nErr, &appErr):
|
||||
return nil, appErr
|
||||
case errors.As(nErr, &invErr):
|
||||
return nil, model.NewAppError("CreateBot", "app.user.save.existing.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("CreateBot", "app.user.save.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
bot.UserId = user.Id
|
||||
|
||||
@@ -38,9 +47,10 @@ func (a *App) CreateBot(bot *model.Bot) (*model.Bot, *model.AppError) {
|
||||
|
||||
// Get the owner of the bot, if one exists. If not, don't send a message
|
||||
ownerUser, err := a.Srv().Store.User().Get(bot.OwnerId)
|
||||
if err != nil && err.Id != store.MISSING_ACCOUNT_ERROR {
|
||||
var nfErr *store.ErrNotFound
|
||||
if err != nil && !errors.As(err, &nfErr) {
|
||||
mlog.Error(err.Error())
|
||||
return nil, err
|
||||
return nil, model.NewAppError("CreateBot", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
} else if ownerUser != nil {
|
||||
// Send a message to the bot's creator to inform them that the bot needs to be added
|
||||
// to a team and channel after it's created
|
||||
@@ -74,10 +84,19 @@ func (a *App) getOrCreateWarnMetricsBot(botDef *model.Bot) (*model.Bot, *model.A
|
||||
}
|
||||
|
||||
// cannot find this bot user, save the user
|
||||
user, err := a.Srv().Store.User().Save(model.UserFromBot(botDef))
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Save(model.UserFromBot(botDef))
|
||||
if nErr != nil {
|
||||
mlog.Error(nErr.Error())
|
||||
var appError *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(nErr, &appError):
|
||||
return nil, appError
|
||||
case errors.As(nErr, &invErr):
|
||||
return nil, model.NewAppError("getOrCreateWarnMetricsBot", "app.user.save.existing.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("getOrCreateWarnMetricsBot", "app.user.save.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
botDef.UserId = user.Id
|
||||
|
||||
@@ -119,9 +138,15 @@ func (a *App) PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot,
|
||||
|
||||
bot.Patch(botPatch)
|
||||
|
||||
user, err := a.Srv().Store.User().Get(botUserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(botUserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("PatchBot", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("PatchBot", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
patchedUser := model.UserFromBot(bot)
|
||||
@@ -130,16 +155,25 @@ func (a *App) PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot,
|
||||
user.Email = patchedUser.Email
|
||||
user.FirstName = patchedUser.FirstName
|
||||
|
||||
userUpdate, err := a.Srv().Store.User().Update(user, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
userUpdate, nErr := a.Srv().Store.User().Update(user, true)
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(nErr, &appErr):
|
||||
return nil, appErr
|
||||
case errors.As(nErr, &invErr):
|
||||
return nil, model.NewAppError("PatchBot", "app.user.update.find.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("PatchBot", "app.user.update.finding.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
|
||||
ruser := userUpdate.New
|
||||
a.sendUpdatedUserEvent(*ruser)
|
||||
|
||||
bot, nErr := a.Srv().Store.Bot().Update(bot)
|
||||
bot, nErr = a.Srv().Store.Bot().Update(bot)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
var appErr *model.AppError
|
||||
@@ -181,12 +215,18 @@ func (a *App) GetBots(options *model.BotGetOptions) (model.BotList, *model.AppEr
|
||||
|
||||
// UpdateBotActive marks a bot as active or inactive, along with its corresponding user.
|
||||
func (a *App) UpdateBotActive(botUserId string, active bool) (*model.Bot, *model.AppError) {
|
||||
user, err := a.Srv().Store.User().Get(botUserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(botUserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("PatchBot", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("PatchBot", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if _, err = a.UpdateActive(user, active); err != nil {
|
||||
if _, err := a.UpdateActive(user, active); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -242,7 +282,7 @@ func (a *App) PermanentDeleteBot(botUserId string) *model.AppError {
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.User().PermanentDelete(botUserId); err != nil {
|
||||
return err
|
||||
return model.NewAppError("PermanentDeleteBot", "app.user.permanent_delete.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -499,8 +539,8 @@ func (a *App) DeleteBotIconImage(botUserId string) *model.AppError {
|
||||
return model.NewAppError("DeleteBotIconImage", "api.bot.delete_bot_icon_image.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if err = a.Srv().Store.User().UpdateLastPictureUpdate(botUserId); err != nil {
|
||||
mlog.Error(err.Error())
|
||||
if nErr := a.Srv().Store.User().UpdateLastPictureUpdate(botUserId); nErr != nil {
|
||||
mlog.Error(nErr.Error())
|
||||
}
|
||||
|
||||
bot.LastIconUpdate = int64(0)
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestCreateBot(t *testing.T) {
|
||||
OwnerId: th.BasicUser.Id,
|
||||
})
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, "store.sql_user.save.username_exists.app_error", err.Id)
|
||||
require.Equal(t, "app.user.save.existing.app_error", err.Id)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ func TestPatchBot(t *testing.T) {
|
||||
|
||||
_, err = th.App.PatchBot(bot.UserId, botPatch)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, "store.sql_user.update.username_taken.app_error", err.Id)
|
||||
require.Equal(t, "app.user.update.find.app_error", err.Id)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ func TestUpdateBotActive(t *testing.T) {
|
||||
|
||||
_, err := th.App.UpdateBotActive(model.NewId(), false)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, "store.sql_user.missing_account.const", err.Id)
|
||||
require.Equal(t, "app.user.missing_account.const", err.Id)
|
||||
})
|
||||
|
||||
t.Run("disable/enable bot", func(t *testing.T) {
|
||||
|
||||
107
app/channel.go
107
app/channel.go
@@ -65,16 +65,21 @@ func (a *App) DefaultChannelNames() []string {
|
||||
|
||||
func (a *App) JoinDefaultChannels(teamId string, user *model.User, shouldBeAdmin bool, userRequestorId string) *model.AppError {
|
||||
var requestor *model.User
|
||||
var nErr error
|
||||
if userRequestorId != "" {
|
||||
var err *model.AppError
|
||||
requestor, err = a.Srv().Store.User().Get(userRequestorId)
|
||||
if err != nil {
|
||||
return err
|
||||
requestor, nErr = a.Srv().Store.User().Get(userRequestorId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return model.NewAppError("JoinDefaultChannels", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("JoinDefaultChannels", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var err *model.AppError
|
||||
var nErr error
|
||||
for _, channelName := range a.DefaultChannelNames() {
|
||||
channel, channelErr := a.Srv().Store.Channel().GetByName(teamId, channelName, true)
|
||||
if channelErr != nil {
|
||||
@@ -256,9 +261,15 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
|
||||
}
|
||||
|
||||
if addMember {
|
||||
user, err := a.Srv().Store.User().Get(channel.CreatorId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(channel.CreatorId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("CreateChannel", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("CreateChannel", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
cm := &model.ChannelMember{
|
||||
@@ -352,23 +363,23 @@ func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Cha
|
||||
uc2 := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
uc1 <- store.StoreResult{Data: user, Err: err}
|
||||
uc1 <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uc1)
|
||||
}()
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(otherUserId)
|
||||
uc2 <- store.StoreResult{Data: user, Err: err}
|
||||
uc2 <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uc2)
|
||||
}()
|
||||
|
||||
result := <-uc1
|
||||
if result.Err != nil {
|
||||
if result.NErr != nil {
|
||||
return nil, model.NewAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, userId, http.StatusBadRequest)
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
result = <-uc2
|
||||
if result.Err != nil {
|
||||
if result.NErr != nil {
|
||||
return nil, model.NewAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, otherUserId, http.StatusBadRequest)
|
||||
}
|
||||
otherUser := result.Data.(*model.User)
|
||||
@@ -478,7 +489,7 @@ func (a *App) createGroupChannel(userIds []string, creatorId string) (*model.Cha
|
||||
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIds, nil, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("createGroupChannel", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if len(users) != len(userIds) {
|
||||
@@ -558,16 +569,16 @@ func (a *App) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError
|
||||
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIds, nil, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
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)
|
||||
}
|
||||
|
||||
channel, err := a.GetChannelByName(model.GetGroupNameFromUserIds(userIds), "", true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
channel, appErr := a.GetChannelByName(model.GetGroupNameFromUserIds(userIds), "", true)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
return channel, nil
|
||||
@@ -702,9 +713,15 @@ func (a *App) RestoreChannel(channel *model.Channel, userId string) (*model.Chan
|
||||
message.Add("channel_id", channel.Id)
|
||||
a.Publish(message)
|
||||
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(userId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("RestoreChannel", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("RestoreChannel", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if user != nil {
|
||||
@@ -1209,10 +1226,16 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
||||
|
||||
var user *model.User
|
||||
if userId != "" {
|
||||
var err *model.AppError
|
||||
user, err = a.Srv().Store.User().Get(userId)
|
||||
if err != nil {
|
||||
return err
|
||||
var nErr error
|
||||
user, nErr = a.Srv().Store.User().Get(userId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return model.NewAppError("DeleteChannel", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("DeleteChannel", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1876,7 +1899,7 @@ func (a *App) JoinChannel(channel *model.Channel, userId string) *model.AppError
|
||||
memberChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
userChan <- store.StoreResult{Data: user, Err: err}
|
||||
userChan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(userChan)
|
||||
}()
|
||||
go func() {
|
||||
@@ -1886,8 +1909,14 @@ func (a *App) JoinChannel(channel *model.Channel, userId string) *model.AppError
|
||||
}()
|
||||
|
||||
uresult := <-userChan
|
||||
if uresult.Err != nil {
|
||||
return uresult.Err
|
||||
if uresult.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(uresult.NErr, &nfErr):
|
||||
return model.NewAppError("CreateChannel", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("CreateChannel", "app.user.get.app_error", nil, uresult.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
mresult := <-memberChan
|
||||
@@ -1979,7 +2008,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)
|
||||
uc <- store.StoreResult{Data: user, Err: err}
|
||||
uc <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uc)
|
||||
}()
|
||||
|
||||
@@ -2001,8 +2030,14 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError {
|
||||
}
|
||||
}
|
||||
uresult := <-uc
|
||||
if uresult.Err != nil {
|
||||
return uresult.Err
|
||||
if uresult.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(uresult.NErr, &nfErr):
|
||||
return model.NewAppError("LeaveChannel", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("LeaveChannel", "app.user.get.app_error", nil, uresult.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
ccresult := <-mcc
|
||||
if ccresult.NErr != nil {
|
||||
@@ -2134,9 +2169,15 @@ func (a *App) postRemoveFromChannelMessage(removerUserId string, removedUser *mo
|
||||
}
|
||||
|
||||
func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
|
||||
user, err := a.Srv().Store.User().Get(userIdToRemove)
|
||||
if err != nil {
|
||||
return err
|
||||
user, nErr := a.Srv().Store.User().Get(userIdToRemove)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return model.NewAppError("removeUserFromChannel", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("removeUserFromChannel", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
isGuest := user.IsGuest()
|
||||
|
||||
|
||||
@@ -1859,7 +1859,7 @@ func TestMarkChannelsAsViewedPanic(t *testing.T) {
|
||||
|
||||
mockStore := th.App.Srv().Store.(*mocks.Store)
|
||||
mockUserStore := mocks.UserStore{}
|
||||
mockUserStore.On("Get", "userID").Return(nil, model.NewAppError("SqlUserStore.Get", "store.sql_user.get.app_error", nil, "user_id=userID", http.StatusInternalServerError))
|
||||
mockUserStore.On("Get", "userID").Return(nil, model.NewAppError("SqlUserStore.Get", "app.user.get.app_error", nil, "user_id=userID", http.StatusInternalServerError))
|
||||
mockChannelStore := mocks.ChannelStore{}
|
||||
mockChannelStore.On("Get", "channelID", true).Return(&model.Channel{}, nil)
|
||||
mockChannelStore.On("GetMember", "channelID", "userID").Return(&model.ChannelMember{
|
||||
|
||||
@@ -231,28 +231,29 @@ func (a *App) MentionsToTeamMembers(message, teamId string) model.UserMentionMap
|
||||
wg.Add(1)
|
||||
go func(mention string) {
|
||||
defer wg.Done()
|
||||
user, err := a.Srv().Store.User().GetByUsername(mention)
|
||||
user, nErr := a.Srv().Store.User().GetByUsername(mention)
|
||||
|
||||
if err != nil && err.StatusCode != http.StatusNotFound {
|
||||
mlog.Warn("Failed to retrieve user @"+mention, mlog.Err(err))
|
||||
var nfErr *store.ErrNotFound
|
||||
if nErr != nil && !errors.As(nErr, &nfErr) {
|
||||
mlog.Warn("Failed to retrieve user @"+mention, mlog.Err(nErr))
|
||||
return
|
||||
}
|
||||
|
||||
// If it's a http.StatusNotFound error, check for usernames in substrings
|
||||
// without trailing punctuation
|
||||
if err != nil {
|
||||
if nErr != nil {
|
||||
trimmed, ok := model.TrimUsernameSpecialChar(mention)
|
||||
for ; ok; trimmed, ok = model.TrimUsernameSpecialChar(trimmed) {
|
||||
userFromTrimmed, userErr := a.Srv().Store.User().GetByUsername(trimmed)
|
||||
if userErr != nil && err.StatusCode != http.StatusNotFound {
|
||||
userFromTrimmed, nErr := a.Srv().Store.User().GetByUsername(trimmed)
|
||||
if nErr != nil && !errors.As(nErr, &nfErr) {
|
||||
return
|
||||
}
|
||||
|
||||
if userErr != nil {
|
||||
if nErr != nil {
|
||||
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
|
||||
@@ -265,7 +266,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
|
||||
@@ -367,7 +368,7 @@ func (a *App) tryExecuteCustomCommand(args *model.CommandArgs, trigger string, m
|
||||
userChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(args.UserId)
|
||||
userChan <- store.StoreResult{Data: user, Err: err}
|
||||
userChan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(userChan)
|
||||
}()
|
||||
|
||||
@@ -389,8 +390,14 @@ func (a *App) tryExecuteCustomCommand(args *model.CommandArgs, trigger string, m
|
||||
team := tr.Data.(*model.Team)
|
||||
|
||||
ur := <-userChan
|
||||
if ur.Err != nil {
|
||||
return nil, nil, ur.Err
|
||||
if ur.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(ur.NErr, &nfErr):
|
||||
return nil, nil, model.NewAppError("tryExecuteCustomCommand", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, nil, model.NewAppError("tryExecuteCustomCommand", "app.user.get.app_error", nil, ur.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := ur.Data.(*model.User)
|
||||
|
||||
|
||||
@@ -247,9 +247,9 @@ func (s *Server) ensureInstallationDate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
installDate, appErr := s.Store.User().InferSystemInstallDate()
|
||||
installDate, nErr := s.Store.User().InferSystemInstallDate()
|
||||
var installationDate int64
|
||||
if appErr == nil && installDate > 0 {
|
||||
if nErr == nil && installDate > 0 {
|
||||
installationDate = installDate
|
||||
} else {
|
||||
installationDate = utils.MillisFromTime(time.Now())
|
||||
|
||||
@@ -4,3 +4,5 @@
|
||||
package app
|
||||
|
||||
const MISSING_CHANNEL_MEMBER_ERROR = "app.channel.get_member.missing.app_error"
|
||||
const MISSING_ACCOUNT_ERROR = "app.user.missing_account.const"
|
||||
const MISSING_AUTH_ACCOUNT_ERROR = "app.user.get_by_auth.missing_account.app_error"
|
||||
|
||||
@@ -187,7 +187,7 @@ func (a *App) exportAllUsers(writer io.Writer) *model.AppError {
|
||||
users, err := a.Srv().Store.User().GetAllAfter(1000, afterId)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return model.NewAppError("exportAllUsers", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if len(users) == 0 {
|
||||
@@ -412,11 +412,12 @@ func (a *App) BuildPostReactions(postId string) (*[]ReactionImportData, *model.A
|
||||
for _, reaction := range reactions {
|
||||
user, err := a.Srv().Store.User().Get(reaction.UserId)
|
||||
if err != nil {
|
||||
if err.Id == store.MISSING_ACCOUNT_ERROR { // this is a valid case, the user that reacted might've been deleted by now
|
||||
var nfErr *store.ErrNotFound
|
||||
if errors.As(err, &nfErr) { // this is a valid case, the user that reacted might've been deleted by now
|
||||
mlog.Info("Skipping reactions by user since the entity doesn't exist anymore", mlog.String("user_id", reaction.UserId))
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
return nil, model.NewAppError("BuildPostReactions", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
reactionsOfPost = append(reactionsOfPost, *ImportReactionFromPost(user, reaction))
|
||||
}
|
||||
|
||||
@@ -296,9 +296,9 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError {
|
||||
hasUserEmailVerifiedChanged := false
|
||||
|
||||
var user *model.User
|
||||
var err *model.AppError
|
||||
user, err = a.Srv().Store.User().GetByUsername(*data.Username)
|
||||
if err != nil {
|
||||
var nErr error
|
||||
user, nErr = a.Srv().Store.User().GetByUsername(*data.Username)
|
||||
if nErr != nil {
|
||||
user = &model.User{}
|
||||
user.MakeNonNil()
|
||||
user.SetDefaultNotifications()
|
||||
@@ -475,6 +475,7 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError {
|
||||
}
|
||||
|
||||
var savedUser *model.User
|
||||
var err *model.AppError
|
||||
if user.Id == "" {
|
||||
if savedUser, err = a.createUser(user); err != nil {
|
||||
return err
|
||||
@@ -501,8 +502,14 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError {
|
||||
}
|
||||
} else {
|
||||
if hasUserAuthDataChanged {
|
||||
if _, err = a.Srv().Store.User().UpdateAuthData(user.Id, authService, authData, user.Email, false); err != nil {
|
||||
return err
|
||||
if _, nErr := a.Srv().Store.User().UpdateAuthData(user.Id, authService, authData, user.Email, false); nErr != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(nErr, &invErr):
|
||||
return model.NewAppError("importUser", "app.user.update_auth_data.email_exists.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return model.NewAppError("importUser", "app.user.update_auth_data.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -976,15 +983,14 @@ func (a *App) importUserChannels(user *model.User, team *model.Team, teamMember
|
||||
}
|
||||
|
||||
func (a *App) importReaction(data *ReactionImportData, post *model.Post, dryRun bool) *model.AppError {
|
||||
var err *model.AppError
|
||||
if err = validateReactionImportData(data, post.CreateAt); err != nil {
|
||||
if err := validateReactionImportData(data, post.CreateAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
user, err = a.Srv().Store.User().GetByUsername(*data.User)
|
||||
if err != nil {
|
||||
return model.NewAppError("BulkImport", "app.import.import_post.user_not_found.error", map[string]interface{}{"Username": data.User}, err.Error(), http.StatusBadRequest)
|
||||
var nErr error
|
||||
if user, nErr = a.Srv().Store.User().GetByUsername(*data.User); nErr != nil {
|
||||
return model.NewAppError("BulkImport", "app.import.import_post.user_not_found.error", map[string]interface{}{"Username": data.User}, nErr.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
reaction := &model.Reaction{
|
||||
@@ -993,7 +999,7 @@ func (a *App) importReaction(data *ReactionImportData, post *model.Post, dryRun
|
||||
EmojiName: *data.EmojiName,
|
||||
CreateAt: *data.CreateAt,
|
||||
}
|
||||
if _, nErr := a.Srv().Store.Reaction().Save(reaction); nErr != nil {
|
||||
if _, nErr = a.Srv().Store.Reaction().Save(reaction); nErr != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(nErr, &appErr):
|
||||
|
||||
@@ -85,7 +85,7 @@ func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption st
|
||||
userChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(upstreamRequest.UserId)
|
||||
userChan <- store.StoreResult{Data: user, Err: err}
|
||||
userChan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(userChan)
|
||||
}()
|
||||
|
||||
@@ -188,8 +188,14 @@ func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption st
|
||||
}()
|
||||
|
||||
ur := <-userChan
|
||||
if ur.Err != nil {
|
||||
return "", ur.Err
|
||||
if ur.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(ur.NErr, &nfErr):
|
||||
return "", model.NewAppError("DoPostActionWithCookie", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return "", model.NewAppError("DoPostActionWithCookie", "app.user.get.app_error", nil, ur.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := ur.Data.(*model.User)
|
||||
upstreamRequest.UserName = user.Username
|
||||
|
||||
@@ -96,7 +96,7 @@ func (s *Server) SaveLicense(licenseBytes []byte) (*model.License, *model.AppErr
|
||||
case errors.As(nErr, &appErr):
|
||||
return nil, appErr
|
||||
default:
|
||||
return nil, model.NewAppError("addLicense", "api.license.add_license.save.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("addLicense", "api.license.add_license.save.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ func (a *App) GetUserForLogin(id, loginId string) (*model.User, *model.AppError)
|
||||
if len(id) != 0 {
|
||||
user, err := a.GetUser(id)
|
||||
if err != nil {
|
||||
if err.Id != store.MISSING_ACCOUNT_ERROR {
|
||||
if err.Id != MISSING_ACCOUNT_ERROR {
|
||||
err.StatusCode = http.StatusInternalServerError
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
pchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
props, err := a.Srv().Store.User().GetAllProfilesInChannel(channel.Id, true)
|
||||
pchan <- store.StoreResult{Data: props, Err: err}
|
||||
pchan <- store.StoreResult{Data: props, NErr: err}
|
||||
close(pchan)
|
||||
}()
|
||||
|
||||
@@ -58,8 +58,8 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
}
|
||||
|
||||
result := <-pchan
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
return nil, result.NErr
|
||||
}
|
||||
profileMap := result.Data.(map[string]*model.User)
|
||||
|
||||
@@ -504,9 +504,9 @@ func (a *App) filterOutOfChannelMentions(sender *model.User, post *model.Post, c
|
||||
// Filter out inactive users and bots
|
||||
allUsers := model.UserSlice(users).FilterByActive(true)
|
||||
allUsers = allUsers.FilterWithoutBots()
|
||||
allUsers, err = a.FilterUsersByVisible(sender, allUsers)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
allUsers, appErr := a.FilterUsersByVisible(sender, allUsers)
|
||||
if appErr != nil {
|
||||
return nil, nil, appErr
|
||||
}
|
||||
|
||||
if len(allUsers) == 0 {
|
||||
|
||||
@@ -211,7 +211,7 @@ func (a *App) clearPushNotificationSync(currentSessionId, userId, channelId stri
|
||||
|
||||
unreadCount, err := a.Srv().Store.User().GetUnreadCount(userId)
|
||||
if err != nil {
|
||||
return err
|
||||
return model.NewAppError("clearPushNotificationSync", "app.user.get_unread_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
msg.Badge = int(unreadCount)
|
||||
@@ -242,7 +242,7 @@ func (a *App) updateMobileAppBadgeSync(userId string) *model.AppError {
|
||||
|
||||
unreadCount, err := a.Srv().Store.User().GetUnreadCount(userId)
|
||||
if err != nil {
|
||||
return err
|
||||
return model.NewAppError("updateMobileAppBadgeSync", "app.user.get_unread_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
msg.Badge = int(unreadCount)
|
||||
@@ -525,7 +525,7 @@ func (a *App) BuildPushNotificationMessage(contentsConfig string, post *model.Po
|
||||
|
||||
unreadCount, err := a.Srv().Store.User().GetUnreadCount(user.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("BuildPushNotificationMessage", "app.user.get_unread_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
msg.Badge = int(unreadCount)
|
||||
|
||||
|
||||
39
app/oauth.go
39
app/oauth.go
@@ -269,6 +269,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
|
||||
|
||||
var accessData *model.AccessData
|
||||
var accessRsp *model.AccessResponse
|
||||
var user *model.User
|
||||
if grantType == model.ACCESS_TOKEN_GRANT_TYPE {
|
||||
var authData *model.AuthData
|
||||
authData, nErr = a.Srv().Store.OAuth().GetAuthData(code)
|
||||
@@ -287,8 +288,8 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.redirect_uri.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
user, err := a.Srv().Store.User().Get(authData.UserId)
|
||||
if err != nil {
|
||||
user, nErr = a.Srv().Store.User().Get(authData.UserId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound)
|
||||
}
|
||||
|
||||
@@ -300,7 +301,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
|
||||
if accessData != nil {
|
||||
if accessData.IsExpired() {
|
||||
var access *model.AccessResponse
|
||||
access, err = a.newSessionUpdateToken(oauthApp.Name, accessData, user)
|
||||
access, err := a.newSessionUpdateToken(oauthApp.Name, accessData, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -317,7 +318,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
|
||||
} else {
|
||||
var session *model.Session
|
||||
// Create a new session and return new access token
|
||||
session, err = a.newSession(oauthApp.Name, user)
|
||||
session, err := a.newSession(oauthApp.Name, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -347,8 +348,8 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.refresh_token.app_error", nil, "", http.StatusNotFound)
|
||||
}
|
||||
|
||||
user, err := a.Srv().Store.User().Get(accessData.UserId)
|
||||
if err != nil {
|
||||
user, nErr := a.Srv().Store.User().Get(accessData.UserId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound)
|
||||
}
|
||||
|
||||
@@ -587,7 +588,7 @@ func (a *App) LoginByOAuth(service string, userData io.Reader, teamId string) (*
|
||||
}
|
||||
user, err := a.GetUserByAuth(model.NewString(*authUser.AuthData), service)
|
||||
if err != nil {
|
||||
if err.Id == store.MISSING_AUTH_ACCOUNT_ERROR {
|
||||
if err.Id == MISSING_AUTH_ACCOUNT_ERROR {
|
||||
user, err = a.CreateOAuthUser(service, bytes.NewReader(buf.Bytes()), teamId)
|
||||
} else {
|
||||
return nil, err
|
||||
@@ -637,21 +638,27 @@ func (a *App) CompleteSwitchWithOAuth(service string, userData io.Reader, email
|
||||
map[string]interface{}{"Service": service}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
user, err := a.Srv().Store.User().GetByEmail(email)
|
||||
if err != nil {
|
||||
user, nErr := a.Srv().Store.User().GetByEmail(email)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("CompleteSwitchWithOAuth", MISSING_ACCOUNT_ERROR, nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if err := a.RevokeAllSessions(user.Id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = a.RevokeAllSessions(user.Id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err = a.Srv().Store.User().UpdateAuthData(user.Id, service, model.NewString(*ssoUser.AuthData), ssoUser.Email, true); err != nil {
|
||||
return nil, err
|
||||
if _, nErr := a.Srv().Store.User().UpdateAuthData(user.Id, service, ssoUser.AuthData, ssoUser.Email, true); nErr != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(nErr, &invErr):
|
||||
return nil, model.NewAppError("importUser", "app.user.update_auth_data.email_exists.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("importUser", "app.user.update_auth_data.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
a.Srv().Go(func() {
|
||||
if err = a.Srv().EmailService.SendSignInChangeEmail(user.Email, strings.Title(service)+" SSO", user.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.Srv().EmailService.SendSignInChangeEmail(user.Email, strings.Title(service)+" SSO", user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("error sending signin change email", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -30,7 +30,7 @@ func (a *App) ResetPermissionsSystem() *model.AppError {
|
||||
|
||||
// Reset all Custom Role assignments to Users.
|
||||
if err := a.Srv().Store.User().ClearAllCustomRoleAssignments(); err != nil {
|
||||
return err
|
||||
return model.NewAppError("ResetPermissionsSystem", "app.user.clear_all_custom_role_assignments.select.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// Reset all Custom Role assignments to TeamMembers.
|
||||
|
||||
24
app/post.go
24
app/post.go
@@ -53,9 +53,15 @@ func (a *App) CreatePostAsUser(post *model.Post, currentSessionId string, setOnl
|
||||
}
|
||||
|
||||
if err.Id == "api.post.create_post.town_square_read_only" {
|
||||
user, userErr := a.Srv().Store.User().Get(post.UserId)
|
||||
if userErr != nil {
|
||||
return nil, userErr
|
||||
user, nErr := a.Srv().Store.User().Get(post.UserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("CreatePostAsUser", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("CreatePostAsUser", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
T := utils.GetUserTranslations(user.Locale)
|
||||
@@ -185,9 +191,15 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
||||
}()
|
||||
}
|
||||
|
||||
user, err := a.Srv().Store.User().Get(post.UserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(post.UserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("CreatePost", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("CreatePost", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if user.IsBot {
|
||||
|
||||
@@ -16,10 +16,10 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
date_constraints "github.com/reflog/dateconstraints"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/reflog/dateconstraints"
|
||||
)
|
||||
|
||||
const MAX_REPEAT_VIEWINGS = 3
|
||||
@@ -301,16 +301,15 @@ func (a *App) UpdateProductNotices() *model.AppError {
|
||||
url := *a.Srv().Config().AnnouncementSettings.NoticesURL
|
||||
skip := *a.Srv().Config().AnnouncementSettings.NoticesSkipCache
|
||||
mlog.Debug("Will fetch notices from", mlog.String("url", url), mlog.Bool("skip_cache", skip))
|
||||
var appErr *model.AppError
|
||||
var err error
|
||||
cachedPostCount, err = a.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to fetch post count", mlog.String("error", err.Error()))
|
||||
}
|
||||
|
||||
cachedUserCount, appErr = a.Srv().Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
if appErr != nil {
|
||||
mlog.Error("Failed to fetch user count", mlog.String("error", appErr.Error()))
|
||||
cachedUserCount, err = a.Srv().Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
if err != nil {
|
||||
mlog.Error("Failed to fetch user count", mlog.String("error", err.Error()))
|
||||
}
|
||||
|
||||
data, err := utils.GetUrlWithCache(url, ¬icesCache, skip)
|
||||
|
||||
@@ -399,9 +399,15 @@ func (a *App) SetSessionExpireInDays(session *model.Session, days int) {
|
||||
|
||||
func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
||||
|
||||
user, err := a.Srv().Store.User().Get(token.UserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(token.UserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("CreateUserAccessToken", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("CreateUserAccessToken", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if !*a.Config().ServiceSettings.EnableUserAccessTokens && !user.IsBot {
|
||||
@@ -410,14 +416,14 @@ func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAc
|
||||
|
||||
token.Token = model.NewId()
|
||||
|
||||
token, nErr := a.Srv().Store.UserAccessToken().Save(token)
|
||||
token, nErr = a.Srv().Store.UserAccessToken().Save(token)
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(nErr, &appErr):
|
||||
return nil, appErr
|
||||
default:
|
||||
return nil, model.NewAppError("CreateUserAccessToken", "app.user_access_token.save.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("CreateUserAccessToken", "app.user_access_token.save.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,9 +448,15 @@ func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Sessio
|
||||
return nil, model.NewAppError("createSessionForUserAccessToken", "app.user_access_token.invalid_or_missing", nil, "inactive_token", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
user, err := a.Srv().Store.User().Get(token.UserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(token.UserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("createSessionForUserAccessToken", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("createSessionForUserAccessToken", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if !*a.Config().ServiceSettings.EnableUserAccessTokens && !user.IsBot {
|
||||
|
||||
@@ -56,7 +56,7 @@ func CreateBasicUser(a *app.App, client *model.Client4) *model.AppError {
|
||||
}
|
||||
_, err := a.Srv().Store.User().VerifyEmail(ruser.Id, ruser.Email)
|
||||
if err != nil {
|
||||
return err
|
||||
return model.NewAppError("CreateBasicUser", "app.user.verify_email.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if _, nErr := a.Srv().Store.Team().SaveMember(&model.TeamMember{TeamId: basicteam.Id, UserId: ruser.Id}, *a.Config().TeamSettings.MaxUsersPerTeam); nErr != nil {
|
||||
var appErr *model.AppError
|
||||
|
||||
@@ -48,8 +48,8 @@ func (me *groupmsgProvider) DoCommand(a *app.App, args *model.CommandArgs, messa
|
||||
for _, username := range users {
|
||||
username = strings.TrimSpace(username)
|
||||
username = strings.TrimPrefix(username, "@")
|
||||
targetUser, err := a.Srv().Store.User().GetByUsername(username)
|
||||
if err != nil {
|
||||
targetUser, nErr := a.Srv().Store.User().GetByUsername(username)
|
||||
if nErr != nil {
|
||||
invalidUsernames = append(invalidUsernames, username)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ func (me *InviteProvider) DoCommand(a *app.App, args *model.CommandArgs, message
|
||||
targetUsername := splitMessage[0]
|
||||
targetUsername = strings.TrimPrefix(targetUsername, "@")
|
||||
|
||||
userProfile, err := a.Srv().Store.User().GetByUsername(targetUsername)
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
userProfile, nErr := a.Srv().Store.User().GetByUsername(targetUsername)
|
||||
if nErr != nil {
|
||||
mlog.Error(nErr.Error())
|
||||
return &model.CommandResponse{
|
||||
Text: args.T("api.command_invite.missing_user.app_error"),
|
||||
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
||||
@@ -67,6 +67,7 @@ func (me *InviteProvider) DoCommand(a *app.App, args *model.CommandArgs, message
|
||||
}
|
||||
|
||||
var channelToJoin *model.Channel
|
||||
var err *model.AppError
|
||||
// User set a channel to add the invited user
|
||||
if len(splitMessage) > 1 && splitMessage[1] != "" {
|
||||
targetChannelName := strings.TrimPrefix(strings.TrimSpace(splitMessage[1]), "~")
|
||||
|
||||
@@ -51,9 +51,9 @@ func (me *msgProvider) DoCommand(a *app.App, args *model.CommandArgs, message st
|
||||
targetUsername = strings.SplitN(message, " ", 2)[0]
|
||||
targetUsername = strings.TrimPrefix(targetUsername, "@")
|
||||
|
||||
userProfile, err := a.Srv().Store.User().GetByUsername(targetUsername)
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
userProfile, nErr := a.Srv().Store.User().GetByUsername(targetUsername)
|
||||
if nErr != nil {
|
||||
mlog.Error(nErr.Error())
|
||||
return &model.CommandResponse{Text: args.T("api.command_msg.missing.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,9 +108,9 @@ func doCommand(a *app.App, args *model.CommandArgs, message string) *model.Comma
|
||||
targetUsername = strings.SplitN(message, " ", 2)[0]
|
||||
targetUsername = strings.TrimPrefix(targetUsername, "@")
|
||||
|
||||
userProfile, err := a.Srv().Store.User().GetByUsername(targetUsername)
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
userProfile, nErr := a.Srv().Store.User().GetByUsername(targetUsername)
|
||||
if nErr != nil {
|
||||
mlog.Error(nErr.Error())
|
||||
return &model.CommandResponse{
|
||||
Text: args.T("api.command_remove.missing.app_error"),
|
||||
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
||||
|
||||
88
app/team.go
88
app/team.go
@@ -488,7 +488,7 @@ func (a *App) AddUserToTeam(teamId string, userId string, userRequestorId string
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -505,8 +505,14 @@ func (a *App) AddUserToTeam(teamId string, userId string, userRequestorId string
|
||||
team := result.Data.(*model.Team)
|
||||
|
||||
result = <-uchan
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(result.NErr, &nfErr):
|
||||
return nil, model.NewAppError("AddUserToTeam", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("AddUserToTeam", "app.user.get.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
@@ -559,7 +565,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)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -580,8 +586,14 @@ func (a *App) AddUserToTeamByToken(userId string, tokenId string) (*model.Team,
|
||||
}
|
||||
|
||||
result = <-uchan
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(result.NErr, &nfErr):
|
||||
return nil, model.NewAppError("AddUserToTeamByToken", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("AddUserToTeamByToken", "app.user.get.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
@@ -628,7 +640,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)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -645,8 +657,14 @@ func (a *App) AddUserToTeamByInviteId(inviteId string, userId string) (*model.Te
|
||||
team := result.Data.(*model.Team)
|
||||
|
||||
result = <-uchan
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(result.NErr, &nfErr):
|
||||
return nil, model.NewAppError("AddUserToTeamByInviteId", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("AddUserToTeamByInviteId", "app.user.get.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
@@ -760,7 +778,7 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId
|
||||
}
|
||||
|
||||
if _, err := a.Srv().Store.User().UpdateUpdateAt(user.Id); err != nil {
|
||||
return err
|
||||
return model.NewAppError("JoinUserToTeam", "app.user.update_update.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if err := a.createInitialSidebarCategories(user.Id, team.Id); err != nil {
|
||||
@@ -1144,7 +1162,7 @@ func (a *App) RemoveUserFromTeam(teamId string, userId string, requestorId strin
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -1161,8 +1179,14 @@ func (a *App) RemoveUserFromTeam(teamId string, userId string, requestorId strin
|
||||
team := result.Data.(*model.Team)
|
||||
|
||||
result = <-uchan
|
||||
if result.Err != nil {
|
||||
return result.Err
|
||||
if result.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(result.NErr, &nfErr):
|
||||
return model.NewAppError("RemoveUserFromTeam", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("RemoveUserFromTeam", "app.user.get.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
@@ -1180,9 +1204,15 @@ func (a *App) RemoveTeamMemberFromTeam(teamMember *model.TeamMember, requestorId
|
||||
message.Add("team_id", teamMember.TeamId)
|
||||
a.Publish(message)
|
||||
|
||||
user, err := a.Srv().Store.User().Get(teamMember.UserId)
|
||||
if err != nil {
|
||||
return err
|
||||
user, nErr := a.Srv().Store.User().Get(teamMember.UserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return model.NewAppError("RemoveTeamMemberFromTeam", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("RemoveTeamMemberFromTeam", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
teamMember.Roles = ""
|
||||
@@ -1214,7 +1244,7 @@ func (a *App) RemoveTeamMemberFromTeam(teamMember *model.TeamMember, requestorId
|
||||
}
|
||||
|
||||
if _, err := a.Srv().Store.User().UpdateUpdateAt(user.Id); err != nil {
|
||||
return err
|
||||
return model.NewAppError("RemoveTeamMemberFromTeam", "app.user.update_update.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Channel().ClearSidebarOnTeamLeave(user.Id, teamMember.TeamId); err != nil {
|
||||
@@ -1337,7 +1367,7 @@ func (a *App) prepareInviteNewUsersToTeam(teamId, senderId string) (*model.User,
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(senderId)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -1354,8 +1384,14 @@ func (a *App) prepareInviteNewUsersToTeam(teamId, senderId string) (*model.User,
|
||||
team := result.Data.(*model.Team)
|
||||
|
||||
result = <-uchan
|
||||
if result.Err != nil {
|
||||
return nil, nil, result.Err
|
||||
if result.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(result.NErr, &nfErr):
|
||||
return nil, nil, model.NewAppError("prepareInviteNewUsersToTeam", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, nil, model.NewAppError("prepareInviteNewUsersToTeam", "app.user.get.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
return user, team, nil
|
||||
@@ -1462,7 +1498,7 @@ func (a *App) prepareInviteGuestsToChannels(teamId string, guestsInvite *model.G
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(senderId)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -1473,8 +1509,14 @@ func (a *App) prepareInviteGuestsToChannels(teamId string, guestsInvite *model.G
|
||||
channels := result.Data.([]*model.Channel)
|
||||
|
||||
result = <-uchan
|
||||
if result.Err != nil {
|
||||
return nil, nil, nil, result.Err
|
||||
if result.NErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(result.NErr, &nfErr):
|
||||
return nil, nil, nil, model.NewAppError("prepareInviteGuestsToChannels", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, nil, nil, model.NewAppError("prepareInviteGuestsToChannels", "app.user.get.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
|
||||
306
app/user.go
306
app/user.go
@@ -258,7 +258,7 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
|
||||
// system is granted the system_admin role
|
||||
count, err := a.Srv().Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("createUserOrGuest", "app.user.get_total_users_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if count <= 0 {
|
||||
user.Roles = model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID
|
||||
@@ -268,9 +268,9 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
|
||||
user.Locale = *a.Config().LocalizationSettings.DefaultClientLocale
|
||||
}
|
||||
|
||||
ruser, err := a.createUser(user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
ruser, appErr := a.createUser(user)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
// This message goes to everyone, so the teamId, channelId and userId are irrelevant
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_NEW_USER, "", "", "", nil)
|
||||
@@ -297,10 +297,19 @@ func (a *App) createUser(user *model.User) (*model.User, *model.AppError) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ruser, err := a.Srv().Store.User().Save(user)
|
||||
if err != nil {
|
||||
mlog.Error("Couldn't save the user", mlog.Err(err))
|
||||
return nil, err
|
||||
ruser, nErr := a.Srv().Store.User().Save(user)
|
||||
if nErr != nil {
|
||||
mlog.Error("Couldn't save the user", mlog.Err(nErr))
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(nErr, &appErr):
|
||||
return nil, appErr
|
||||
case errors.As(nErr, &invErr):
|
||||
return nil, model.NewAppError("createUser", "app.user.save.existing.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("createUser", "app.user.save.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if user.EmailVerified {
|
||||
@@ -337,12 +346,12 @@ func (a *App) CreateOAuthUser(service string, userData io.Reader, teamId string)
|
||||
euchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
userByAuth, err := a.Srv().Store.User().GetByAuth(user.AuthData, service)
|
||||
suchan <- store.StoreResult{Data: userByAuth, Err: err}
|
||||
suchan <- store.StoreResult{Data: userByAuth, NErr: err}
|
||||
close(suchan)
|
||||
}()
|
||||
go func() {
|
||||
userByEmail, err := a.Srv().Store.User().GetByEmail(user.Email)
|
||||
euchan <- store.StoreResult{Data: userByEmail, Err: err}
|
||||
euchan <- store.StoreResult{Data: userByEmail, NErr: err}
|
||||
close(euchan)
|
||||
}()
|
||||
|
||||
@@ -355,11 +364,11 @@ func (a *App) CreateOAuthUser(service string, userData io.Reader, teamId string)
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-suchan; result.Err == nil {
|
||||
if result := <-suchan; result.NErr == nil {
|
||||
return result.Data.(*model.User), nil
|
||||
}
|
||||
|
||||
if result := <-euchan; result.Err == nil {
|
||||
if result := <-euchan; result.NErr == nil {
|
||||
authService := result.Data.(*model.User).AuthService
|
||||
if authService == "" {
|
||||
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_oauth_user.already_attached.app_error", map[string]interface{}{"Service": service, "Auth": model.USER_AUTH_SERVICE_EMAIL}, "email="+user.Email, http.StatusBadRequest)
|
||||
@@ -425,14 +434,30 @@ func (a *App) IsUsernameTaken(name string) bool {
|
||||
}
|
||||
|
||||
func (a *App) GetUser(userId string) (*model.User, *model.AppError) {
|
||||
return a.Srv().Store.User().Get(userId)
|
||||
user, err := a.Srv().Store.User().Get(userId)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("GetUser", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("GetUser", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUserByUsername(username string) (*model.User, *model.AppError) {
|
||||
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
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("GetUserByUsername", "app.user.get_by_username.app_error", nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("GetUserByUsername", "app.user.get_by_username.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -440,22 +465,42 @@ 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)
|
||||
if err != nil {
|
||||
if err.Id == "store.sql_user.missing_account.const" {
|
||||
err.StatusCode = http.StatusNotFound
|
||||
return nil, err
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("GetUserByEmail", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("GetUserByEmail", MISSING_ACCOUNT_ERROR, nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
err.StatusCode = http.StatusBadRequest
|
||||
return nil, err
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUserByAuth(authData *string, authService string) (*model.User, *model.AppError) {
|
||||
return a.Srv().Store.User().GetByAuth(authData, authService)
|
||||
user, err := a.Srv().Store.User().GetByAuth(authData, authService)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("GetUserByAuth", MISSING_AUTH_ACCOUNT_ERROR, nil, invErr.Error(), http.StatusBadRequest)
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("GetUserByAuth", MISSING_AUTH_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusInternalServerError)
|
||||
default:
|
||||
return nil, model.NewAppError("GetUserByAuth", "app.user.get_by_auth.other.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsers(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv().Store.User().GetAllProfiles(options)
|
||||
users, err := a.Srv().Store.User().GetAllProfiles(options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsers", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError) {
|
||||
@@ -472,11 +517,21 @@ func (a *App) GetUsersEtag(restrictionsHash string) string {
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv().Store.User().GetProfiles(options)
|
||||
users, err := a.Srv().Store.User().GetProfiles(options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersInTeam", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError) {
|
||||
@@ -506,11 +561,21 @@ func (a *App) GetUsersNotInTeamEtag(teamId string, restrictionsHash string) stri
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInChannel(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv().Store.User().GetProfilesInChannel(options)
|
||||
users, err := a.Srv().Store.User().GetProfilesInChannel(options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersInChannel", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInChannelByStatus(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
return a.Srv().Store.User().GetProfilesInChannelByStatus(options)
|
||||
users, err := a.Srv().Store.User().GetProfilesInChannelByStatus(options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersInChannelByStatus", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInChannelMap(options *model.UserGetOptions, asAdmin bool) (map[string]*model.User, *model.AppError) {
|
||||
@@ -546,7 +611,12 @@ func (a *App) GetUsersInChannelPageByStatus(options *model.UserGetOptions, asAdm
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -584,17 +654,32 @@ 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)
|
||||
users, err := a.Srv().Store.User().GetProfilesWithoutTeam(options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersWithoutTeam", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
users, err := a.Srv().Store.User().GetTeamGroupUsers(teamID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamGroupUsers", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
users, err := a.Srv().Store.User().GetChannelGroupUsers(channelID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelGroupUsers", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) GetUsersByIds(userIds []string, options *store.UserGetByIdsOpts) ([]*model.User, *model.AppError) {
|
||||
@@ -602,7 +687,7 @@ func (a *App) GetUsersByIds(userIds []string, options *store.UserGetByIdsOpts) (
|
||||
|
||||
users, err := a.Srv().Store.User().GetProfileByIds(userIds, options, allowFromCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetUsersByIds", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return a.sanitizeProfiles(users, options.IsAdmin), nil
|
||||
@@ -611,7 +696,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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetUsersByGroupChannelIds", "app.user.get_profile_by_group_channel_ids_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
for channelId, userList := range usersByChannelId {
|
||||
usersByChannelId[channelId] = a.sanitizeProfiles(userList, asAdmin)
|
||||
@@ -623,7 +708,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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetUsersByUsernames", "app.user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return a.sanitizeProfiles(users, asAdmin), nil
|
||||
}
|
||||
@@ -658,7 +743,13 @@ 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)
|
||||
if err != nil {
|
||||
return err
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return model.NewAppError("ActivateMfa", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return model.NewAppError("ActivateMfa", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if len(user.AuthService) > 0 && user.AuthService != model.USER_AUTH_SERVICE_LDAP {
|
||||
@@ -1003,7 +1094,16 @@ func (a *App) UpdateActive(user *model.User, active bool) (*model.User, *model.A
|
||||
|
||||
userUpdate, err := a.Srv().Store.User().Update(user, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
return nil, appErr
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("UpdateActive", "app.user.update.find.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("UpdateActive", "app.user.update.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
ruser := userUpdate.New
|
||||
|
||||
@@ -1024,7 +1124,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()
|
||||
if err != nil {
|
||||
return err
|
||||
return model.NewAppError("DeactivateGuests", "app.user.update_active_for_multiple_users.updating.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, userId := range userIds {
|
||||
@@ -1098,13 +1198,19 @@ 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 {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("UpdateUserAuth", "app.user.update_password.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
} else {
|
||||
userAuth.Password = ""
|
||||
|
||||
if _, err := a.Srv().Store.User().UpdateAuthData(userId, userAuth.AuthService, userAuth.AuthData, "", false); err != nil {
|
||||
return nil, err
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("UpdateUserAuth", "app.user.update_auth_data.email_exists.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("UpdateUserAuth", "app.user.update_auth_data.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1129,7 +1235,13 @@ 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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("UpdateUser", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("UpdateUser", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if !CheckUserDomain(user, *a.Config().TeamSettings.RestrictCreationToDomains) {
|
||||
@@ -1150,8 +1262,8 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
if *a.Config().EmailSettings.RequireEmailVerification && prev.Email != user.Email {
|
||||
newEmail = user.Email
|
||||
|
||||
_, err = a.GetUserByEmail(newEmail)
|
||||
if err == nil {
|
||||
_, appErr := a.GetUserByEmail(newEmail)
|
||||
if appErr == nil {
|
||||
return nil, model.NewAppError("UpdateUser", "store.sql_user.update.email_taken.app_error", nil, "user_id="+user.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -1166,7 +1278,16 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
|
||||
userUpdate, err := a.Srv().Store.User().Update(user, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
return nil, appErr
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("UpdateUser", "app.user.update.find.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("UpdateUser", "app.user.update.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if sendNotifications {
|
||||
@@ -1440,7 +1561,7 @@ func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
userUpdate, err := a.Srv().Store.User().Update(user, true)
|
||||
uchan <- store.StoreResult{Data: userUpdate, Err: err}
|
||||
uchan <- store.StoreResult{Data: userUpdate, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -1452,8 +1573,17 @@ func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent
|
||||
}()
|
||||
|
||||
result := <-uchan
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(result.NErr, &appErr):
|
||||
return nil, appErr
|
||||
case errors.As(result.NErr, &invErr):
|
||||
return nil, model.NewAppError("UpdateUserRoles", "app.user.update.find.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("UpdateUserRoles", "app.user.update.finding.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
ruser := result.Data.(*model.UserUpdate).New
|
||||
|
||||
@@ -1572,7 +1702,7 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError {
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.User().PermanentDelete(user.Id); err != nil {
|
||||
return err
|
||||
return model.NewAppError("PermanentDeleteUser", "app.user.permanent_delete.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Audit().PermanentDeleteByUser(user.Id); err != nil {
|
||||
@@ -1591,7 +1721,7 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError {
|
||||
func (a *App) PermanentDeleteAllUsers() *model.AppError {
|
||||
users, err := a.Srv().Store.User().GetAll()
|
||||
if err != nil {
|
||||
return err
|
||||
return model.NewAppError("PermanentDeleteAllUsers", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
for _, user := range users {
|
||||
a.PermanentDeleteUser(user)
|
||||
@@ -1674,7 +1804,7 @@ func (a *App) GetTotalUsersStats(viewRestrictions *model.ViewUsersRestrictions)
|
||||
ViewRestrictions: viewRestrictions,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetTotalUsersStats", "app.user.get_total_users_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
stats := &model.UsersStats{
|
||||
TotalUsersCount: count,
|
||||
@@ -1686,7 +1816,7 @@ func (a *App) GetTotalUsersStats(viewRestrictions *model.ViewUsersRestrictions)
|
||||
func (a *App) GetFilteredUsersStats(options *model.UserCountOptions) (*model.UsersStats, *model.AppError) {
|
||||
count, err := a.Srv().Store.User().Count(*options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetFilteredUsersStats", "app.user.get_total_users_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
stats := &model.UsersStats{
|
||||
TotalUsersCount: count,
|
||||
@@ -1696,7 +1826,7 @@ func (a *App) GetFilteredUsersStats(options *model.UserCountOptions) (*model.Use
|
||||
|
||||
func (a *App) VerifyUserEmail(userId, email string) *model.AppError {
|
||||
if _, err := a.Srv().Store.User().VerifyEmail(userId, email); err != nil {
|
||||
return err
|
||||
return model.NewAppError("VerifyUserEmail", "app.user.verify_email.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
@@ -1735,7 +1865,7 @@ func (a *App) SearchUsersInChannel(channelId string, term string, options *model
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv().Store.User().SearchInChannel(channelId, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("SearchUsersInChannel", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
for _, user := range users {
|
||||
a.SanitizeProfile(user, options.IsAdmin)
|
||||
@@ -1748,7 +1878,7 @@ func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term stri
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv().Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("SearchUsersNotInChannel", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
@@ -1759,13 +1889,11 @@ func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term stri
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersInTeam(teamId, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
var users []*model.User
|
||||
var err *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, err
|
||||
return nil, model.NewAppError("SearchUsersInTeam", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
@@ -1779,7 +1907,7 @@ func (a *App) SearchUsersNotInTeam(notInTeamId string, term string, options *mod
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv().Store.User().SearchNotInTeam(notInTeamId, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("SearchUsersNotInTeam", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
@@ -1793,7 +1921,7 @@ func (a *App) SearchUsersWithoutTeam(term string, options *model.UserSearchOptio
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv().Store.User().SearchWithoutTeam(term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("SearchUsersWithoutTeam", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
@@ -1807,7 +1935,7 @@ func (a *App) SearchUsersInGroup(groupID string, term string, options *model.Use
|
||||
term = strings.TrimSpace(term)
|
||||
users, err := a.Srv().Store.User().SearchInGroup(groupID, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("SearchUsersInGroup", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
@@ -1822,7 +1950,7 @@ func (a *App) AutocompleteUsersInChannel(teamId string, channelId string, term s
|
||||
|
||||
autocomplete, err := a.Srv().Store.User().AutocompleteUsersInChannel(teamId, channelId, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("AutocompleteUsersInChannel", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, user := range autocomplete.InChannel {
|
||||
@@ -1837,13 +1965,11 @@ func (a *App) AutocompleteUsersInChannel(teamId string, channelId string, term s
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteUsersInTeam(teamId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError) {
|
||||
var err *model.AppError
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
users, err := a.Srv().Store.User().Search(teamId, term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("AutocompleteUsersInTeam", "app.user.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
@@ -1892,7 +2018,16 @@ func (a *App) UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provide
|
||||
if userAttrsChanged {
|
||||
users, err := a.Srv().Store.User().Update(user, true)
|
||||
if err != nil {
|
||||
return err
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
return appErr
|
||||
case errors.As(err, &invErr):
|
||||
return model.NewAppError("UpdateOAuthUserAttrs", "app.user.update.find.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return model.NewAppError("UpdateOAuthUserAttrs", "app.user.update.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
user = users.New
|
||||
@@ -2047,10 +2182,10 @@ func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestricti
|
||||
// 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)
|
||||
nErr := a.Srv().Store.User().PromoteGuestToUser(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
if nErr != nil {
|
||||
return model.NewAppError("PromoteGuestToUser", "app.user.promote_guest.user_update.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
userTeams, nErr := a.Srv().Store.Team().GetTeamsByUserId(user.Id)
|
||||
if nErr != nil {
|
||||
@@ -2059,7 +2194,7 @@ func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.Ap
|
||||
|
||||
for _, team := range userTeams {
|
||||
// Soft error if there is an issue joining the default channels
|
||||
if err = a.JoinDefaultChannels(team.Id, user, false, requestorId); err != nil {
|
||||
if err := a.JoinDefaultChannels(team.Id, user, false, requestorId); err != nil {
|
||||
mlog.Error("Failed to join default channels", mlog.String("user_id", user.Id), mlog.String("team_id", team.Id), mlog.String("requestor_id", requestorId), mlog.Err(err))
|
||||
}
|
||||
}
|
||||
@@ -2101,10 +2236,10 @@ 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)
|
||||
nErr := a.Srv().Store.User().DemoteUserToGuest(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
if nErr != nil {
|
||||
return model.NewAppError("DemoteUserToGuest", "app.user.demote_user_to_guest.user_update.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
demotedUser, err := a.GetUser(user.Id)
|
||||
@@ -2176,29 +2311,40 @@ func (a *App) invalidateUserCacheAndPublish(userId string) {
|
||||
// relationship with a user. That means any user sharing any channel, including
|
||||
// direct and group channels.
|
||||
func (a *App) GetKnownUsers(userID string) ([]string, *model.AppError) {
|
||||
return a.Srv().Store.User().GetKnownUsers(userID)
|
||||
users, err := a.Srv().Store.User().GetKnownUsers(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetKnownUsers", "app.user.get_known_users.get_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
// ConvertBotToUser converts a bot to user.
|
||||
func (a *App) ConvertBotToUser(bot *model.Bot, userPatch *model.UserPatch, sysadmin bool) (*model.User, *model.AppError) {
|
||||
user, err := a.Srv().Store.User().Get(bot.UserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
user, nErr := a.Srv().Store.User().Get(bot.UserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("ConvertBotToUser", MISSING_ACCOUNT_ERROR, nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("ConvertBotToUser", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
if sysadmin && !user.IsInRole(model.SYSTEM_ADMIN_ROLE_ID) {
|
||||
_, err = a.UpdateUserRoles(
|
||||
_, appErr := a.UpdateUserRoles(
|
||||
user.Id,
|
||||
fmt.Sprintf("%s %s", user.Roles, model.SYSTEM_ADMIN_ROLE_ID),
|
||||
false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
}
|
||||
|
||||
user.Patch(userPatch)
|
||||
|
||||
user, err = a.UpdateUser(user, false)
|
||||
user, err := a.UpdateUser(user, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -398,8 +398,8 @@ func TestUpdateUserEmail(t *testing.T) {
|
||||
Username: model.NewId(),
|
||||
IsBot: true,
|
||||
}
|
||||
_, err = th.App.Srv().Store.User().Save(&botuser)
|
||||
assert.Nil(t, err)
|
||||
_, nErr := th.App.Srv().Store.User().Save(&botuser)
|
||||
assert.Nil(t, nErr)
|
||||
|
||||
newBotEmail := th.MakeEmail()
|
||||
botuser.Email = newBotEmail
|
||||
@@ -441,8 +441,8 @@ func TestUpdateUserEmail(t *testing.T) {
|
||||
Username: model.NewId(),
|
||||
IsBot: true,
|
||||
}
|
||||
_, err = th.App.Srv().Store.User().Save(&botuser)
|
||||
assert.Nil(t, err)
|
||||
_, nErr := th.App.Srv().Store.User().Save(&botuser)
|
||||
assert.Nil(t, nErr)
|
||||
|
||||
newBotEmail := th.MakeEmail()
|
||||
botuser.Email = newBotEmail
|
||||
|
||||
@@ -676,7 +676,7 @@ func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookReq
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv().Store.User().Get(hook.UserId)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
uchan <- store.StoreResult{Data: user, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
@@ -700,7 +700,7 @@ func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookReq
|
||||
if len(channelName) != 0 {
|
||||
if channelName[0] == '@' {
|
||||
if result, err := a.Srv().Store.User().GetByUsername(channelName[1:]); err != nil {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.user.app_error", nil, "err="+err.Message, http.StatusBadRequest)
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.user.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
} else {
|
||||
if ch, err := a.GetOrCreateDirectChannel(hook.UserId, result.Id); err != nil {
|
||||
return err
|
||||
@@ -757,8 +757,8 @@ func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookReq
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-uchan; result.Err != nil {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.user.app_error", nil, "err="+result.Err.Message, http.StatusForbidden)
|
||||
if result := <-uchan; result.NErr != nil {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.user.app_error", nil, result.NErr.Error(), http.StatusForbidden)
|
||||
} else {
|
||||
user = result.Data.(*model.User)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func getUserFromUserArg(a *app.App, userArg string) *model.User {
|
||||
user, _ := a.Srv().Store.User().GetByEmail(userArg)
|
||||
|
||||
if user == nil {
|
||||
var err *model.AppError
|
||||
var err error
|
||||
if user, err = a.Srv().Store.User().GetByUsername(userArg); err == nil {
|
||||
return user
|
||||
}
|
||||
|
||||
372
i18n/en.json
372
i18n/en.json
@@ -5334,14 +5334,138 @@
|
||||
"id": "app.upload.upload_data.update.app_error",
|
||||
"translation": "Failed to update the upload session."
|
||||
},
|
||||
{
|
||||
"id": "app.user.analytics_daily_active_users.app_error",
|
||||
"translation": "Unable to get the active users during the requested period."
|
||||
},
|
||||
{
|
||||
"id": "app.user.analytics_get_inactive_users_count.app_error",
|
||||
"translation": "We could not count the inactive users."
|
||||
},
|
||||
{
|
||||
"id": "app.user.clear_all_custom_role_assignments.select.app_error",
|
||||
"translation": "Failed to retrieve the users."
|
||||
},
|
||||
{
|
||||
"id": "app.user.convert_bot_to_user.app_error",
|
||||
"translation": "Unable to convert bot to user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.demote_user_to_guest.user_update.app_error",
|
||||
"translation": "Failed to update the user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get.app_error",
|
||||
"translation": "We encountered an error finding the account."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_by_auth.missing_account.app_error",
|
||||
"translation": "Unable to find an existing account matching your authentication type for this team. This team may require an invite from the team owner to join."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_by_auth.other.app_error",
|
||||
"translation": "We encountered an error trying to find the account by authentication type."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_by_username.app_error",
|
||||
"translation": "Unable to find an existing account matching your username for this team. This team may require an invite from the team owner to join."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_known_users.get_users.app_error",
|
||||
"translation": "Unable to get know users from the database."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_new_users.app_error",
|
||||
"translation": "We encountered an error while finding the new users."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_profile_by_group_channel_ids_for_user.app_error",
|
||||
"translation": "We encountered an error while finding user profiles."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_profiles.app_error",
|
||||
"translation": "We encountered an error while finding user profiles."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_recently_active_users.app_error",
|
||||
"translation": "We encountered an error while finding the recently active users."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_total_users_count.app_error",
|
||||
"translation": "We could not count the users."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_unread_count.app_error",
|
||||
"translation": "We could not get the unread message count for the user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.get_users_batch_for_indexing.get_users.app_error",
|
||||
"translation": "Unable to get the users batch for indexing."
|
||||
},
|
||||
{
|
||||
"id": "app.user.missing_account.const",
|
||||
"translation": "Unable to find the user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.permanent_delete.app_error",
|
||||
"translation": "Unable to delete the existing account."
|
||||
},
|
||||
{
|
||||
"id": "app.user.permanentdeleteuser.internal_error",
|
||||
"translation": "Unable to delete user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.promote_guest.user_update.app_error",
|
||||
"translation": "Failed to update the user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.save.app_error",
|
||||
"translation": "Unable to save the account."
|
||||
},
|
||||
{
|
||||
"id": "app.user.save.existing.app_error",
|
||||
"translation": "Must call update for existing user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.search.app_error",
|
||||
"translation": "Unable to find any user matching the search parameters."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update.find.app_error",
|
||||
"translation": "Unable to find the existing account to update."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update.finding.app_error",
|
||||
"translation": "We encountered an error finding the account."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update_active_for_multiple_users.updating.app_error",
|
||||
"translation": "Unable to deactivate guests."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update_auth_data.app_error",
|
||||
"translation": "Unable to update the auth data."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update_auth_data.email_exists.app_error",
|
||||
"translation": "Unable to switch account to {{.Service}}. An account using the email {{.Email}} already exists."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update_failed_pwd_attempts.app_error",
|
||||
"translation": "Unable to update the failed_attempts."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update_password.app_error",
|
||||
"translation": "Unable to update the user password."
|
||||
},
|
||||
{
|
||||
"id": "app.user.update_update.app_error",
|
||||
"translation": "Unable to update the date of the last update of the user."
|
||||
},
|
||||
{
|
||||
"id": "app.user.verify_email.app_error",
|
||||
"translation": "Unable to update verify email field."
|
||||
},
|
||||
{
|
||||
"id": "app.user_access_token.delete.app_error",
|
||||
"translation": "Unable to delete the personal access token."
|
||||
@@ -7866,262 +7990,14 @@
|
||||
"id": "store.sql_team.save_member.exists.app_error",
|
||||
"translation": "A team member with that ID already exists."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.analytics_daily_active_users.app_error",
|
||||
"translation": "Unable to get the active users during the requested period."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.analytics_get_external_users.app_error",
|
||||
"translation": "We could not count the users with non local domain emails"
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.analytics_get_inactive_users_count.app_error",
|
||||
"translation": "We could not count the inactive users."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.analytics_get_system_admin_count.app_error",
|
||||
"translation": "Unable to get the system admin count."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.app_error",
|
||||
"translation": "Failed to build query."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.clear_all_custom_role_assignments.commit_transaction.app_error",
|
||||
"translation": "Failed to commit the database transaction."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.clear_all_custom_role_assignments.open_transaction.app_error",
|
||||
"translation": "Failed to begin the database transaction."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.clear_all_custom_role_assignments.select.app_error",
|
||||
"translation": "Failed to retrieve the users."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.clear_all_custom_role_assignments.update.app_error",
|
||||
"translation": "Failed to update the user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.count.app_error",
|
||||
"translation": "UserCountOptions don't make sense."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.demote_user_to_guest.channel_members_update.app_error",
|
||||
"translation": "Failed to update the user channels memberships."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.demote_user_to_guest.commit_transaction.app_error",
|
||||
"translation": "Failed to commit the database transaction."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.demote_user_to_guest.open_transaction.app_error",
|
||||
"translation": "Failed to begin the database transaction."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.demote_user_to_guest.team_members_update.app_error",
|
||||
"translation": "Failed to update the user teams memberships."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.demote_user_to_guest.user_update.app_error",
|
||||
"translation": "Failed to update the user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get.app_error",
|
||||
"translation": "We encountered an error finding the account."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_by_auth.missing_account.app_error",
|
||||
"translation": "Unable to find an existing account matching your authentication type for this team. This team may require an invite from the team owner to join."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_by_auth.other.app_error",
|
||||
"translation": "We encountered an error trying to find the account by authentication type."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_by_username.app_error",
|
||||
"translation": "Unable to find an existing account matching your username for this team. This team may require an invite from the team owner to join."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_for_login.app_error",
|
||||
"translation": "Unable to find an existing account matching your credentials. This team may require an invite from the team owner to join."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_for_login.multiple_users",
|
||||
"translation": "We found multiple users matching your credentials and were unable to log you in. Please contact an administrator."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_known_users.get_users.app_error",
|
||||
"translation": "Unable to get know users from the database."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_new_users.app_error",
|
||||
"translation": "We encountered an error while finding the new users."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_profile_by_group_channel_ids_for_user.app_error",
|
||||
"translation": "We encountered an error while finding user profiles."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_profiles.app_error",
|
||||
"translation": "We encountered an error while finding user profiles."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_recently_active_users.app_error",
|
||||
"translation": "We encountered an error while finding the recently active users."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_sysadmin_profiles.app_error",
|
||||
"translation": "We encountered an error while finding user profiles."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_system_install_date.app_error",
|
||||
"translation": "Unable to infer the system date based on the first user creation date."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_total_users_count.app_error",
|
||||
"translation": "We could not count the users."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_unread_count.app_error",
|
||||
"translation": "We could not get the unread message count for the user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_unread_count_for_channel.app_error",
|
||||
"translation": "We could not get the unread message count for the user and channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_users_batch_for_indexing.get_channel_members.app_error",
|
||||
"translation": "Unable to get the channel members for the users batch for indexing."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_users_batch_for_indexing.get_team_members.app_error",
|
||||
"translation": "Unable to get the team members for the users batch for indexing."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.get_users_batch_for_indexing.get_users.app_error",
|
||||
"translation": "Unable to get the users batch for indexing."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.missing_account.const",
|
||||
"translation": "Unable to find the user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.permanent_delete.app_error",
|
||||
"translation": "Unable to delete the existing account."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.promote_guest.channel_members_update.app_error",
|
||||
"translation": "Failed to update the user channels memberships."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.promote_guest.commit_transaction.app_error",
|
||||
"translation": "Failed to commit the database transaction."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.promote_guest.open_transaction.app_error",
|
||||
"translation": "Failed to begin the database transaction."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.promote_guest.team_members_update.app_error",
|
||||
"translation": "Failed to update the user teams memberships."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.promote_guest.user_update.app_error",
|
||||
"translation": "Failed to update the user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.save.app_error",
|
||||
"translation": "Unable to save the account."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.save.email_exists.app_error",
|
||||
"translation": "An account with that email already exists."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.save.existing.app_error",
|
||||
"translation": "Must call update for existing user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.save.username_exists.app_error",
|
||||
"translation": "An account with that username already exists."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.search.app_error",
|
||||
"translation": "Unable to find any user matching the search parameters."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update.app_error",
|
||||
"translation": "Unable to update the account."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update.can_not_change_ldap.app_error",
|
||||
"translation": "Can not change fields set by AD/LDAP."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update.email_taken.app_error",
|
||||
"translation": "This email is already taken. Please choose another."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update.find.app_error",
|
||||
"translation": "Unable to find the existing account to update."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update.finding.app_error",
|
||||
"translation": "We encountered an error finding the account."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update.updating.app_error",
|
||||
"translation": "We encountered an error updating the account."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update.username_taken.app_error",
|
||||
"translation": "This username is already taken. Please choose another."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_active_for_multiple_users.getting_changed_users.app_error",
|
||||
"translation": "Unable to get the list of deactivate guests ids."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_active_for_multiple_users.updating.app_error",
|
||||
"translation": "Unable to deactivate guests."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_auth_data.app_error",
|
||||
"translation": "Unable to update the auth data."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_auth_data.email_exists.app_error",
|
||||
"translation": "Unable to switch account to {{.Service}}. An account using the email {{.Email}} already exists."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_failed_pwd_attempts.app_error",
|
||||
"translation": "Unable to update the failed_attempts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_last_picture_update.app_error",
|
||||
"translation": "Unable to update the update_at."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_mfa_active.app_error",
|
||||
"translation": "We encountered an error updating the user's MFA active status."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_mfa_secret.app_error",
|
||||
"translation": "We encountered an error updating the user's MFA secret."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_password.app_error",
|
||||
"translation": "Unable to update the user password."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.update_update.app_error",
|
||||
"translation": "Unable to update the date of the last update of the user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_user.verify_email.app_error",
|
||||
"translation": "Unable to update verify email field."
|
||||
},
|
||||
{
|
||||
"id": "store.update_error",
|
||||
"translation": "update error"
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
package active_users
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/app"
|
||||
"github.com/mattermost/mattermost-server/v5/jobs"
|
||||
tjobs "github.com/mattermost/mattermost-server/v5/jobs/interfaces"
|
||||
@@ -91,7 +93,7 @@ func (worker *Worker) DoJob(job *model.Job) {
|
||||
|
||||
if err != nil {
|
||||
mlog.Error("Worker: Failed to get active user count", mlog.String("worker", worker.name), mlog.String("job_id", job.Id), mlog.String("error", err.Error()))
|
||||
worker.setJobError(job, err)
|
||||
worker.setJobError(job, model.NewAppError("DoJob", "app.user.get_total_users_count.app_error", nil, err.Error(), http.StatusInternalServerError))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ func (m *Mfa) Deactivate(userId string) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
schan := make(chan *model.AppError, 1)
|
||||
schan := make(chan error, 1)
|
||||
go func() {
|
||||
schan <- m.Store.User().UpdateMfaSecret(userId, "")
|
||||
close(schan)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
package mfa
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -42,8 +42,8 @@ func TestGenerateSecret(t *testing.T) {
|
||||
t.Run("fail on store action fail", func(t *testing.T) {
|
||||
storeMock := mocks.Store{}
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, mock.AnythingOfType("string")).Return(func(userId string, secret string) *model.AppError {
|
||||
return model.NewAppError("GenerateQrCode", "mfa.generate_qr_code.save_secret.app_error", nil, "", http.StatusInternalServerError)
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, mock.AnythingOfType("string")).Return(func(userId string, secret string) error {
|
||||
return errors.New("failed to update mfa secret")
|
||||
})
|
||||
storeMock.On("User").Return(&userStoreMock)
|
||||
|
||||
@@ -56,7 +56,7 @@ func TestGenerateSecret(t *testing.T) {
|
||||
t.Run("Successful generate secret", func(t *testing.T) {
|
||||
storeMock := mocks.Store{}
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, mock.AnythingOfType("string")).Return(func(userId string, secret string) *model.AppError {
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, mock.AnythingOfType("string")).Return(func(userId string, secret string) error {
|
||||
return nil
|
||||
})
|
||||
storeMock.On("User").Return(&userStoreMock)
|
||||
@@ -130,8 +130,8 @@ func TestActivate(t *testing.T) {
|
||||
t.Run("fail on store action fail", func(t *testing.T) {
|
||||
storeMock := mocks.Store{}
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, true).Return(func(userId string, active bool) *model.AppError {
|
||||
return model.NewAppError("Activate", "mfa.activate.save_active.app_error", nil, "", http.StatusInternalServerError)
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, true).Return(func(userId string, active bool) error {
|
||||
return errors.New("failed to update mfa active")
|
||||
})
|
||||
storeMock.On("User").Return(&userStoreMock)
|
||||
|
||||
@@ -144,7 +144,7 @@ func TestActivate(t *testing.T) {
|
||||
t.Run("Successful activate", func(t *testing.T) {
|
||||
storeMock := mocks.Store{}
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, true).Return(func(userId string, active bool) *model.AppError {
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, true).Return(func(userId string, active bool) error {
|
||||
return nil
|
||||
})
|
||||
storeMock.On("User").Return(&userStoreMock)
|
||||
@@ -177,11 +177,11 @@ func TestDeactivate(t *testing.T) {
|
||||
t.Run("fail on store UpdateMfaActive action fail", func(t *testing.T) {
|
||||
storeMock := mocks.Store{}
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, false).Return(func(userId string, active bool) *model.AppError {
|
||||
return model.NewAppError("Deactivate", "mfa.deactivate.save_active.app_error", nil, "", http.StatusInternalServerError)
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, false).Return(func(userId string, active bool) error {
|
||||
return errors.New("failed to update mfa active")
|
||||
})
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, "").Return(func(userId string, secret string) *model.AppError {
|
||||
return model.NewAppError("Deactivate", "mfa.deactivate.save_secret.app_error", nil, "", http.StatusInternalServerError)
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, "").Return(func(userId string, secret string) error {
|
||||
return errors.New("failed to update mfa secret")
|
||||
})
|
||||
storeMock.On("User").Return(&userStoreMock)
|
||||
|
||||
@@ -194,11 +194,11 @@ func TestDeactivate(t *testing.T) {
|
||||
t.Run("fail on store UpdateMfaSecret action fail", func(t *testing.T) {
|
||||
storeMock := mocks.Store{}
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, false).Return(func(userId string, active bool) *model.AppError {
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, false).Return(func(userId string, active bool) error {
|
||||
return nil
|
||||
})
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, "").Return(func(userId string, secret string) *model.AppError {
|
||||
return model.NewAppError("Deactivate", "mfa.deactivate.save_secret.app_error", nil, "", http.StatusInternalServerError)
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, "").Return(func(userId string, secret string) error {
|
||||
return errors.New("failed to update mfa secret")
|
||||
})
|
||||
storeMock.On("User").Return(&userStoreMock)
|
||||
|
||||
@@ -211,10 +211,10 @@ func TestDeactivate(t *testing.T) {
|
||||
t.Run("Successful deactivate", func(t *testing.T) {
|
||||
storeMock := mocks.Store{}
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, false).Return(func(userId string, active bool) *model.AppError {
|
||||
userStoreMock.On("UpdateMfaActive", user.Id, false).Return(func(userId string, active bool) error {
|
||||
return nil
|
||||
})
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, "").Return(func(userId string, secret string) *model.AppError {
|
||||
userStoreMock.On("UpdateMfaSecret", user.Id, "").Return(func(userId string, secret string) error {
|
||||
return nil
|
||||
})
|
||||
storeMock.On("User").Return(&userStoreMock)
|
||||
|
||||
@@ -442,7 +442,7 @@ func (worker *BleveIndexerWorker) IndexUsersBatch(progress IndexingProgress) (In
|
||||
for users == nil {
|
||||
if usersBatch, err := worker.jobServer.Store.User().GetUsersBatchForIndexing(progress.LastEntityTime, endTime, BATCH_SIZE); err != nil {
|
||||
if tries >= 10 {
|
||||
return progress, err
|
||||
return progress, model.NewAppError("IndexUsersBatch", "app.user.get_users_batch_for_indexing.get_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
mlog.Warn("Failed to get users batch for indexing. Retrying.", mlog.Err(err))
|
||||
|
||||
|
||||
@@ -684,17 +684,17 @@ func (si *SlackImporter) oldImportUser(team *model.Team, user *model.User) *mode
|
||||
|
||||
user.Roles = model.SYSTEM_USER_ROLE_ID
|
||||
|
||||
ruser, err := si.store.User().Save(user)
|
||||
if err != nil {
|
||||
mlog.Error("Error saving user.", mlog.Err(err))
|
||||
ruser, nErr := si.store.User().Save(user)
|
||||
if nErr != nil {
|
||||
mlog.Error("Error saving user.", mlog.Err(nErr))
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err = si.store.User().VerifyEmail(ruser.Id, ruser.Email); err != nil {
|
||||
if _, err := si.store.User().VerifyEmail(ruser.Id, ruser.Email); err != nil {
|
||||
mlog.Error("Failed to set email verified.", mlog.Err(err))
|
||||
}
|
||||
|
||||
if err = si.actions.JoinUserToTeam(team, user, ""); err != nil {
|
||||
if err := si.actions.JoinUserToTeam(team, user, ""); err != nil {
|
||||
mlog.Error("Failed to join team when importing.", mlog.Err(err))
|
||||
}
|
||||
|
||||
|
||||
@@ -234,14 +234,14 @@ func (ts *TelemetryService) trackActivity() {
|
||||
activeUsersDailyCountChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err := ts.dbStore.User().AnalyticsActiveCount(DAY_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
activeUsersDailyCountChan <- store.StoreResult{Data: count, Err: err}
|
||||
activeUsersDailyCountChan <- store.StoreResult{Data: count, NErr: err}
|
||||
close(activeUsersDailyCountChan)
|
||||
}()
|
||||
|
||||
activeUsersMonthlyCountChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err := ts.dbStore.User().AnalyticsActiveCount(MONTH_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
activeUsersMonthlyCountChan <- store.StoreResult{Data: count, Err: err}
|
||||
activeUsersMonthlyCountChan <- store.StoreResult{Data: count, NErr: err}
|
||||
close(activeUsersMonthlyCountChan)
|
||||
}()
|
||||
|
||||
@@ -311,12 +311,12 @@ func (ts *TelemetryService) trackActivity() {
|
||||
outgoingWebhooksCount, _ = ts.dbStore.Webhook().AnalyticsOutgoingCount("")
|
||||
|
||||
var activeUsersDailyCount int64
|
||||
if r := <-activeUsersDailyCountChan; r.Err == nil {
|
||||
if r := <-activeUsersDailyCountChan; r.NErr == nil {
|
||||
activeUsersDailyCount = r.Data.(int64)
|
||||
}
|
||||
|
||||
var activeUsersMonthlyCount int64
|
||||
if r := <-activeUsersMonthlyCountChan; r.Err == nil {
|
||||
if r := <-activeUsersMonthlyCountChan; r.NErr == nil {
|
||||
activeUsersMonthlyCount = r.Data.(int64)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ package store
|
||||
const (
|
||||
CHANNEL_EXISTS_ERROR = "store.sql_channel.save_channel.exists.app_error"
|
||||
|
||||
MISSING_ACCOUNT_ERROR = "store.sql_user.missing_account.const"
|
||||
MISSING_AUTH_ACCOUNT_ERROR = "store.sql_user.get_by_auth.missing_account.app_error"
|
||||
|
||||
USER_SEARCH_OPTION_NAMES_ONLY = "names_only"
|
||||
USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME = "names_only_no_full_name"
|
||||
USER_SEARCH_OPTION_ALL_NO_FULL_NAME = "all_no_full_name"
|
||||
|
||||
@@ -71,7 +71,7 @@ func (s LocalCacheUserStore) InvalidateProfilesInChannelCache(channelId string)
|
||||
}
|
||||
}
|
||||
|
||||
func (s LocalCacheUserStore) GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, *model.AppError) {
|
||||
func (s LocalCacheUserStore) GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, error) {
|
||||
if allowFromCache {
|
||||
var cachedMap map[string]*model.User
|
||||
if err := s.rootStore.doStandardReadCache(s.rootStore.profilesInChannelCache, channelId, &cachedMap); err == nil {
|
||||
@@ -91,7 +91,7 @@ func (s LocalCacheUserStore) GetAllProfilesInChannel(channelId string, allowFrom
|
||||
return userMap, nil
|
||||
}
|
||||
|
||||
func (s LocalCacheUserStore) GetProfileByIds(userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, *model.AppError) {
|
||||
func (s LocalCacheUserStore) GetProfileByIds(userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error) {
|
||||
if !allowFromCache {
|
||||
return s.UserStore.GetProfileByIds(userIds, options, false)
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (s LocalCacheUserStore) GetProfileByIds(userIds []string, options *store.Us
|
||||
// It checks if the user entry is present in the cache, returning the entry from cache
|
||||
// if it is present. Otherwise, it fetches the entry from the store and stores it in the
|
||||
// cache.
|
||||
func (s LocalCacheUserStore) Get(id string) (*model.User, *model.AppError) {
|
||||
func (s LocalCacheUserStore) Get(id string) (*model.User, error) {
|
||||
var cacheItem *model.User
|
||||
if err := s.rootStore.doStandardReadCache(s.rootStore.userProfileByIdsCache, id, &cacheItem); err == nil {
|
||||
if s.rootStore.metrics != nil {
|
||||
|
||||
@@ -7985,7 +7985,7 @@ func (s *OpenTracingLayerUploadSessionStore) Update(session *model.UploadSession
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.AnalyticsActiveCount")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8021,7 +8021,7 @@ func (s *OpenTracingLayerUserStore) AnalyticsActiveCountForPeriod(startTime int6
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.AnalyticsGetExternalUsers")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8039,7 +8039,7 @@ func (s *OpenTracingLayerUserStore) AnalyticsGetExternalUsers(hostDomain string)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetGuestCount() (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetGuestCount() (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.AnalyticsGetGuestCount")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8057,7 +8057,7 @@ func (s *OpenTracingLayerUserStore) AnalyticsGetGuestCount() (int64, *model.AppE
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.AnalyticsGetInactiveUsersCount")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8075,7 +8075,7 @@ func (s *OpenTracingLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, *mo
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetSystemAdminCount() (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) AnalyticsGetSystemAdminCount() (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.AnalyticsGetSystemAdminCount")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8093,7 +8093,7 @@ func (s *OpenTracingLayerUserStore) AnalyticsGetSystemAdminCount() (int64, *mode
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.AutocompleteUsersInChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8111,7 +8111,7 @@ func (s *OpenTracingLayerUserStore) AutocompleteUsersInChannel(teamId string, ch
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) ClearAllCustomRoleAssignments() *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) ClearAllCustomRoleAssignments() error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.ClearAllCustomRoleAssignments")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8142,7 +8142,7 @@ func (s *OpenTracingLayerUserStore) ClearCaches() {
|
||||
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) Count(options model.UserCountOptions) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) Count(options model.UserCountOptions) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.Count")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8160,7 +8160,7 @@ func (s *OpenTracingLayerUserStore) Count(options model.UserCountOptions) (int64
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) DeactivateGuests() ([]string, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) DeactivateGuests() ([]string, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.DeactivateGuests")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8178,7 +8178,7 @@ func (s *OpenTracingLayerUserStore) DeactivateGuests() ([]string, *model.AppErro
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) DemoteUserToGuest(userID string) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) DemoteUserToGuest(userID string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.DemoteUserToGuest")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8196,7 +8196,7 @@ func (s *OpenTracingLayerUserStore) DemoteUserToGuest(userID string) *model.AppE
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) Get(id string) (*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) Get(id string) (*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.Get")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8214,7 +8214,7 @@ func (s *OpenTracingLayerUserStore) Get(id string) (*model.User, *model.AppError
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetAll() ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetAll() ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetAll")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8232,7 +8232,7 @@ func (s *OpenTracingLayerUserStore) GetAll() ([]*model.User, *model.AppError) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetAllAfter(limit int, afterId string) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetAllAfter(limit int, afterId string) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetAllAfter")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8250,7 +8250,7 @@ func (s *OpenTracingLayerUserStore) GetAllAfter(limit int, afterId string) ([]*m
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetAllNotInAuthService")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8268,7 +8268,7 @@ func (s *OpenTracingLayerUserStore) GetAllNotInAuthService(authServices []string
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetAllProfiles")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8286,7 +8286,7 @@ func (s *OpenTracingLayerUserStore) GetAllProfiles(options *model.UserGetOptions
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetAllProfilesInChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8304,7 +8304,7 @@ func (s *OpenTracingLayerUserStore) GetAllProfilesInChannel(channelId string, al
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetAllUsingAuthService(authService string) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetAllUsingAuthService(authService string) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetAllUsingAuthService")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8322,7 +8322,7 @@ func (s *OpenTracingLayerUserStore) GetAllUsingAuthService(authService string) (
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetAnyUnreadPostCountForChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8340,7 +8340,7 @@ func (s *OpenTracingLayerUserStore) GetAnyUnreadPostCountForChannel(userId strin
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetByAuth(authData *string, authService string) (*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetByAuth(authData *string, authService string) (*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetByAuth")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8358,7 +8358,7 @@ func (s *OpenTracingLayerUserStore) GetByAuth(authData *string, authService stri
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetByEmail(email string) (*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetByEmail(email string) (*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetByEmail")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8376,7 +8376,7 @@ func (s *OpenTracingLayerUserStore) GetByEmail(email string) (*model.User, *mode
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetByUsername(username string) (*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetByUsername(username string) (*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetByUsername")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8394,7 +8394,7 @@ func (s *OpenTracingLayerUserStore) GetByUsername(username string) (*model.User,
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetChannelGroupUsers")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8451,7 +8451,7 @@ func (s *OpenTracingLayerUserStore) GetEtagForProfilesNotInTeam(teamId string) s
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetForLogin(loginId string, allowSignInWithUsername bool, allowSignInWithEmail bool) (*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetForLogin(loginId string, allowSignInWithUsername bool, allowSignInWithEmail bool) (*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetForLogin")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8469,7 +8469,7 @@ func (s *OpenTracingLayerUserStore) GetForLogin(loginId string, allowSignInWithU
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetKnownUsers(userID string) ([]string, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetKnownUsers(userID string) ([]string, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetKnownUsers")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8487,7 +8487,7 @@ func (s *OpenTracingLayerUserStore) GetKnownUsers(userID string) ([]string, *mod
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetNewUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetNewUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetNewUsersForTeam")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8505,7 +8505,7 @@ func (s *OpenTracingLayerUserStore) GetNewUsersForTeam(teamId string, offset int
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfileByGroupChannelIdsForUser")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8523,7 +8523,7 @@ func (s *OpenTracingLayerUserStore) GetProfileByGroupChannelIdsForUser(userId st
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfileByIds(userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfileByIds(userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfileByIds")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8541,7 +8541,7 @@ func (s *OpenTracingLayerUserStore) GetProfileByIds(userIds []string, options *s
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfiles")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8559,7 +8559,7 @@ func (s *OpenTracingLayerUserStore) GetProfiles(options *model.UserGetOptions) (
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfilesByUsernames")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8577,7 +8577,7 @@ func (s *OpenTracingLayerUserStore) GetProfilesByUsernames(usernames []string, v
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfilesInChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8595,7 +8595,7 @@ func (s *OpenTracingLayerUserStore) GetProfilesInChannel(options *model.UserGetO
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfilesInChannelByStatus")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8613,7 +8613,7 @@ func (s *OpenTracingLayerUserStore) GetProfilesInChannelByStatus(options *model.
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfilesNotInChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8631,7 +8631,7 @@ func (s *OpenTracingLayerUserStore) GetProfilesNotInChannel(teamId string, chann
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfilesNotInTeam")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8649,7 +8649,7 @@ func (s *OpenTracingLayerUserStore) GetProfilesNotInTeam(teamId string, groupCon
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetProfilesWithoutTeam")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8667,7 +8667,7 @@ func (s *OpenTracingLayerUserStore) GetProfilesWithoutTeam(options *model.UserGe
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetRecentlyActiveUsersForTeam")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8685,7 +8685,7 @@ func (s *OpenTracingLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string,
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetSystemAdminProfiles")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8703,7 +8703,7 @@ func (s *OpenTracingLayerUserStore) GetSystemAdminProfiles() (map[string]*model.
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetTeamGroupUsers")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8721,7 +8721,7 @@ func (s *OpenTracingLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.U
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetUnreadCount(userId string) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetUnreadCount(userId string) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetUnreadCount")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8739,7 +8739,7 @@ func (s *OpenTracingLayerUserStore) GetUnreadCount(userId string) (int64, *model
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetUnreadCountForChannel(userId string, channelId string) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetUnreadCountForChannel(userId string, channelId string) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetUnreadCountForChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8757,7 +8757,7 @@ func (s *OpenTracingLayerUserStore) GetUnreadCountForChannel(userId string, chan
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.UserForIndexing, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.GetUsersBatchForIndexing")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8775,7 +8775,7 @@ func (s *OpenTracingLayerUserStore) GetUsersBatchForIndexing(startTime int64, en
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) InferSystemInstallDate() (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) InferSystemInstallDate() (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.InferSystemInstallDate")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8832,7 +8832,7 @@ func (s *OpenTracingLayerUserStore) InvalidateProfilesInChannelCacheByUser(userI
|
||||
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) PermanentDelete(userId string) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) PermanentDelete(userId string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.PermanentDelete")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8850,7 +8850,7 @@ func (s *OpenTracingLayerUserStore) PermanentDelete(userId string) *model.AppErr
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) PromoteGuestToUser(userID string) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) PromoteGuestToUser(userID string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.PromoteGuestToUser")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8868,7 +8868,7 @@ func (s *OpenTracingLayerUserStore) PromoteGuestToUser(userID string) *model.App
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) ResetLastPictureUpdate(userId string) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) ResetLastPictureUpdate(userId string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.ResetLastPictureUpdate")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8886,7 +8886,7 @@ func (s *OpenTracingLayerUserStore) ResetLastPictureUpdate(userId string) *model
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) Save(user *model.User) (*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) Save(user *model.User) (*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.Save")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8904,7 +8904,7 @@ func (s *OpenTracingLayerUserStore) Save(user *model.User) (*model.User, *model.
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.Search")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8922,7 +8922,7 @@ func (s *OpenTracingLayerUserStore) Search(teamId string, term string, options *
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.SearchInChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8940,7 +8940,7 @@ func (s *OpenTracingLayerUserStore) SearchInChannel(channelId string, term strin
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.SearchInGroup")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8958,7 +8958,7 @@ func (s *OpenTracingLayerUserStore) SearchInGroup(groupID string, term string, o
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.SearchNotInChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8976,7 +8976,7 @@ func (s *OpenTracingLayerUserStore) SearchNotInChannel(teamId string, channelId
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.SearchNotInTeam")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -8994,7 +8994,7 @@ func (s *OpenTracingLayerUserStore) SearchNotInTeam(notInTeamId string, term str
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.SearchWithoutTeam")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9012,7 +9012,7 @@ func (s *OpenTracingLayerUserStore) SearchWithoutTeam(term string, options *mode
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.Update")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9030,7 +9030,7 @@ func (s *OpenTracingLayerUserStore) Update(user *model.User, allowRoleUpdate boo
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.UpdateAuthData")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9048,7 +9048,7 @@ func (s *OpenTracingLayerUserStore) UpdateAuthData(userId string, service string
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.UpdateFailedPasswordAttempts")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9066,7 +9066,7 @@ func (s *OpenTracingLayerUserStore) UpdateFailedPasswordAttempts(userId string,
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) UpdateLastPictureUpdate(userId string) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) UpdateLastPictureUpdate(userId string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.UpdateLastPictureUpdate")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9084,7 +9084,7 @@ func (s *OpenTracingLayerUserStore) UpdateLastPictureUpdate(userId string) *mode
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) UpdateMfaActive(userId string, active bool) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) UpdateMfaActive(userId string, active bool) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.UpdateMfaActive")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9102,7 +9102,7 @@ func (s *OpenTracingLayerUserStore) UpdateMfaActive(userId string, active bool)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) UpdateMfaSecret(userId string, secret string) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) UpdateMfaSecret(userId string, secret string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.UpdateMfaSecret")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9120,7 +9120,7 @@ func (s *OpenTracingLayerUserStore) UpdateMfaSecret(userId string, secret string
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) UpdatePassword(userId string, newPassword string) *model.AppError {
|
||||
func (s *OpenTracingLayerUserStore) UpdatePassword(userId string, newPassword string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.UpdatePassword")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9138,7 +9138,7 @@ func (s *OpenTracingLayerUserStore) UpdatePassword(userId string, newPassword st
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) UpdateUpdateAt(userId string) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) UpdateUpdateAt(userId string) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.UpdateUpdateAt")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -9156,7 +9156,7 @@ func (s *OpenTracingLayerUserStore) UpdateUpdateAt(userId string) (int64, *model
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) VerifyEmail(userId string, email string) (string, *model.AppError) {
|
||||
func (s *OpenTracingLayerUserStore) VerifyEmail(userId string, email string) (string, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.VerifyEmail")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -33,7 +33,7 @@ func (s *SearchUserStore) deleteUserIndex(user *model.User) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SearchUserStore) Search(teamId, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *SearchUserStore) Search(teamId, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
for _, engine := range s.rootStore.searchEngine.GetActiveEngines() {
|
||||
if engine.IsSearchEnabled() {
|
||||
listOfAllowedChannels, err := s.getListOfAllowedChannelsForTeam(teamId, options.ViewRestrictions)
|
||||
@@ -54,9 +54,9 @@ func (s *SearchUserStore) Search(teamId, term string, options *model.UserSearchO
|
||||
continue
|
||||
}
|
||||
|
||||
users, err := s.UserStore.GetProfileByIds(usersIds, nil, false)
|
||||
if err != nil {
|
||||
mlog.Error("Encountered error on Search", mlog.String("search_engine", engine.GetName()), mlog.Err(err))
|
||||
users, nErr := s.UserStore.GetProfileByIds(usersIds, nil, false)
|
||||
if nErr != nil {
|
||||
mlog.Error("Encountered error on Search", mlog.String("search_engine", engine.GetName()), mlog.Err(nErr))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func (s *SearchUserStore) Search(teamId, term string, options *model.UserSearchO
|
||||
return s.UserStore.Search(teamId, term, options)
|
||||
}
|
||||
|
||||
func (s *SearchUserStore) Update(user *model.User, trustedUpdateData bool) (*model.UserUpdate, *model.AppError) {
|
||||
func (s *SearchUserStore) Update(user *model.User, trustedUpdateData bool) (*model.UserUpdate, error) {
|
||||
userUpdate, err := s.UserStore.Update(user, trustedUpdateData)
|
||||
|
||||
if err == nil {
|
||||
@@ -79,7 +79,7 @@ func (s *SearchUserStore) Update(user *model.User, trustedUpdateData bool) (*mod
|
||||
return userUpdate, err
|
||||
}
|
||||
|
||||
func (s *SearchUserStore) Save(user *model.User) (*model.User, *model.AppError) {
|
||||
func (s *SearchUserStore) Save(user *model.User) (*model.User, error) {
|
||||
nuser, err := s.UserStore.Save(user)
|
||||
|
||||
if err == nil {
|
||||
@@ -88,7 +88,7 @@ func (s *SearchUserStore) Save(user *model.User) (*model.User, *model.AppError)
|
||||
return nuser, err
|
||||
}
|
||||
|
||||
func (s *SearchUserStore) PermanentDelete(userId string) *model.AppError {
|
||||
func (s *SearchUserStore) PermanentDelete(userId string) error {
|
||||
user, userErr := s.UserStore.Get(userId)
|
||||
if userErr != nil {
|
||||
mlog.Error("Encountered error deleting user", mlog.String("user_id", userId), mlog.Err(userErr))
|
||||
@@ -117,29 +117,29 @@ func (s *SearchUserStore) autocompleteUsersInChannelByEngine(engine searchengine
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
users, err := s.UserStore.GetProfileByIds(uchanIds, nil, false)
|
||||
uchan <- store.StoreResult{Data: users, Err: err}
|
||||
uchan <- store.StoreResult{Data: users, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
nuchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
users, err := s.UserStore.GetProfileByIds(nuchanIds, nil, false)
|
||||
nuchan <- store.StoreResult{Data: users, Err: err}
|
||||
nuchan <- store.StoreResult{Data: users, NErr: err}
|
||||
close(nuchan)
|
||||
}()
|
||||
|
||||
autocomplete := &model.UserAutocompleteInChannel{}
|
||||
|
||||
result := <-uchan
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
return nil, model.NewAppError("autocompleteUsersInChannelByEngine", "app.user.get_profiles.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
inUsers := result.Data.([]*model.User)
|
||||
autocomplete.InChannel = inUsers
|
||||
|
||||
result = <-nuchan
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
return nil, model.NewAppError("autocompleteUsersInChannelByEngine", "app.user.get_profiles.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
outUsers := result.Data.([]*model.User)
|
||||
autocomplete.OutOfChannel = outUsers
|
||||
@@ -198,7 +198,7 @@ func (s *SearchUserStore) getListOfAllowedChannelsForTeam(teamId string, viewRes
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (s *SearchUserStore) AutocompleteUsersInChannel(teamId, channelId, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
func (s *SearchUserStore) AutocompleteUsersInChannel(teamId, channelId, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) {
|
||||
for _, engine := range s.rootStore.searchEngine.GetActiveEngines() {
|
||||
if engine.IsAutocompletionEnabled() {
|
||||
listOfAllowedChannels, err := s.getListOfAllowedChannelsForTeam(teamId, options.ViewRestrictions)
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
120
store/store.go
120
store/store.go
@@ -304,74 +304,74 @@ type PostStore interface {
|
||||
}
|
||||
|
||||
type UserStore interface {
|
||||
Save(user *model.User) (*model.User, *model.AppError)
|
||||
Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, *model.AppError)
|
||||
UpdateLastPictureUpdate(userId string) *model.AppError
|
||||
ResetLastPictureUpdate(userId string) *model.AppError
|
||||
UpdatePassword(userId, newPassword string) *model.AppError
|
||||
UpdateUpdateAt(userId string) (int64, *model.AppError)
|
||||
UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, *model.AppError)
|
||||
UpdateMfaSecret(userId, secret string) *model.AppError
|
||||
UpdateMfaActive(userId string, active bool) *model.AppError
|
||||
Get(id string) (*model.User, *model.AppError)
|
||||
GetAll() ([]*model.User, *model.AppError)
|
||||
Save(user *model.User) (*model.User, error)
|
||||
Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error)
|
||||
UpdateLastPictureUpdate(userId string) error
|
||||
ResetLastPictureUpdate(userId string) error
|
||||
UpdatePassword(userId, newPassword string) error
|
||||
UpdateUpdateAt(userId string) (int64, error)
|
||||
UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, error)
|
||||
UpdateMfaSecret(userId, secret string) error
|
||||
UpdateMfaActive(userId string, active bool) error
|
||||
Get(id string) (*model.User, error)
|
||||
GetAll() ([]*model.User, error)
|
||||
ClearCaches()
|
||||
InvalidateProfilesInChannelCacheByUser(userId string)
|
||||
InvalidateProfilesInChannelCache(channelId string)
|
||||
GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, *model.AppError)
|
||||
GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetAllProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError)
|
||||
GetProfileByIds(userIds []string, options *UserGetByIdsOpts, allowFromCache bool) ([]*model.User, *model.AppError)
|
||||
GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, *model.AppError)
|
||||
GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, error)
|
||||
GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, error)
|
||||
GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, error)
|
||||
GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
|
||||
GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, error)
|
||||
GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
|
||||
GetAllProfiles(options *model.UserGetOptions) ([]*model.User, error)
|
||||
GetProfiles(options *model.UserGetOptions) ([]*model.User, error)
|
||||
GetProfileByIds(userIds []string, options *UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error)
|
||||
GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, error)
|
||||
InvalidateProfileCacheForUser(userId string)
|
||||
GetByEmail(email string) (*model.User, *model.AppError)
|
||||
GetByAuth(authData *string, authService string) (*model.User, *model.AppError)
|
||||
GetAllUsingAuthService(authService string) ([]*model.User, *model.AppError)
|
||||
GetAllNotInAuthService(authServices []string) ([]*model.User, *model.AppError)
|
||||
GetByUsername(username string) (*model.User, *model.AppError)
|
||||
GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail bool) (*model.User, *model.AppError)
|
||||
VerifyEmail(userId, email string) (string, *model.AppError)
|
||||
GetByEmail(email string) (*model.User, error)
|
||||
GetByAuth(authData *string, authService string) (*model.User, error)
|
||||
GetAllUsingAuthService(authService string) ([]*model.User, error)
|
||||
GetAllNotInAuthService(authServices []string) ([]*model.User, error)
|
||||
GetByUsername(username string) (*model.User, error)
|
||||
GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail bool) (*model.User, error)
|
||||
VerifyEmail(userId, email string) (string, error)
|
||||
GetEtagForAllProfiles() string
|
||||
GetEtagForProfiles(teamId string) string
|
||||
UpdateFailedPasswordAttempts(userId string, attempts int) *model.AppError
|
||||
GetSystemAdminProfiles() (map[string]*model.User, *model.AppError)
|
||||
PermanentDelete(userId string) *model.AppError
|
||||
AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, *model.AppError)
|
||||
UpdateFailedPasswordAttempts(userId string, attempts int) error
|
||||
GetSystemAdminProfiles() (map[string]*model.User, error)
|
||||
PermanentDelete(userId string) error
|
||||
AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, error)
|
||||
AnalyticsActiveCountForPeriod(startTime int64, endTime int64, options model.UserCountOptions) (int64, error)
|
||||
GetUnreadCount(userId string) (int64, *model.AppError)
|
||||
GetUnreadCountForChannel(userId string, channelId string) (int64, *model.AppError)
|
||||
GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetNewUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
AnalyticsGetInactiveUsersCount() (int64, *model.AppError)
|
||||
AnalyticsGetExternalUsers(hostDomain string) (bool, *model.AppError)
|
||||
AnalyticsGetSystemAdminCount() (int64, *model.AppError)
|
||||
AnalyticsGetGuestCount() (int64, *model.AppError)
|
||||
GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetUnreadCount(userId string) (int64, error)
|
||||
GetUnreadCountForChannel(userId string, channelId string) (int64, error)
|
||||
GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, error)
|
||||
GetRecentlyActiveUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
|
||||
GetNewUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
|
||||
Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
|
||||
SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
|
||||
SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
|
||||
SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
|
||||
SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, error)
|
||||
SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, error)
|
||||
AnalyticsGetInactiveUsersCount() (int64, error)
|
||||
AnalyticsGetExternalUsers(hostDomain string) (bool, error)
|
||||
AnalyticsGetSystemAdminCount() (int64, error)
|
||||
AnalyticsGetGuestCount() (int64, error)
|
||||
GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
|
||||
GetEtagForProfilesNotInTeam(teamId string) string
|
||||
ClearAllCustomRoleAssignments() *model.AppError
|
||||
InferSystemInstallDate() (int64, *model.AppError)
|
||||
GetAllAfter(limit int, afterId string) ([]*model.User, *model.AppError)
|
||||
GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError)
|
||||
Count(options model.UserCountOptions) (int64, *model.AppError)
|
||||
GetTeamGroupUsers(teamID string) ([]*model.User, *model.AppError)
|
||||
GetChannelGroupUsers(channelID string) ([]*model.User, *model.AppError)
|
||||
PromoteGuestToUser(userID string) *model.AppError
|
||||
DemoteUserToGuest(userID string) *model.AppError
|
||||
DeactivateGuests() ([]string, *model.AppError)
|
||||
AutocompleteUsersInChannel(teamId, channelId, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError)
|
||||
GetKnownUsers(userID string) ([]string, *model.AppError)
|
||||
ClearAllCustomRoleAssignments() error
|
||||
InferSystemInstallDate() (int64, error)
|
||||
GetAllAfter(limit int, afterId string) ([]*model.User, error)
|
||||
GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, error)
|
||||
Count(options model.UserCountOptions) (int64, error)
|
||||
GetTeamGroupUsers(teamID string) ([]*model.User, error)
|
||||
GetChannelGroupUsers(channelID string) ([]*model.User, error)
|
||||
PromoteGuestToUser(userID string) error
|
||||
DemoteUserToGuest(userID string) error
|
||||
DeactivateGuests() ([]string, error)
|
||||
AutocompleteUsersInChannel(teamId, channelId, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error)
|
||||
GetKnownUsers(userID string) ([]string, error)
|
||||
}
|
||||
|
||||
type BotStore interface {
|
||||
|
||||
@@ -4470,8 +4470,8 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
DeleteAt: 0,
|
||||
}
|
||||
_, err = ss.User().Save(u1)
|
||||
require.Nil(t, err)
|
||||
_, nErr = ss.User().Save(u1)
|
||||
require.Nil(t, nErr)
|
||||
_, nErr = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
@@ -4541,8 +4541,8 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
DeleteAt: 0,
|
||||
}
|
||||
_, err = ss.User().Save(u)
|
||||
require.Nil(t, err)
|
||||
_, nErr = ss.User().Save(u)
|
||||
require.Nil(t, nErr)
|
||||
_, nErr = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u.Id}, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
@@ -4592,8 +4592,8 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
DeleteAt: 0,
|
||||
}
|
||||
_, err = ss.User().Save(u)
|
||||
require.Nil(t, err)
|
||||
_, nErr = ss.User().Save(u)
|
||||
require.Nil(t, nErr)
|
||||
_, nErr = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u.Id}, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
|
||||
@@ -374,8 +374,8 @@ func testGroupStoreGetByUser(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
u1, err = ss.User().Save(u1)
|
||||
require.Nil(t, err)
|
||||
u1, nErr := ss.User().Save(u1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(g1.Id, u1.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -386,8 +386,8 @@ func testGroupStoreGetByUser(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
u2, err = ss.User().Save(u2)
|
||||
require.Nil(t, err)
|
||||
u2, nErr = ss.User().Save(u2)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(g2.Id, u2.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -571,8 +571,8 @@ func testGroupGetMemberUsers(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user1, err := ss.User().Save(u1)
|
||||
require.Nil(t, err)
|
||||
user1, nErr := ss.User().Save(u1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(group.Id, user1.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -581,8 +581,8 @@ func testGroupGetMemberUsers(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user2, err := ss.User().Save(u2)
|
||||
require.Nil(t, err)
|
||||
user2, nErr := ss.User().Save(u2)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(group.Id, user2.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -623,8 +623,8 @@ func testGroupGetMemberUsersPage(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user1, err := ss.User().Save(u1)
|
||||
require.Nil(t, err)
|
||||
user1, nErr := ss.User().Save(u1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(group.Id, user1.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -633,8 +633,8 @@ func testGroupGetMemberUsersPage(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user2, err := ss.User().Save(u2)
|
||||
require.Nil(t, err)
|
||||
user2, nErr := ss.User().Save(u2)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(group.Id, user2.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -643,8 +643,8 @@ func testGroupGetMemberUsersPage(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user3, err := ss.User().Save(u3)
|
||||
require.Nil(t, err)
|
||||
user3, nErr := ss.User().Save(u3)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(group.Id, user3.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -923,8 +923,8 @@ func testUpsertMember(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user, err := ss.User().Save(u1)
|
||||
require.Nil(t, err)
|
||||
user, nErr := ss.User().Save(u1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Happy path
|
||||
d2, err := ss.Group().UpsertMember(group.Id, user.Id)
|
||||
@@ -981,8 +981,8 @@ func testGroupDeleteMember(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user, err := ss.User().Save(u1)
|
||||
require.Nil(t, err)
|
||||
user, nErr := ss.User().Save(u1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create member
|
||||
d1, err := ss.Group().UpsertMember(group.Id, user.Id)
|
||||
@@ -1321,8 +1321,8 @@ func testTeamMembersToAdd(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user, err = ss.User().Save(user)
|
||||
require.Nil(t, err)
|
||||
user, nErr := ss.User().Save(user)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create GroupMember
|
||||
_, err = ss.Group().UpsertMember(group.Id, user.Id)
|
||||
@@ -1339,7 +1339,7 @@ func testTeamMembersToAdd(t *testing.T, ss store.Store) {
|
||||
Email: "success+" + model.NewId() + "@simulator.amazonses.com",
|
||||
Type: model.TEAM_OPEN,
|
||||
}
|
||||
team, nErr := ss.Team().Save(team)
|
||||
team, nErr = ss.Team().Save(team)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create GroupTeam
|
||||
@@ -1490,22 +1490,22 @@ func testTeamMembersToAddSingleTeam(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user1, err = ss.User().Save(user1)
|
||||
require.Nil(t, err)
|
||||
user1, nErr := ss.User().Save(user1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
user2 := &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user2, err = ss.User().Save(user2)
|
||||
require.Nil(t, err)
|
||||
user2, nErr = ss.User().Save(user2)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
user3 := &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user3, err = ss.User().Save(user3)
|
||||
require.Nil(t, err)
|
||||
user3, nErr = ss.User().Save(user3)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
for _, user := range []*model.User{user1, user2} {
|
||||
_, err = ss.Group().UpsertMember(group1.Id, user.Id)
|
||||
@@ -1524,7 +1524,7 @@ func testTeamMembersToAddSingleTeam(t *testing.T, ss store.Store) {
|
||||
Email: "success+" + model.NewId() + "@simulator.amazonses.com",
|
||||
Type: model.TEAM_OPEN,
|
||||
}
|
||||
team1, nErr := ss.Team().Save(team1)
|
||||
team1, nErr = ss.Team().Save(team1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
team2 := &model.Team{
|
||||
@@ -1574,8 +1574,8 @@ func testChannelMembersToAdd(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user, err = ss.User().Save(user)
|
||||
require.Nil(t, err)
|
||||
user, nErr := ss.User().Save(user)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create GroupMember
|
||||
_, err = ss.Group().UpsertMember(group.Id, user.Id)
|
||||
@@ -1588,7 +1588,7 @@ func testChannelMembersToAdd(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN, // Query does not look at type so this shouldn't matter.
|
||||
}
|
||||
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||
channel, nErr = ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create GroupChannel
|
||||
@@ -1749,22 +1749,22 @@ func testChannelMembersToAddSingleChannel(t *testing.T, ss store.Store) {
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user1, err = ss.User().Save(user1)
|
||||
require.Nil(t, err)
|
||||
user1, nErr := ss.User().Save(user1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
user2 := &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user2, err = ss.User().Save(user2)
|
||||
require.Nil(t, err)
|
||||
user2, nErr = ss.User().Save(user2)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
user3 := &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
user3, err = ss.User().Save(user3)
|
||||
require.Nil(t, err)
|
||||
user3, nErr = ss.User().Save(user3)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
for _, user := range []*model.User{user1, user2} {
|
||||
_, err = ss.Group().UpsertMember(group1.Id, user.Id)
|
||||
@@ -1778,7 +1778,7 @@ func testChannelMembersToAddSingleChannel(t *testing.T, ss store.Store) {
|
||||
Name: "z-z-" + model.NewId() + "a",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel1, nErr := ss.Channel().Save(channel1, 999)
|
||||
channel1, nErr = ss.Channel().Save(channel1, 999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
channel2 := &model.Channel{
|
||||
@@ -2131,24 +2131,24 @@ func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
userA, err = ss.User().Save(userA)
|
||||
require.Nil(t, err)
|
||||
userA, nErr := ss.User().Save(userA)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// userB will not get removed from the group
|
||||
userB := &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
userB, err = ss.User().Save(userB)
|
||||
require.Nil(t, err)
|
||||
userB, nErr = ss.User().Save(userB)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// userC was never in the group
|
||||
userC := &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
userC, err = ss.User().Save(userC)
|
||||
require.Nil(t, err)
|
||||
userC, nErr = ss.User().Save(userC)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// add users to group (but not userC)
|
||||
_, err = ss.Group().UpsertMember(group.Id, userA.Id)
|
||||
@@ -2165,7 +2165,7 @@ func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
GroupConstrained: model.NewBool(true),
|
||||
}
|
||||
channelConstrained, nErr := ss.Channel().Save(channelConstrained, 9999)
|
||||
channelConstrained, nErr = ss.Channel().Save(channelConstrained, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
channelUnconstrained := &model.Channel{
|
||||
@@ -3747,14 +3747,14 @@ func groupTestGetMemberCount(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
var user *model.User
|
||||
|
||||
var nErr error
|
||||
for i := 0; i < 2; i++ {
|
||||
user = &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: fmt.Sprintf("%d_%s", i, model.NewId()),
|
||||
}
|
||||
user, err = ss.User().Save(user)
|
||||
require.Nil(t, err)
|
||||
user, nErr = ss.User().Save(user)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().UpsertMember(group.Id, user.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -3765,8 +3765,8 @@ func groupTestGetMemberCount(t *testing.T, ss store.Store) {
|
||||
require.Equal(t, int64(2), count)
|
||||
|
||||
user.DeleteAt = 1
|
||||
_, err = ss.User().Update(user, true)
|
||||
require.Nil(t, err)
|
||||
_, nErr = ss.User().Update(user, true)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
count, err = ss.Group().GetMemberCount(group.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -2785,17 +2785,17 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, int(totalMemberCount), maxUsersPerTeam, "should start with 5 team members, had %v instead", totalMemberCount)
|
||||
|
||||
user, err := ss.User().Save(&model.User{
|
||||
user, nErr := ss.User().Save(&model.User{
|
||||
Username: model.NewId(),
|
||||
Email: MakeEmail(),
|
||||
})
|
||||
require.Nil(t, err)
|
||||
require.Nil(t, nErr)
|
||||
newUserId := user.Id
|
||||
defer func() {
|
||||
ss.User().PermanentDelete(newUserId)
|
||||
}()
|
||||
|
||||
_, nErr := ss.Team().SaveMember(&model.TeamMember{
|
||||
_, nErr = ss.Team().SaveMember(&model.TeamMember{
|
||||
TeamId: team.Id,
|
||||
UserId: newUserId,
|
||||
}, maxUsersPerTeam)
|
||||
@@ -2827,17 +2827,17 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
|
||||
require.Equal(t, maxUsersPerTeam, int(totalMemberCount), "should have 5 team members again, had %v instead", totalMemberCount)
|
||||
|
||||
// Deactivating a user should make them stop counting against max members
|
||||
user2, err := ss.User().Get(userIds[1])
|
||||
require.Nil(t, err)
|
||||
user2, nErr := ss.User().Get(userIds[1])
|
||||
require.Nil(t, nErr)
|
||||
user2.DeleteAt = 1234
|
||||
_, err = ss.User().Update(user2, true)
|
||||
require.Nil(t, err)
|
||||
_, nErr = ss.User().Update(user2, true)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
user, err = ss.User().Save(&model.User{
|
||||
user, nErr = ss.User().Save(&model.User{
|
||||
Username: model.NewId(),
|
||||
Email: MakeEmail(),
|
||||
})
|
||||
require.Nil(t, err)
|
||||
require.Nil(t, nErr)
|
||||
newUserId2 := user.Id
|
||||
_, nErr = ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId2}, maxUsersPerTeam)
|
||||
require.Nil(t, nErr, "should've been able to save new member after deleting one")
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package storetest
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -1788,13 +1789,11 @@ func testUserStoreGetByEmail(t *testing.T, ss store.Store) {
|
||||
t.Run("get by empty email", func(t *testing.T) {
|
||||
_, err := ss.User().GetByEmail("")
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, store.MISSING_ACCOUNT_ERROR)
|
||||
})
|
||||
|
||||
t.Run("get by unknown", func(t *testing.T) {
|
||||
_, err := ss.User().GetByEmail("unknown")
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, store.MISSING_ACCOUNT_ERROR)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1857,21 +1856,24 @@ func testUserStoreGetByAuthData(t *testing.T, ss store.Store) {
|
||||
t.Run("get by u1 auth, unknown service", func(t *testing.T) {
|
||||
_, err := ss.User().GetByAuth(u1.AuthData, "unknown")
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, store.MISSING_AUTH_ACCOUNT_ERROR)
|
||||
var nfErr *store.ErrNotFound
|
||||
require.True(t, errors.As(err, &nfErr))
|
||||
})
|
||||
|
||||
t.Run("get by unknown auth, u1 service", func(t *testing.T) {
|
||||
unknownAuth := ""
|
||||
_, err := ss.User().GetByAuth(&unknownAuth, u1.AuthService)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, store.MISSING_AUTH_ACCOUNT_ERROR)
|
||||
var invErr *store.ErrInvalidInput
|
||||
require.True(t, errors.As(err, &invErr))
|
||||
})
|
||||
|
||||
t.Run("get by unknown auth, unknown service", func(t *testing.T) {
|
||||
unknownAuth := ""
|
||||
_, err := ss.User().GetByAuth(&unknownAuth, "unknown")
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, store.MISSING_AUTH_ACCOUNT_ERROR)
|
||||
var invErr *store.ErrInvalidInput
|
||||
require.True(t, errors.As(err, &invErr))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1934,13 +1936,15 @@ func testUserStoreGetByUsername(t *testing.T, ss store.Store) {
|
||||
t.Run("get by empty username", func(t *testing.T) {
|
||||
_, err := ss.User().GetByUsername("")
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "store.sql_user.get_by_username.app_error")
|
||||
var nfErr *store.ErrNotFound
|
||||
require.True(t, errors.As(err, &nfErr))
|
||||
})
|
||||
|
||||
t.Run("get by unknown", func(t *testing.T) {
|
||||
_, err := ss.User().GetByUsername("unknown")
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "store.sql_user.get_by_username.app_error")
|
||||
var nfErr *store.ErrNotFound
|
||||
require.True(t, errors.As(err, &nfErr))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2007,7 +2011,7 @@ func testUserStoreGetForLogin(t *testing.T, ss store.Store) {
|
||||
t.Run("get u1 by username, allow only email", func(t *testing.T) {
|
||||
_, err := ss.User().GetForLogin(u1.Username, false, true)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "store.sql_user.get_for_login.app_error")
|
||||
require.Equal(t, "user not found", err.Error())
|
||||
})
|
||||
|
||||
t.Run("get u1 by email, allow both", func(t *testing.T) {
|
||||
@@ -2025,7 +2029,7 @@ func testUserStoreGetForLogin(t *testing.T, ss store.Store) {
|
||||
t.Run("get u1 by email, allow only username", func(t *testing.T) {
|
||||
_, err := ss.User().GetForLogin(u1.Email, true, false)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "store.sql_user.get_for_login.app_error")
|
||||
require.Equal(t, "user not found", err.Error())
|
||||
})
|
||||
|
||||
t.Run("get u2 by username, allow both", func(t *testing.T) {
|
||||
@@ -2043,7 +2047,7 @@ func testUserStoreGetForLogin(t *testing.T, ss store.Store) {
|
||||
t.Run("get u2 by username, allow neither", func(t *testing.T) {
|
||||
_, err := ss.User().GetForLogin(u2.Username, false, false)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "store.sql_user.get_for_login.app_error")
|
||||
require.Equal(t, "sign in with username and email are disabled", err.Error())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3949,12 +3953,12 @@ func testUserStoreAnalyticsGetSystemAdminCount(t *testing.T, ss store.Store) {
|
||||
u2.Email = MakeEmail()
|
||||
u2.Username = model.NewId()
|
||||
|
||||
_, err = ss.User().Save(&u1)
|
||||
require.Nil(t, err, "couldn't save user")
|
||||
_, nErr := ss.User().Save(&u1)
|
||||
require.Nil(t, nErr, "couldn't save user")
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u1.Id)) }()
|
||||
|
||||
_, err = ss.User().Save(&u2)
|
||||
require.Nil(t, err, "couldn't save user")
|
||||
_, nErr = ss.User().Save(&u2)
|
||||
require.Nil(t, nErr, "couldn't save user")
|
||||
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u2.Id)) }()
|
||||
|
||||
@@ -3983,16 +3987,16 @@ func testUserStoreAnalyticsGetGuestCount(t *testing.T, ss store.Store) {
|
||||
u3.Username = model.NewId()
|
||||
u3.Roles = "system_guest"
|
||||
|
||||
_, err = ss.User().Save(&u1)
|
||||
require.Nil(t, err, "couldn't save user")
|
||||
_, nErr := ss.User().Save(&u1)
|
||||
require.Nil(t, nErr, "couldn't save user")
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u1.Id)) }()
|
||||
|
||||
_, err = ss.User().Save(&u2)
|
||||
require.Nil(t, err, "couldn't save user")
|
||||
_, nErr = ss.User().Save(&u2)
|
||||
require.Nil(t, nErr, "couldn't save user")
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u2.Id)) }()
|
||||
|
||||
_, err = ss.User().Save(&u3)
|
||||
require.Nil(t, err, "couldn't save user")
|
||||
_, nErr = ss.User().Save(&u3)
|
||||
require.Nil(t, nErr, "couldn't save user")
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u3.Id)) }()
|
||||
|
||||
result, err := ss.User().AnalyticsGetGuestCount()
|
||||
|
||||
@@ -7207,7 +7207,7 @@ func (s *TimerLayerUploadSessionStore) Update(session *model.UploadSession) erro
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.AnalyticsActiveCount(time, options)
|
||||
@@ -7239,7 +7239,7 @@ func (s *TimerLayerUserStore) AnalyticsActiveCountForPeriod(startTime int64, end
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.AnalyticsGetExternalUsers(hostDomain)
|
||||
@@ -7255,7 +7255,7 @@ func (s *TimerLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) AnalyticsGetGuestCount() (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) AnalyticsGetGuestCount() (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.AnalyticsGetGuestCount()
|
||||
@@ -7271,7 +7271,7 @@ func (s *TimerLayerUserStore) AnalyticsGetGuestCount() (int64, *model.AppError)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.AnalyticsGetInactiveUsersCount()
|
||||
@@ -7287,7 +7287,7 @@ func (s *TimerLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, *model.Ap
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) AnalyticsGetSystemAdminCount() (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) AnalyticsGetSystemAdminCount() (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.AnalyticsGetSystemAdminCount()
|
||||
@@ -7303,7 +7303,7 @@ func (s *TimerLayerUserStore) AnalyticsGetSystemAdminCount() (int64, *model.AppE
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.AutocompleteUsersInChannel(teamId, channelId, term, options)
|
||||
@@ -7319,7 +7319,7 @@ func (s *TimerLayerUserStore) AutocompleteUsersInChannel(teamId string, channelI
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) ClearAllCustomRoleAssignments() *model.AppError {
|
||||
func (s *TimerLayerUserStore) ClearAllCustomRoleAssignments() error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.ClearAllCustomRoleAssignments()
|
||||
@@ -7350,7 +7350,7 @@ func (s *TimerLayerUserStore) ClearCaches() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) Count(options model.UserCountOptions) (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) Count(options model.UserCountOptions) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.Count(options)
|
||||
@@ -7366,7 +7366,7 @@ func (s *TimerLayerUserStore) Count(options model.UserCountOptions) (int64, *mod
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) DeactivateGuests() ([]string, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) DeactivateGuests() ([]string, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.DeactivateGuests()
|
||||
@@ -7382,7 +7382,7 @@ func (s *TimerLayerUserStore) DeactivateGuests() ([]string, *model.AppError) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) DemoteUserToGuest(userID string) *model.AppError {
|
||||
func (s *TimerLayerUserStore) DemoteUserToGuest(userID string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.DemoteUserToGuest(userID)
|
||||
@@ -7398,7 +7398,7 @@ func (s *TimerLayerUserStore) DemoteUserToGuest(userID string) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) Get(id string) (*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) Get(id string) (*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.Get(id)
|
||||
@@ -7414,7 +7414,7 @@ func (s *TimerLayerUserStore) Get(id string) (*model.User, *model.AppError) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetAll() ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetAll() ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetAll()
|
||||
@@ -7430,7 +7430,7 @@ func (s *TimerLayerUserStore) GetAll() ([]*model.User, *model.AppError) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetAllAfter(limit int, afterId string) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetAllAfter(limit int, afterId string) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetAllAfter(limit, afterId)
|
||||
@@ -7446,7 +7446,7 @@ func (s *TimerLayerUserStore) GetAllAfter(limit int, afterId string) ([]*model.U
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetAllNotInAuthService(authServices)
|
||||
@@ -7462,7 +7462,7 @@ func (s *TimerLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetAllProfiles(options)
|
||||
@@ -7478,7 +7478,7 @@ func (s *TimerLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetAllProfilesInChannel(channelId string, allowFromCache bool) (map[string]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetAllProfilesInChannel(channelId, allowFromCache)
|
||||
@@ -7494,7 +7494,7 @@ func (s *TimerLayerUserStore) GetAllProfilesInChannel(channelId string, allowFro
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetAllUsingAuthService(authService string) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetAllUsingAuthService(authService string) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetAllUsingAuthService(authService)
|
||||
@@ -7510,7 +7510,7 @@ func (s *TimerLayerUserStore) GetAllUsingAuthService(authService string) ([]*mod
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetAnyUnreadPostCountForChannel(userId, channelId)
|
||||
@@ -7526,7 +7526,7 @@ func (s *TimerLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, cha
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetByAuth(authData *string, authService string) (*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetByAuth(authData *string, authService string) (*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetByAuth(authData, authService)
|
||||
@@ -7542,7 +7542,7 @@ func (s *TimerLayerUserStore) GetByAuth(authData *string, authService string) (*
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetByEmail(email string) (*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetByEmail(email string) (*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetByEmail(email)
|
||||
@@ -7558,7 +7558,7 @@ func (s *TimerLayerUserStore) GetByEmail(email string) (*model.User, *model.AppE
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetByUsername(username string) (*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetByUsername(username string) (*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetByUsername(username)
|
||||
@@ -7574,7 +7574,7 @@ func (s *TimerLayerUserStore) GetByUsername(username string) (*model.User, *mode
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetChannelGroupUsers(channelID)
|
||||
@@ -7638,7 +7638,7 @@ func (s *TimerLayerUserStore) GetEtagForProfilesNotInTeam(teamId string) string
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetForLogin(loginId string, allowSignInWithUsername bool, allowSignInWithEmail bool) (*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetForLogin(loginId string, allowSignInWithUsername bool, allowSignInWithEmail bool) (*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetForLogin(loginId, allowSignInWithUsername, allowSignInWithEmail)
|
||||
@@ -7654,7 +7654,7 @@ func (s *TimerLayerUserStore) GetForLogin(loginId string, allowSignInWithUsernam
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetKnownUsers(userID string) ([]string, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetKnownUsers(userID string) ([]string, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetKnownUsers(userID)
|
||||
@@ -7670,7 +7670,7 @@ func (s *TimerLayerUserStore) GetKnownUsers(userID string) ([]string, *model.App
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetNewUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetNewUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetNewUsersForTeam(teamId, offset, limit, viewRestrictions)
|
||||
@@ -7686,7 +7686,7 @@ func (s *TimerLayerUserStore) GetNewUsersForTeam(teamId string, offset int, limi
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfileByGroupChannelIdsForUser(userId, channelIds)
|
||||
@@ -7702,7 +7702,7 @@ func (s *TimerLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string,
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfileByIds(userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfileByIds(userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfileByIds(userIds, options, allowFromCache)
|
||||
@@ -7718,7 +7718,7 @@ func (s *TimerLayerUserStore) GetProfileByIds(userIds []string, options *store.U
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfiles(options)
|
||||
@@ -7734,7 +7734,7 @@ func (s *TimerLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*mod
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfilesByUsernames(usernames, viewRestrictions)
|
||||
@@ -7750,7 +7750,7 @@ func (s *TimerLayerUserStore) GetProfilesByUsernames(usernames []string, viewRes
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfilesInChannel(options)
|
||||
@@ -7766,7 +7766,7 @@ func (s *TimerLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfilesInChannelByStatus(options)
|
||||
@@ -7782,7 +7782,7 @@ func (s *TimerLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGe
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
|
||||
@@ -7798,7 +7798,7 @@ func (s *TimerLayerUserStore) GetProfilesNotInChannel(teamId string, channelId s
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfilesNotInTeam(teamId, groupConstrained, offset, limit, viewRestrictions)
|
||||
@@ -7814,7 +7814,7 @@ func (s *TimerLayerUserStore) GetProfilesNotInTeam(teamId string, groupConstrain
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetProfilesWithoutTeam(options)
|
||||
@@ -7830,7 +7830,7 @@ func (s *TimerLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptio
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetRecentlyActiveUsersForTeam(teamId, offset, limit, viewRestrictions)
|
||||
@@ -7846,7 +7846,7 @@ func (s *TimerLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string, offse
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetSystemAdminProfiles()
|
||||
@@ -7862,7 +7862,7 @@ func (s *TimerLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User,
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetTeamGroupUsers(teamID)
|
||||
@@ -7878,7 +7878,7 @@ func (s *TimerLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, *
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetUnreadCount(userId string) (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetUnreadCount(userId string) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetUnreadCount(userId)
|
||||
@@ -7894,7 +7894,7 @@ func (s *TimerLayerUserStore) GetUnreadCount(userId string) (int64, *model.AppEr
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetUnreadCountForChannel(userId string, channelId string) (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetUnreadCountForChannel(userId string, channelId string) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetUnreadCountForChannel(userId, channelId)
|
||||
@@ -7910,7 +7910,7 @@ func (s *TimerLayerUserStore) GetUnreadCountForChannel(userId string, channelId
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.UserForIndexing, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.GetUsersBatchForIndexing(startTime, endTime, limit)
|
||||
@@ -7926,7 +7926,7 @@ func (s *TimerLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) InferSystemInstallDate() (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) InferSystemInstallDate() (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.InferSystemInstallDate()
|
||||
@@ -7987,7 +7987,7 @@ func (s *TimerLayerUserStore) InvalidateProfilesInChannelCacheByUser(userId stri
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) PermanentDelete(userId string) *model.AppError {
|
||||
func (s *TimerLayerUserStore) PermanentDelete(userId string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.PermanentDelete(userId)
|
||||
@@ -8003,7 +8003,7 @@ func (s *TimerLayerUserStore) PermanentDelete(userId string) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) PromoteGuestToUser(userID string) *model.AppError {
|
||||
func (s *TimerLayerUserStore) PromoteGuestToUser(userID string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.PromoteGuestToUser(userID)
|
||||
@@ -8019,7 +8019,7 @@ func (s *TimerLayerUserStore) PromoteGuestToUser(userID string) *model.AppError
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) ResetLastPictureUpdate(userId string) *model.AppError {
|
||||
func (s *TimerLayerUserStore) ResetLastPictureUpdate(userId string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.ResetLastPictureUpdate(userId)
|
||||
@@ -8035,7 +8035,7 @@ func (s *TimerLayerUserStore) ResetLastPictureUpdate(userId string) *model.AppEr
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) Save(user *model.User) (*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) Save(user *model.User) (*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.Save(user)
|
||||
@@ -8051,7 +8051,7 @@ func (s *TimerLayerUserStore) Save(user *model.User) (*model.User, *model.AppErr
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.Search(teamId, term, options)
|
||||
@@ -8067,7 +8067,7 @@ func (s *TimerLayerUserStore) Search(teamId string, term string, options *model.
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.SearchInChannel(channelId, term, options)
|
||||
@@ -8083,7 +8083,7 @@ func (s *TimerLayerUserStore) SearchInChannel(channelId string, term string, opt
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.SearchInGroup(groupID, term, options)
|
||||
@@ -8099,7 +8099,7 @@ func (s *TimerLayerUserStore) SearchInGroup(groupID string, term string, options
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.SearchNotInChannel(teamId, channelId, term, options)
|
||||
@@ -8115,7 +8115,7 @@ func (s *TimerLayerUserStore) SearchNotInChannel(teamId string, channelId string
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.SearchNotInTeam(notInTeamId, term, options)
|
||||
@@ -8131,7 +8131,7 @@ func (s *TimerLayerUserStore) SearchNotInTeam(notInTeamId string, term string, o
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.SearchWithoutTeam(term, options)
|
||||
@@ -8147,7 +8147,7 @@ func (s *TimerLayerUserStore) SearchWithoutTeam(term string, options *model.User
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.Update(user, allowRoleUpdate)
|
||||
@@ -8163,7 +8163,7 @@ func (s *TimerLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*m
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.UpdateAuthData(userId, service, authData, email, resetMfa)
|
||||
@@ -8179,7 +8179,7 @@ func (s *TimerLayerUserStore) UpdateAuthData(userId string, service string, auth
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) *model.AppError {
|
||||
func (s *TimerLayerUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.UpdateFailedPasswordAttempts(userId, attempts)
|
||||
@@ -8195,7 +8195,7 @@ func (s *TimerLayerUserStore) UpdateFailedPasswordAttempts(userId string, attemp
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) UpdateLastPictureUpdate(userId string) *model.AppError {
|
||||
func (s *TimerLayerUserStore) UpdateLastPictureUpdate(userId string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.UpdateLastPictureUpdate(userId)
|
||||
@@ -8211,7 +8211,7 @@ func (s *TimerLayerUserStore) UpdateLastPictureUpdate(userId string) *model.AppE
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) UpdateMfaActive(userId string, active bool) *model.AppError {
|
||||
func (s *TimerLayerUserStore) UpdateMfaActive(userId string, active bool) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.UpdateMfaActive(userId, active)
|
||||
@@ -8227,7 +8227,7 @@ func (s *TimerLayerUserStore) UpdateMfaActive(userId string, active bool) *model
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) UpdateMfaSecret(userId string, secret string) *model.AppError {
|
||||
func (s *TimerLayerUserStore) UpdateMfaSecret(userId string, secret string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.UpdateMfaSecret(userId, secret)
|
||||
@@ -8243,7 +8243,7 @@ func (s *TimerLayerUserStore) UpdateMfaSecret(userId string, secret string) *mod
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) UpdatePassword(userId string, newPassword string) *model.AppError {
|
||||
func (s *TimerLayerUserStore) UpdatePassword(userId string, newPassword string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.UserStore.UpdatePassword(userId, newPassword)
|
||||
@@ -8259,7 +8259,7 @@ func (s *TimerLayerUserStore) UpdatePassword(userId string, newPassword string)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) UpdateUpdateAt(userId string) (int64, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) UpdateUpdateAt(userId string) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.UpdateUpdateAt(userId)
|
||||
@@ -8275,7 +8275,7 @@ func (s *TimerLayerUserStore) UpdateUpdateAt(userId string) (int64, *model.AppEr
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) VerifyEmail(userId string, email string) (string, *model.AppError) {
|
||||
func (s *TimerLayerUserStore) VerifyEmail(userId string, email string) (string, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.UserStore.VerifyEmail(userId, email)
|
||||
|
||||
@@ -473,9 +473,9 @@ func TestOAuthComplete(t *testing.T) {
|
||||
closeBody(r)
|
||||
}
|
||||
|
||||
_, err = th.App.Srv().Store.User().UpdateAuthData(
|
||||
_, nErr := th.App.Srv().Store.User().UpdateAuthData(
|
||||
th.BasicUser.Id, model.SERVICE_GITLAB, &th.BasicUser.Email, th.BasicUser.Email, true)
|
||||
require.Nil(t, err)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
redirect, resp = ApiClient.AuthorizeOAuthApp(authRequest)
|
||||
require.Nil(t, resp.Error)
|
||||
|
||||
Ссылка в новой задаче
Block a user