From 07f340f7285660aed28c5396da18573db6d1b482 Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Fri, 1 Nov 2024 11:04:01 -0400 Subject: [PATCH 1/3] Remove Circular ingestion from legacy email --- .../circulars/__tests__/parse.ts | 20 ----------- app/email-incoming/circulars/index.ts | 6 ++-- app/email-incoming/circulars/parse.ts | 35 ++----------------- app/routes/docs.circulars.submitting.mdx | 9 +---- app/routes/docs.contributing.email/route.mdx | 6 +--- 5 files changed, 7 insertions(+), 69 deletions(-) diff --git a/app/email-incoming/circulars/__tests__/parse.ts b/app/email-incoming/circulars/__tests__/parse.ts index 9e77a93a0..82365d471 100644 --- a/app/email-incoming/circulars/__tests__/parse.ts +++ b/app/email-incoming/circulars/__tests__/parse.ts @@ -55,26 +55,6 @@ describe('getFromAddress', () => { submittedHow: 'email', }) }) - - test('returns the original address for a rewritten address', () => { - expect( - getFromAddress( - parseFrom( - '"Example via gcncirc" ' - ) - ) - ).toEqual({ address: 'example@example.com', submittedHow: 'email-legacy' }) - }) - - test('returns the original address for a rewritten address with an alternative "via" name', () => { - expect( - getFromAddress( - parseFrom( - '"Example via my mind" ' - ) - ) - ).toEqual({ address: 'example@example.com', submittedHow: 'email-legacy' }) - }) }) const testEmailContentString = `Return-Path: diff --git a/app/email-incoming/circulars/index.ts b/app/email-incoming/circulars/index.ts index 61f637e2f..8c620fa6e 100644 --- a/app/email-incoming/circulars/index.ts +++ b/app/email-incoming/circulars/index.ts @@ -53,7 +53,7 @@ const fromName = 'GCN Circulars' export const handler = createEmailIncomingMessageHandler( async ({ content }) => { const parsed = await parseEmailContentFromSource(content) - const { address: userEmail, submittedHow } = getFromAddress(parsed.from) + const userEmail = getFromAddress(parsed.from) const to = getReplyToAddresses(parsed.replyTo) ?? [userEmail] const userData = @@ -92,7 +92,7 @@ export const handler = createEmailIncomingMessageHandler( body: parsed.text, sub: userData.sub, submitter: formatAuthor(userData), - submittedHow, + submittedHow: 'email', } const eventId = parseEventFromSubject(parsed.subject) @@ -204,7 +204,7 @@ If you have not already done so, we encourage you to make an account at ${origin - Your Circulars settings have been transferred automatically. - You are able to submit Circulars from the same email addresses registered in the legacy service. - Emails from GCN come from a new address, no-reply@${hostname}. -- We encourage you to submit Circulars to the new address, circulars@${hostname}. The old GCN Circulars submission address, gcncirc@capella2.gsfc.nasa.gov, will be retired on December 31, 2024. +- We encourage you to submit Circulars to the new address, circulars@${hostname}. The old address, gcncirc@capella2.gsfc.nasa.gov, has been retired. - The new archive, ${origin}/circulars, includes all past Circulars. We have frozen the old archive, https://gcn.gsfc.nasa.gov/gcn3_archive.html. For more information about the GCN Circulars, please see ${origin}/circulars. diff --git a/app/email-incoming/circulars/parse.ts b/app/email-incoming/circulars/parse.ts index e1aa43cc6..3b3582003 100644 --- a/app/email-incoming/circulars/parse.ts +++ b/app/email-incoming/circulars/parse.ts @@ -7,43 +7,12 @@ */ import type { AddressObject, Source } from 'mailparser' import { simpleParser } from 'mailparser' -import addressparser from 'nodemailer/lib/addressparser' -import type { SubmittedHow } from '~/routes/circulars/circulars.lib' - -const legacyAddress = 'mailnull@capella2.gsfc.nasa.gov' -const legacyFromNameSplitter = ' via ' - -/** - * Parse rewritten From addresses from capella2. - * - * Messages forwarded by capella2 from non-NASA addresses have From headers - * that are rewritten like this: - * - * From: Albert Einstein - * --rewritten to-- - * From: "Albert Einstein via gcncirc" - * - */ export function getFromAddress(fromAddressObject?: AddressObject) { - let from = fromAddressObject?.value[0] - let submittedHow: SubmittedHow - if (from?.address === legacyAddress) { - const i = from.name.lastIndexOf(legacyFromNameSplitter) - if (i === -1) - throw new Error( - `Expected From name to contain '${legacyFromNameSplitter}'` - ) - from = addressparser(from.name.slice(0, i), { - flatten: true, - })[0] - submittedHow = 'email-legacy' - } else { - submittedHow = 'email' - } + const from = fromAddressObject?.value[0] const address = from?.address if (!address) throw new Error('From address is missing') - return { address, submittedHow } + return address } export function getReplyToAddresses(replyTo?: AddressObject) { diff --git a/app/routes/docs.circulars.submitting.mdx b/app/routes/docs.circulars.submitting.mdx index 233e0e32a..2f2527723 100644 --- a/app/routes/docs.circulars.submitting.mdx +++ b/app/routes/docs.circulars.submitting.mdx @@ -71,11 +71,4 @@ To post a GCN Circular via the web form, simply go to the [GCN Circulars archive ### Post a GCN Circular by Email -To submit a GCN Circular by email, send a message to: . - -The legacy address gcncirc@capella2.gsfc.nasa.gov forwards emails to . This forwarding will be retired on December 31, 2024. Note that the new address is stricter than the old address about the `From:` address matching the sender. - - - **Do not send your Circular to both email addresses.** If you send it to both - addresses, then it will be distributed twice as two different circulars. - +To submit a GCN Circular by email, send a message to . diff --git a/app/routes/docs.contributing.email/route.mdx b/app/routes/docs.contributing.email/route.mdx index 26ce61ed9..f26c87d78 100644 --- a/app/routes/docs.contributing.email/route.mdx +++ b/app/routes/docs.contributing.email/route.mdx @@ -20,7 +20,7 @@ Note that each flow chart represents the email processing for a single one of GC Flow chart of GCN Circulars ingestion -Authorized GCN users can [submit GCN Circulars](/docs/circulars/submitting) in any one of three ways: by logging in and completing the [Web form](/circulars/new), by submitting an email to circulars@stage.gcn.nasa.gov, or by submitting an email to the legacy GCN Classic server at gcncirc@capella2.gsfc.nasa.gov. +Authorized GCN users can [submit GCN Circulars](/docs/circulars/submitting) in either of two ways: by logging in and completing the [Web form](/circulars/new) or by submitting an email to circulars@stage.gcn.nasa.gov. ### By Web form @@ -36,10 +36,6 @@ To submit a Circular via email, the user sends an email to circulars@stagegcncirc@capella2.gsfc.nasa.gov - -The legacy, on-premise GCN Classic server at NASA Goddard Space Flight Center, capella2.gsfc.nasa.gov, is configured to forward messages addressed to gcncirc@capella2.gsfc.nasa.gov to circulars@gcn.nasa.gov. Once received by Amazon SES, processing proceeds the same as above. - ## Support Requests **Source code:** [app/email-incoming/support](https://github.com/nasa-gcn/gcn.nasa.gov/tree/main/app/email-incoming/support) From 1a41ef08be07214669928f0c00565c40a2a2a9b9 Mon Sep 17 00:00:00 2001 From: dakota002 Date: Tue, 10 Dec 2024 14:48:38 -0500 Subject: [PATCH 2/3] Removes other test of forwarding behavior, change expected result from object to string --- app/email-incoming/circulars/__tests__/parse.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/app/email-incoming/circulars/__tests__/parse.ts b/app/email-incoming/circulars/__tests__/parse.ts index 82365d471..1434a9a98 100644 --- a/app/email-incoming/circulars/__tests__/parse.ts +++ b/app/email-incoming/circulars/__tests__/parse.ts @@ -39,21 +39,10 @@ describe('getFromAddress', () => { ).toThrow('From address is missing') }) - test("raises if the from address name does not contain ' via '", () => { - expect(() => - getFromAddress( - parseFrom( - '"Example " ' - ) - ) - ).toThrow("Expected From name to contain ' via '") - }) - test('returns the address verbatim for a normal email address', () => { - expect(getFromAddress(parseFrom('example@example.com'))).toEqual({ - address: 'example@example.com', - submittedHow: 'email', - }) + expect(getFromAddress(parseFrom('example@example.com'))).toEqual( + 'example@example.com' + ) }) }) From 489723d4733dc86e52269f8e8cf05f1c1df3b3f9 Mon Sep 17 00:00:00 2001 From: dakota002 Date: Tue, 10 Dec 2024 16:36:14 -0500 Subject: [PATCH 3/3] Adds updates the tests with a click --- __playwright__/circulars/archive.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index c0cc33262..74d2ffd22 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -6,9 +6,10 @@ test.describe('Circulars archive page', () => { }) => { await page.goto('/circulars') for (const expectedResultsPerPage of [10, 20]) { - await page - .getByTitle('Number of results per page') - .selectOption({ label: `${expectedResultsPerPage} / page` }) + const locator = page.getByTestId('Select') + await expect(locator).toBeVisible() + await locator.click() + await locator.selectOption(`${expectedResultsPerPage} / page`) await page.waitForFunction( (n) => document.getElementsByTagName('ol')[0].getElementsByTagName('li')