Add material pack attachment file policy

This commit is contained in:
gitea committed 2026-09-08 14:54:51 +08:00
1 parent e512ee68dc
commit 79c9420e4e
19 files changed
+487 -182

No files matched your search

+21
View File
@@ -1,4 +1,5 @@
import type { WebhookMode } from "../domains/seal/types.js";
import type { MaterialPackFilePolicyPatch } from "../domains/seal/material-pack/policy.js";
import type { ParsedArgs } from "./types.js";
export function parseArgs(argv: string[]): ParsedArgs {
@@ -201,3 +202,23 @@ export function webhookRateOption(options: Record<string, string | boolean>): nu
export function webhookShowSecretOption(options: Record<string, string | boolean>): boolean | undefined {
return booleanOption(options.showSecret) ?? booleanOption(options["show-secret"]);
}
export function materialPackFilePolicyOptions(
options: Record<string, string | boolean>
): MaterialPackFilePolicyPatch | undefined {
const minFileSizeBytes = numberOption(
options.minFileSizeBytes ?? options["min-file-size-bytes"] ?? options.minFileSize ?? options["min-file-size"]
);
const maxFileSizeBytes = numberOption(
options.maxFileSizeBytes ?? options["max-file-size-bytes"] ?? options.maxFileSize ?? options["max-file-size"]
);
const allowedExtensions = splitOption(
options.allowedExtensions ?? options["allowed-extensions"] ?? options.extensions
);
if (minFileSizeBytes === undefined && maxFileSizeBytes === undefined && allowedExtensions === undefined) {
return undefined;
}
return { minFileSizeBytes, maxFileSizeBytes, allowedExtensions };
}