MM-15801 Migrate "Session.UpdateRoles" to Sync by default (#11015)
Этот коммит содержится в:
коммит произвёл
Hanzei
родитель
7b9833405d
Коммит
58e126b910
@@ -1390,7 +1390,13 @@ func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent
|
|||||||
uchan <- store.StoreResult{Data: userUpdate, Err: err}
|
uchan <- store.StoreResult{Data: userUpdate, Err: err}
|
||||||
close(uchan)
|
close(uchan)
|
||||||
}()
|
}()
|
||||||
schan := a.Srv.Store.Session().UpdateRoles(user.Id, newRoles)
|
|
||||||
|
schan := make(chan store.StoreResult, 1)
|
||||||
|
go func() {
|
||||||
|
userId, err := a.Srv.Store.Session().UpdateRoles(user.Id, newRoles)
|
||||||
|
schan <- store.StoreResult{Data: userId, Err: err}
|
||||||
|
close(schan)
|
||||||
|
}()
|
||||||
|
|
||||||
result := <-uchan
|
result := <-uchan
|
||||||
if result.Err != nil {
|
if result.Err != nil {
|
||||||
|
|||||||
@@ -178,14 +178,14 @@ func (me SqlSessionStore) UpdateLastActivityAt(sessionId string, time int64) *mo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me SqlSessionStore) UpdateRoles(userId, roles string) store.StoreChannel {
|
func (me SqlSessionStore) UpdateRoles(userId, roles string) (string, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
query := "UPDATE Sessions SET Roles = :Roles WHERE UserId = :UserId"
|
||||||
if _, err := me.GetMaster().Exec("UPDATE Sessions SET Roles = :Roles WHERE UserId = :UserId", map[string]interface{}{"Roles": roles, "UserId": userId}); err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlSessionStore.UpdateRoles", "store.sql_session.update_roles.app_error", nil, "userId="+userId, http.StatusInternalServerError)
|
_, err := me.GetMaster().Exec(query, map[string]interface{}{"Roles": roles, "UserId": userId})
|
||||||
} else {
|
if err != nil {
|
||||||
result.Data = userId
|
return "", model.NewAppError("SqlSessionStore.UpdateRoles", "store.sql_session.update_roles.app_error", nil, "userId="+userId, http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
})
|
return userId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me SqlSessionStore) UpdateDeviceId(id string, deviceId string, expiresAt int64) (string, *model.AppError) {
|
func (me SqlSessionStore) UpdateDeviceId(id string, deviceId string, expiresAt int64) (string, *model.AppError) {
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ type SessionStore interface {
|
|||||||
RemoveAllSessions() *model.AppError
|
RemoveAllSessions() *model.AppError
|
||||||
PermanentDeleteSessionsByUser(teamId string) *model.AppError
|
PermanentDeleteSessionsByUser(teamId string) *model.AppError
|
||||||
UpdateLastActivityAt(sessionId string, time int64) *model.AppError
|
UpdateLastActivityAt(sessionId string, time int64) *model.AppError
|
||||||
UpdateRoles(userId string, roles string) StoreChannel
|
UpdateRoles(userId string, roles string) (string, *model.AppError)
|
||||||
UpdateDeviceId(id string, deviceId string, expiresAt int64) (string, *model.AppError)
|
UpdateDeviceId(id string, deviceId string, expiresAt int64) (string, *model.AppError)
|
||||||
AnalyticsSessionCount() (int64, *model.AppError)
|
AnalyticsSessionCount() (int64, *model.AppError)
|
||||||
Cleanup(expiryTime int64, batchSize int64)
|
Cleanup(expiryTime int64, batchSize int64)
|
||||||
|
|||||||
@@ -229,17 +229,24 @@ func (_m *SessionStore) UpdateLastActivityAt(sessionId string, time int64) *mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRoles provides a mock function with given fields: userId, roles
|
// UpdateRoles provides a mock function with given fields: userId, roles
|
||||||
func (_m *SessionStore) UpdateRoles(userId string, roles string) store.StoreChannel {
|
func (_m *SessionStore) UpdateRoles(userId string, roles string) (string, *model.AppError) {
|
||||||
ret := _m.Called(userId, roles)
|
ret := _m.Called(userId, roles)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 string
|
||||||
if rf, ok := ret.Get(0).(func(string, string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, string) string); ok {
|
||||||
r0 = rf(userId, roles)
|
r0 = rf(userId, roles)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
r0 = ret.Get(0).(string)
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
}
|
||||||
|
|
||||||
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
|
||||||
|
r1 = rf(userId, roles)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user