MM-32396 Create endpoint for listing all the roles (#16988)
* Create an endpoint for listing roles * Add function to client model * Create tests for listing roles endpoint * Apply code review suggestions * Restore GetAllRoles app method * Use AppContext instead of App * Minor fix * Refactor according to new changes Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
25257d6ef6
Коммит
e70c5a605a
14
app/role.go
14
app/role.go
@@ -37,6 +37,20 @@ func (a *App) GetRole(id string) (*model.Role, *model.AppError) {
|
||||
return role, nil
|
||||
}
|
||||
|
||||
func (a *App) GetAllRoles() ([]*model.Role, *model.AppError) {
|
||||
roles, err := a.Srv().Store.Role().GetAll()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetAllRoles", "app.role.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
appErr := a.Srv().mergeChannelHigherScopedPermissions(roles)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
return roles, nil
|
||||
}
|
||||
|
||||
func (s *Server) GetRoleByName(ctx context.Context, name string) (*model.Role, *model.AppError) {
|
||||
role, nErr := s.Store.Role().GetByName(ctx, name)
|
||||
if nErr != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user