Added id validation to CurseForge and Modrinth uploaders

This commit is contained in:
Kir_Antipov 2023-05-20 15:27:49 +03:00
parent 48e56214c9
commit cf1e5a95bb
2 changed files with 6 additions and 0 deletions

View file

@ -2,6 +2,7 @@ import { CurseForgeUploadRequest as UploadRequest, CurseForgeUploadReport as Upl
import { Dependency } from "@/dependencies"; import { Dependency } from "@/dependencies";
import { PlatformType } from "@/platforms/platform-type"; import { PlatformType } from "@/platforms/platform-type";
import { GenericPlatformUploader, GenericPlatformUploaderOptions } from "@/platforms/generic-platform-uploader"; import { GenericPlatformUploader, GenericPlatformUploaderOptions } from "@/platforms/generic-platform-uploader";
import { ArgumentError } from "@/utils/errors";
import { CurseForgeDependency } from "./curseforge-dependency"; import { CurseForgeDependency } from "./curseforge-dependency";
import { CurseForgeDependencyType } from "./curseforge-dependency-type"; import { CurseForgeDependencyType } from "./curseforge-dependency-type";
import { CurseForgeEternalApiClient } from "./curseforge-eternal-api-client"; import { CurseForgeEternalApiClient } from "./curseforge-eternal-api-client";
@ -48,6 +49,8 @@ export class CurseForgeUploader extends GenericPlatformUploader<CurseForgeUpload
* @inheritdoc * @inheritdoc
*/ */
protected async uploadCore(request: CurseForgeUploadRequest): Promise<CurseForgeUploadReport> { protected async uploadCore(request: CurseForgeUploadRequest): Promise<CurseForgeUploadReport> {
ArgumentError.throwIfNullOrEmpty(request.id, "request.id");
const api = new CurseForgeUploadApiClient({ token: request.token.unwrap() }); const api = new CurseForgeUploadApiClient({ token: request.token.unwrap() });
const eternalApi = new CurseForgeEternalApiClient(); const eternalApi = new CurseForgeEternalApiClient();

View file

@ -4,6 +4,7 @@ import { GenericPlatformUploader, GenericPlatformUploaderOptions } from "@/platf
import { PlatformType } from "@/platforms/platform-type"; import { PlatformType } from "@/platforms/platform-type";
import { $i } from "@/utils/collections"; import { $i } from "@/utils/collections";
import { IGNORE_CASE_AND_NON_WORD_CHARACTERS_EQUALITY_COMPARER } from "@/utils/comparison"; import { IGNORE_CASE_AND_NON_WORD_CHARACTERS_EQUALITY_COMPARER } from "@/utils/comparison";
import { ArgumentError } from "@/utils/errors";
import { ModrinthApiClient } from "./modrinth-api-client"; import { ModrinthApiClient } from "./modrinth-api-client";
import { ModrinthDependency } from "./modrinth-dependency"; import { ModrinthDependency } from "./modrinth-dependency";
import { ModrinthDependencyType } from "./modrinth-dependency-type"; import { ModrinthDependencyType } from "./modrinth-dependency-type";
@ -50,6 +51,8 @@ export class ModrinthUploader extends GenericPlatformUploader<ModrinthUploaderOp
* @inheritdoc * @inheritdoc
*/ */
protected async uploadCore(request: ModrinthUploadRequest): Promise<ModrinthUploadReport> { protected async uploadCore(request: ModrinthUploadRequest): Promise<ModrinthUploadReport> {
ArgumentError.throwIfNullOrEmpty(request.id, "request.id");
const api = new ModrinthApiClient({ token: request.token.unwrap() }); const api = new ModrinthApiClient({ token: request.token.unwrap() });
const unfeatureMode = request.unfeatureMode ?? (request.featured ? ModrinthUnfeatureMode.SUBSET : ModrinthUnfeatureMode.NONE); const unfeatureMode = request.unfeatureMode ?? (request.featured ? ModrinthUnfeatureMode.SUBSET : ModrinthUnfeatureMode.NONE);