mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
29 lines
625 B
TypeScript
29 lines
625 B
TypeScript
import { ReceivedEmail } from '../entity/received_email'
|
|
import { getRepository } from '../entity/utils'
|
|
|
|
export const saveReceivedEmail = async (
|
|
from: string,
|
|
to: string,
|
|
subject: string,
|
|
text: string,
|
|
html: string,
|
|
userId: string,
|
|
type: 'article' | 'non-article' = 'non-article'
|
|
): Promise<ReceivedEmail> => {
|
|
return getRepository(ReceivedEmail).save({
|
|
from,
|
|
to,
|
|
subject,
|
|
text,
|
|
html,
|
|
type,
|
|
user: { id: userId },
|
|
})
|
|
}
|
|
|
|
export const updateReceivedEmail = async (
|
|
id: string,
|
|
type: 'article' | 'non-article'
|
|
) => {
|
|
await getRepository(ReceivedEmail).update(id, { type })
|
|
}
|