Merge pull request #1757 from omnivore-app/fix/substack-email-not-forwarded

fix/substack email not forwarded
This commit is contained in:
Hongbo Wu
2023-02-01 13:56:53 +08:00
committed by GitHub
4 changed files with 51 additions and 9 deletions

View File

@ -36,13 +36,7 @@ interface EmailMessage {
}
function isEmailMessage(data: any): data is EmailMessage {
return (
'from' in data &&
'to' in data &&
'subject' in data &&
'html' in data &&
'text' in data
)
return 'from' in data && 'to' in data
}
const logger = buildLogger('app.dispatch')

View File

@ -125,6 +125,7 @@ describe('Emails Router', () => {
})
describe('create', () => {
const url = '/svc/pubsub/emails/save'
const html = '<html>test html</html>'
const text = 'test text'
const from = 'fake from'
@ -140,12 +141,41 @@ describe('Emails Router', () => {
subject,
}
const res = await request
.post('/svc/pubsub/emails/save')
.post(url)
.set('Authorization', `${authToken}`)
.send(data)
.expect(200)
expect(res.body.id).not.to.be.undefined
})
it('saves the email if body is empty', async () => {
const data = {
from,
to: newsletterEmail,
subject,
}
const res = await request
.post(url)
.set('Authorization', `${authToken}`)
.send(data)
.expect(200)
expect(res.body.id).not.to.be.undefined
})
it('saves the email if subject is empty', async () => {
const data = {
from,
to: newsletterEmail,
html,
}
const res = await request
.post(url)
.set('Authorization', `${authToken}`)
.send(data)
.expect(200)
console.log(res.body)
expect(res.body.id).not.to.be.undefined
})
})

View File

@ -0,0 +1,9 @@
-- Type: DO
-- Name: add_default_value_to_text_in_received_emails
-- Description: Add default value to the text field in received_emails table
BEGIN;
ALTER TABLE omnivore.received_emails ALTER COLUMN text SET DEFAULT '';
COMMIT;

View File

@ -0,0 +1,9 @@
-- Type: UNDO
-- Name: add_default_value_to_text_in_received_emails
-- Description: Add default value to the text field in received_emails table
BEGIN;
ALTER TABLE omnivore.received_emails ALTER COLUMN text DROP DEFAULT;
COMMIT;