MM-22153: Adds tracking of channel moderation. (#14095)

* MM-22153: Adds tracking of channel moderation.

* MM-22153: Fixes test setup.

* MM-22153: Split role constants into scope and type.
Этот коммит содержится в:
Martin Kraft
2020-03-17 11:09:37 -04:00
коммит произвёл GitHub
родитель 4823b3861a
Коммит dd0b0a3d67
7 изменённых файлов: 291 добавлений и 0 удалений

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

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

@@ -322,3 +322,30 @@ func (s *SqlSchemeStore) PermanentDeleteAll() *model.AppError {
return nil
}
func (s *SqlSchemeStore) CountByScope(scope string) (int64, *model.AppError) {
count, err := s.GetReplica().SelectInt("SELECT count(*) FROM Schemes WHERE Scope = :Scope AND DeleteAt = 0", map[string]interface{}{"Scope": scope})
if err != nil {
return int64(0), model.NewAppError("SqlSchemeStore.CountByScope", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
}
return count, nil
}
func (s *SqlSchemeStore) CountWithoutPermission(schemeScope, permissionID string, roleScope model.RoleScope, roleType model.RoleType) (int64, *model.AppError) {
joinCol := fmt.Sprintf("Default%s%sRole", roleScope, roleType)
query := fmt.Sprintf(`
SELECT
count(*)
FROM Schemes
JOIN Roles ON Roles.Name = Schemes.%s
WHERE
Schemes.DeleteAt = 0 AND
Schemes.Scope = '%s' AND
Roles.Permissions NOT LIKE '%%%s%%'
`, joinCol, schemeScope, permissionID)
count, err := s.GetReplica().SelectInt(query)
if err != nil {
return int64(0), model.NewAppError("SqlSchemeStore.CountWithoutPermission", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
}
return count, nil
}