Merge pull request #4215 from omnivore-app/feature/exporter
create a cloud run service for the exporter
This commit is contained in:
@ -623,6 +623,7 @@ const sendEmail = async (user: User, digest: Digest, channels: Channel[]) => {
|
||||
</div>`
|
||||
|
||||
await enqueueSendEmail({
|
||||
userId: user.id,
|
||||
to: user.email,
|
||||
from: env.sender.message,
|
||||
subject: subTitle,
|
||||
|
||||
@ -117,6 +117,7 @@ export const forwardEmailJob = async (data: EmailJobData) => {
|
||||
|
||||
// forward non-newsletter emails to the registered email address
|
||||
const result = await enqueueSendEmail({
|
||||
userId: user.id,
|
||||
from: env.sender.message,
|
||||
to: user.email,
|
||||
subject: `Fwd: ${subject}`,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { env } from '../../env'
|
||||
import { sendWithMailJet } from '../../services/send_emails'
|
||||
import { findActiveUser } from '../../services/user'
|
||||
import { Merge } from '../../util'
|
||||
import { logger } from '../../utils/logger'
|
||||
import { sendEmail } from '../../utils/sendEmail'
|
||||
@ -9,7 +10,8 @@ export const SEND_EMAIL_JOB = 'send-email'
|
||||
type ContentType = { html: string } | { text: string } | { templateId: string }
|
||||
export type SendEmailJobData = Merge<
|
||||
{
|
||||
to: string
|
||||
userId: string
|
||||
to?: string
|
||||
from?: string
|
||||
subject?: string
|
||||
html?: string
|
||||
@ -22,6 +24,16 @@ export type SendEmailJobData = Merge<
|
||||
>
|
||||
|
||||
export const sendEmailJob = async (data: SendEmailJobData) => {
|
||||
if (!data.to) {
|
||||
const user = await findActiveUser(data.userId)
|
||||
if (!user) {
|
||||
logger.error('user not found', data.userId)
|
||||
return false
|
||||
}
|
||||
|
||||
data.to = user.email
|
||||
}
|
||||
|
||||
if (process.env.USE_MAILJET && data.dynamicTemplateData) {
|
||||
return sendWithMailJet(data.to, data.dynamicTemplateData.link)
|
||||
}
|
||||
|
||||
@ -127,6 +127,7 @@ export const replyToEmailResolver = authorized<
|
||||
}
|
||||
|
||||
const result = await enqueueSendEmail({
|
||||
userId: uid,
|
||||
to: recentEmail.replyTo || recentEmail.from, // send to the reply-to address if it exists or the from address
|
||||
subject: 'Re: ' + recentEmail.subject,
|
||||
text: reply,
|
||||
|
||||
@ -95,7 +95,6 @@ export const createApp = (): Express => {
|
||||
app.use('/api/auth', authLimiter, authRouter())
|
||||
app.use('/api/mobile-auth', authLimiter, mobileAuthRouter())
|
||||
app.use('/api/page', pageRouter())
|
||||
app.use('/api/user', userRouter())
|
||||
app.use('/api/shortcuts', shortcutsRouter())
|
||||
app.use('/api/article', articleRouter())
|
||||
app.use('/api/ai-summary', aiSummariesRouter())
|
||||
|
||||
@ -18,6 +18,7 @@ export const sendNewAccountVerificationEmail = async (user: {
|
||||
}
|
||||
|
||||
const result = await enqueueSendEmail({
|
||||
userId: user.id,
|
||||
to: user.email,
|
||||
dynamicTemplateData: dynamicTemplateData,
|
||||
templateId: env.sendgrid.confirmationTemplateId,
|
||||
@ -78,6 +79,7 @@ export const sendAccountChangeEmail = async (user: {
|
||||
}
|
||||
|
||||
const result = await enqueueSendEmail({
|
||||
userId: user.id,
|
||||
to: user.email,
|
||||
dynamicTemplateData: dynamicTemplateData,
|
||||
templateId: env.sendgrid.verificationTemplateId,
|
||||
@ -100,6 +102,7 @@ export const sendPasswordResetEmail = async (user: {
|
||||
}
|
||||
|
||||
const result = await enqueueSendEmail({
|
||||
userId: user.id,
|
||||
to: user.email,
|
||||
dynamicTemplateData: dynamicTemplateData,
|
||||
templateId: env.sendgrid.resetPasswordTemplateId,
|
||||
|
||||
Reference in New Issue
Block a user