Initial migration of the store to be sync (#10592)
* Migrating audit store * Final migration example for the audit store * async example * Ending migration * Removing Async helper * Fixing tests * Fixing govet problems with the StoreResult instanstiation
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
957ec1388b
Коммит
12c50eb830
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/store"
|
||||
)
|
||||
|
||||
func (a *App) CreateSession(session *model.Session) (*model.Session, *model.AppError) {
|
||||
@@ -247,7 +248,12 @@ func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAc
|
||||
|
||||
token.Token = model.NewId()
|
||||
|
||||
uchan := a.Srv.Store.User().Get(token.UserId)
|
||||
uchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
user, err := a.Srv.Store.User().Get(token.UserId)
|
||||
uchan <- store.StoreResult{Data: user, Err: err}
|
||||
close(uchan)
|
||||
}()
|
||||
|
||||
result := <-a.Srv.Store.UserAccessToken().Save(token)
|
||||
if result.Err != nil {
|
||||
@@ -284,12 +290,10 @@ 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)
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
result = <-a.Srv.Store.User().Get(token.UserId)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
user, err := a.Srv.Store.User().Get(token.UserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user = result.Data.(*model.User)
|
||||
|
||||
if user.DeleteAt != 0 {
|
||||
return nil, model.NewAppError("createSessionForUserAccessToken", "app.user_access_token.invalid_or_missing", nil, "inactive_user_id="+user.Id, http.StatusUnauthorized)
|
||||
|
||||
Ссылка в новой задаче
Block a user