-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2660 from lpsinger/remove-legacy-email-forwarding
Remove Circular ingestion from legacy email
- Loading branch information
Showing
5 changed files
with
10 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,41 +39,10 @@ describe('getFromAddress', () => { | |
).toThrow('From address is missing') | ||
}) | ||
|
||
test("raises if the from address name does not contain ' via '", () => { | ||
expect(() => | ||
getFromAddress( | ||
parseFrom( | ||
'"Example <[email protected]>" <[email protected]>' | ||
) | ||
) | ||
).toThrow("Expected From name to contain ' via '") | ||
}) | ||
|
||
test('returns the address verbatim for a normal email address', () => { | ||
expect(getFromAddress(parseFrom('[email protected]'))).toEqual({ | ||
address: '[email protected]', | ||
submittedHow: 'email', | ||
}) | ||
}) | ||
|
||
test('returns the original address for a rewritten address', () => { | ||
expect( | ||
getFromAddress( | ||
parseFrom( | ||
'"Example <[email protected]> via gcncirc" <[email protected]>' | ||
) | ||
) | ||
).toEqual({ address: '[email protected]', submittedHow: 'email-legacy' }) | ||
}) | ||
|
||
test('returns the original address for a rewritten address with an alternative "via" name', () => { | ||
expect( | ||
getFromAddress( | ||
parseFrom( | ||
'"Example <[email protected]> via my mind" <[email protected]>' | ||
) | ||
) | ||
).toEqual({ address: '[email protected]', submittedHow: 'email-legacy' }) | ||
expect(getFromAddress(parseFrom('[email protected]'))).toEqual( | ||
'[email protected]' | ||
) | ||
}) | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, [email protected], will be retired on December 31, 2024. | ||
- We encourage you to submit Circulars to the new address, circulars@${hostname}. The old address, [email protected], 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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = '[email protected]' | ||
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 <[email protected]> | ||
* --rewritten to-- | ||
* From: "Albert Einstein <[email protected]> via gcncirc" <[email protected]> | ||
* | ||
*/ | ||
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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: <CircularsEmailAddress/>. | ||
|
||
The legacy address [email protected] forwards emails to <CircularsEmailAddress/>. 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. | ||
|
||
<Alert type="warning" headingLevel="h4"> | ||
**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. | ||
</Alert> | ||
To submit a GCN Circular by email, send a message to <CircularsEmailAddress/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters