* [MM-11345] Migrated TokenStore.RemoveAllTokensByType to Sync by default (#11345) * changed TokenStore.RemoveAllTokensByType to return *model.AppError * changed test coverage accordingly in store/storetest/mocks * Fixing mocks
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
c95d295dce
Коммит
c8fb1b6265
@@ -1312,8 +1312,8 @@ func (a *App) RemoveTeamIcon(teamId string) *model.AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) InvalidateAllEmailInvites() *model.AppError {
|
func (a *App) InvalidateAllEmailInvites() *model.AppError {
|
||||||
if result := <-a.Srv.Store.Token().RemoveAllTokensByType(TOKEN_TYPE_TEAM_INVITATION); result.Err != nil {
|
if err := a.Srv.Store.Token().RemoveAllTokensByType(TOKEN_TYPE_TEAM_INVITATION); err != nil {
|
||||||
return model.NewAppError("InvalidateAllEmailInvites", "api.team.invalidate_all_email_invites.app_error", nil, result.Err.Error(), http.StatusBadRequest)
|
return model.NewAppError("InvalidateAllEmailInvites", "api.team.invalidate_all_email_invites.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,11 +72,9 @@ func (s SqlTokenStore) Cleanup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlTokenStore) RemoveAllTokensByType(tokenType string) store.StoreChannel {
|
func (s SqlTokenStore) RemoveAllTokensByType(tokenType string) *model.AppError {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
|
||||||
if _, err := s.GetMaster().Exec("DELETE FROM Tokens WHERE Type = :TokenType", map[string]interface{}{"TokenType": tokenType}); err != nil {
|
if _, err := s.GetMaster().Exec("DELETE FROM Tokens WHERE Type = :TokenType", map[string]interface{}{"TokenType": tokenType}); err != nil {
|
||||||
result.Err = model.NewAppError("SqlTokenStore.RemoveAllTokensByType", "store.sql_recover.remove_all_tokens_by_type.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return model.NewAppError("SqlTokenStore.RemoveAllTokensByType", "store.sql_recover.remove_all_tokens_by_type.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
})
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ type TokenStore interface {
|
|||||||
Delete(token string) *model.AppError
|
Delete(token string) *model.AppError
|
||||||
GetByToken(token string) (*model.Token, *model.AppError)
|
GetByToken(token string) (*model.Token, *model.AppError)
|
||||||
Cleanup()
|
Cleanup()
|
||||||
RemoveAllTokensByType(tokenType string) StoreChannel
|
RemoveAllTokensByType(tokenType string) *model.AppError
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmojiStore interface {
|
type EmojiStore interface {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ package mocks
|
|||||||
|
|
||||||
import mock "github.com/stretchr/testify/mock"
|
import mock "github.com/stretchr/testify/mock"
|
||||||
import model "github.com/mattermost/mattermost-server/model"
|
import model "github.com/mattermost/mattermost-server/model"
|
||||||
import store "github.com/mattermost/mattermost-server/store"
|
|
||||||
|
|
||||||
// TokenStore is an autogenerated mock type for the TokenStore type
|
// TokenStore is an autogenerated mock type for the TokenStore type
|
||||||
type TokenStore struct {
|
type TokenStore struct {
|
||||||
@@ -60,15 +59,15 @@ func (_m *TokenStore) GetByToken(token string) (*model.Token, *model.AppError) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveAllTokensByType provides a mock function with given fields: tokenType
|
// RemoveAllTokensByType provides a mock function with given fields: tokenType
|
||||||
func (_m *TokenStore) RemoveAllTokensByType(tokenType string) store.StoreChannel {
|
func (_m *TokenStore) RemoveAllTokensByType(tokenType string) *model.AppError {
|
||||||
ret := _m.Called(tokenType)
|
ret := _m.Called(tokenType)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.AppError
|
||||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||||
r0 = rf(tokenType)
|
r0 = rf(tokenType)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user