omnivore/packages/api/src/services/received_emails.ts
2023-01-18 22:35:07 +08:00

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 })
}