* Removing some other fake apps

* More FakeApp removed

* Removing entirely FakeApp

* Fixing some tests

* Fixing get Cluster id from get plugin status

* Fixing failing tests

* Fixing tests

* Fixing test initialization for web

* Fixing InitServer for server tests

* Fixing InitServer for server tests

* Reverting go.sum and go.mod

* Removing unneded HTMLTemplates function in App layer

* Moving back some functions to its old place to easy the review

* Moving back some functions to its old place to easy the review

* Using the last struct2interface version

* Generating store layers

* Fixing merge problems

* Addressing PR comments

* Small fix

* Fixing app tests build

* Fixing tests

* fixing tests

* Fix tests

* Fixing tests

* Fixing tests

* Fixing tests

* Moving license to server struct

* Adding some fixes to the test compilation

* Fixing cluster and some jobs initialization

* Fixing some license tests compilation problems

* Fixing recursive cache invalidation

* Regenerating app layers

* Fix test compilation

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2020-06-12 13:43:50 +02:00
коммит произвёл GitHub
родитель f3ac33e6dc
Коммит f5eab1271b
88 изменённых файлов: 973 добавлений и 1177 удалений

Просмотреть файл

@@ -20,13 +20,13 @@ func (a *App) GetAllRoles() ([]*model.Role, *model.AppError) {
return a.Srv().Store.Role().GetAll()
}
func (a *App) GetRoleByName(name string) (*model.Role, *model.AppError) {
role, err := a.Srv().Store.Role().GetByName(name)
func (s *Server) GetRoleByName(name string) (*model.Role, *model.AppError) {
role, err := s.Store.Role().GetByName(name)
if err != nil {
return nil, err
}
err = a.mergeChannelHigherScopedPermissions([]*model.Role{role})
err = s.mergeChannelHigherScopedPermissions([]*model.Role{role})
if err != nil {
return nil, err
}
@@ -34,6 +34,10 @@ func (a *App) GetRoleByName(name string) (*model.Role, *model.AppError) {
return role, nil
}
func (a *App) GetRoleByName(name string) (*model.Role, *model.AppError) {
return a.Srv().GetRoleByName(name)
}
func (a *App) GetRolesByNames(names []string) ([]*model.Role, *model.AppError) {
roles, err := a.Srv().Store.Role().GetByNames(names)
if err != nil {
@@ -50,7 +54,7 @@ func (a *App) GetRolesByNames(names []string) ([]*model.Role, *model.AppError) {
// mergeChannelHigherScopedPermissions updates the permissions based on the role type, whether the permission is
// moderated, and the value of the permission on the higher-scoped scheme.
func (a *App) mergeChannelHigherScopedPermissions(roles []*model.Role) *model.AppError {
func (s *Server) mergeChannelHigherScopedPermissions(roles []*model.Role) *model.AppError {
var higherScopeNamesToQuery []string
for _, role := range roles {
@@ -63,7 +67,7 @@ func (a *App) mergeChannelHigherScopedPermissions(roles []*model.Role) *model.Ap
return nil
}
higherScopedPermissionsMap, err := a.Srv().Store.Role().ChannelHigherScopedPermissions(higherScopeNamesToQuery)
higherScopedPermissionsMap, err := s.Store.Role().ChannelHigherScopedPermissions(higherScopeNamesToQuery)
if err != nil {
return err
}
@@ -79,6 +83,12 @@ func (a *App) mergeChannelHigherScopedPermissions(roles []*model.Role) *model.Ap
return nil
}
// mergeChannelHigherScopedPermissions updates the permissions based on the role type, whether the permission is
// moderated, and the value of the permission on the higher-scoped scheme.
func (a *App) mergeChannelHigherScopedPermissions(roles []*model.Role) *model.AppError {
return a.Srv().mergeChannelHigherScopedPermissions(roles)
}
func (a *App) PatchRole(role *model.Role, patch *model.RolePatch) (*model.Role, *model.AppError) {
// If patch is a no-op then short-circuit the store.
if patch.Permissions != nil && reflect.DeepEqual(*patch.Permissions, role.Permissions) {