From 92871ef4642a56279b995fa8050ec0e31974bf4a Mon Sep 17 00:00:00 2001 From: Ian Chan Date: Mon, 22 Dec 2025 17:19:19 -0500 Subject: [PATCH 1/4] add invalid lable for invalid zip files --- .../feed-form/src/impl/feed-form-impl.ts | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/functions/packages/feed-form/src/impl/feed-form-impl.ts b/functions/packages/feed-form/src/impl/feed-form-impl.ts index f84b0f768..d6767b03d 100644 --- a/functions/packages/feed-form/src/impl/feed-form-impl.ts +++ b/functions/packages/feed-form/src/impl/feed-form-impl.ts @@ -327,7 +327,17 @@ async function createGithubIssue( if (formData.country && formData.country in countries) { const country = countries[formData.country as TCountryCode]; const continent = continents[country.continent].toLowerCase(); - if (continent != null) labels.push(continent); + if (continent != null) labels.push(`region/${continent}`); + } + + if (formData.authType !== "None - 0") { + labels.push("auth required"); + } + + if (!isValidZipUrl(formData.feedLink)) { + if(!await isValidZipDownload(formData.feedLink)) { + labels.push("invalid"); + } } try { @@ -441,3 +451,38 @@ export function buildGithubIssueBody( return content; } /* eslint-enable */ + +/** + * Parses the provided URL to check if it is a valid ZIP file URL + * @param url The direct download URL provided in the feed form + * @returns {boolean} Whether the URL is a valid ZIP file URL + */ +function isValidZipUrl(url: string | undefined | null): boolean { + if (!url) return false; + try { + const parsed = new URL(url); + return parsed.pathname.toLowerCase().endsWith(".zip"); + } catch { + return false; + } +} + +/** + * Checks if the provided URL points to a valid ZIP file by making a HEAD request + * @param url The direct download URL provided in the feed form + * @returns {boolean} Whether the URL downloads a valid ZIP file + */ +async function isValidZipDownload(url: string | undefined | null): Promise { + try { + if (!url) return false; + const response = await axios.head(url, {maxRedirects: 2}); + const contentType = response.headers["content-type"]; + const contentDisposition = response.headers["content-disposition"]; + + if (contentType && contentType.includes("zip")) return true; + if (contentDisposition && contentDisposition.includes("zip")) return true; + return false; + } catch { + return false; + } +} \ No newline at end of file From fa9da34d9bd291d6199024053265553bd577fd95 Mon Sep 17 00:00:00 2001 From: Ian Chan Date: Mon, 22 Dec 2025 20:58:37 -0500 Subject: [PATCH 2/4] use graphql to add new issues to the Feed Submissions Project and under the 'Backlog' column --- .../feed-form/src/impl/feed-form-impl.ts | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/functions/packages/feed-form/src/impl/feed-form-impl.ts b/functions/packages/feed-form/src/impl/feed-form-impl.ts index d6767b03d..1910afe2f 100644 --- a/functions/packages/feed-form/src/impl/feed-form-impl.ts +++ b/functions/packages/feed-form/src/impl/feed-form-impl.ts @@ -355,6 +355,19 @@ async function createGithubIssue( }, } ); + + const issueNodeId = response.data.node_id; + const projectId = "PVT_kwDOAnHxDs4Ayxl6"; + const statusFieldId = "PVTSSF_lADOAnHxDs4Ayxl6zgorIUI"; + const backlogOptionId = "8e14ac56"; + await addIssueToProjectV2( + issueNodeId, + githubToken, + projectId, + statusFieldId, + backlogOptionId + ); + return response.data.html_url; } catch (error) { logger.error("Error creating GitHub issue:", error); @@ -485,4 +498,88 @@ async function isValidZipDownload(url: string | undefined | null): Promise Date: Mon, 22 Dec 2025 21:33:30 -0500 Subject: [PATCH 3/4] fix linter errors --- .../feed-form/src/impl/feed-form-impl.ts | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/functions/packages/feed-form/src/impl/feed-form-impl.ts b/functions/packages/feed-form/src/impl/feed-form-impl.ts index 1910afe2f..aa38c2ae7 100644 --- a/functions/packages/feed-form/src/impl/feed-form-impl.ts +++ b/functions/packages/feed-form/src/impl/feed-form-impl.ts @@ -335,7 +335,7 @@ async function createGithubIssue( } if (!isValidZipUrl(formData.feedLink)) { - if(!await isValidZipDownload(formData.feedLink)) { + if (!await isValidZipDownload(formData.feedLink)) { labels.push("invalid"); } } @@ -467,8 +467,8 @@ export function buildGithubIssueBody( /** * Parses the provided URL to check if it is a valid ZIP file URL - * @param url The direct download URL provided in the feed form - * @returns {boolean} Whether the URL is a valid ZIP file URL + * @param {string | undefined | null } url The direct download URL provided in the feed form + * @return {boolean} Whether the URL is a valid ZIP file URL */ function isValidZipUrl(url: string | undefined | null): boolean { if (!url) return false; @@ -481,11 +481,13 @@ function isValidZipUrl(url: string | undefined | null): boolean { } /** - * Checks if the provided URL points to a valid ZIP file by making a HEAD request - * @param url The direct download URL provided in the feed form - * @returns {boolean} Whether the URL downloads a valid ZIP file + * Checks if URL points to a valid ZIP file by making HEAD request + * @param {string | undefined | null } url The download URL + * @return {boolean} Whether the URL downloads a valid ZIP file */ -async function isValidZipDownload(url: string | undefined | null): Promise { +async function isValidZipDownload( + url: string | undefined | null +): Promise { try { if (!url) return false; const response = await axios.head(url, {maxRedirects: 2}); @@ -518,10 +520,10 @@ async function addIssueToProjectV2( try { const addToProjectMutation = ` mutation($projectId: ID!, $contentId: ID!) { - addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) { - item { - id - } + addProjectV2ItemById( + input: {projectId: $projectId, contentId: $contentId} + ) { + item { id } } } `; @@ -546,13 +548,21 @@ async function addIssueToProjectV2( const itemId = addToProjectResponse.data.data.addProjectV2ItemById.item.id; const updateStatusMutation = ` - mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: ProjectV2FieldValue!) { + mutation( + $projectId: ID! + $itemId: ID! + $fieldId: ID! + $value: ProjectV2FieldValue! + ) { updateProjectV2ItemFieldValue( - input: {projectId: $projectId, itemId: $itemId, fieldId: $fieldId, value: $value} - ) { - projectV2Item { - id + input: { + projectId: $projectId + itemId: $itemId + fieldId: $fieldId + value: $value } + ) { + projectV2Item { id } } } `; @@ -582,4 +592,4 @@ async function addIssueToProjectV2( } catch (error) { logger.error("Error adding issue to Feed Submissions Backlog:", error); } -} \ No newline at end of file +} From 10d29cfc108cfb98fbecbb8c3fc169139ed4edc9 Mon Sep 17 00:00:00 2001 From: Ian Chan Date: Mon, 22 Dec 2025 21:49:45 -0500 Subject: [PATCH 4/4] fix linter errors --- functions/packages/feed-form/src/impl/feed-form-impl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/packages/feed-form/src/impl/feed-form-impl.ts b/functions/packages/feed-form/src/impl/feed-form-impl.ts index aa38c2ae7..ee1159f74 100644 --- a/functions/packages/feed-form/src/impl/feed-form-impl.ts +++ b/functions/packages/feed-form/src/impl/feed-form-impl.ts @@ -467,7 +467,7 @@ export function buildGithubIssueBody( /** * Parses the provided URL to check if it is a valid ZIP file URL - * @param {string | undefined | null } url The direct download URL provided in the feed form + * @param {string | undefined | null } url The direct download URL * @return {boolean} Whether the URL is a valid ZIP file URL */ function isValidZipUrl(url: string | undefined | null): boolean {