Use a central list of private types

This commit is contained in:
2019-11-18 14:26:53 +09:00
parent 597f46f372
commit 12c752a272
4 changed files with 26 additions and 26 deletions

View File

@ -13,20 +13,6 @@ import (
"github.com/mohae/deepcopy"
)
// privateTypes are types that are not available for download.
var privateTypes = []string{
"Analytics",
"Crash",
"ClientErrorReport",
"EditLogEntry",
"EmailToUser",
"FacebookToUser",
"PayPalPayment",
"Purchase",
"Session",
"TwitterToUser",
}
// Download downloads a snapshot of a database collection.
func Download(ctx aero.Context) error {
typ := ctx.Get("type")
@ -35,7 +21,7 @@ func Download(ctx aero.Context) error {
return ctx.Error(http.StatusNotFound, "Type doesn't exist")
}
if arn.Contains(privateTypes, typ) {
if arn.IsPrivateType(typ) {
return ctx.Error(http.StatusUnauthorized, "Type is private and can not be downloaded")
}