mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #3819 from omnivore-app/fix/inbound-email-job
save empty url for email attachment in upload_file table as it is required
This commit is contained in:
commit
b1fb527ee9
6 changed files with 14 additions and 34 deletions
|
|
@ -3734,7 +3734,6 @@ export type User = {
|
|||
__typename?: 'User';
|
||||
email?: Maybe<Scalars['String']>;
|
||||
featureList?: Maybe<Array<Feature>>;
|
||||
features?: Maybe<Array<Maybe<Scalars['String']>>>;
|
||||
followersCount?: Maybe<Scalars['Int']>;
|
||||
friendsCount?: Maybe<Scalars['Int']>;
|
||||
id: Scalars['ID'];
|
||||
|
|
@ -7203,7 +7202,6 @@ export type UploadImportFileSuccessResolvers<ContextType = ResolverContext, Pare
|
|||
export type UserResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['User'] = ResolversParentTypes['User']> = {
|
||||
email?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
||||
featureList?: Resolver<Maybe<Array<ResolversTypes['Feature']>>, ParentType, ContextType>;
|
||||
features?: Resolver<Maybe<Array<Maybe<ResolversTypes['String']>>>, ParentType, ContextType>;
|
||||
followersCount?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
|
||||
friendsCount?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
|
||||
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
|
||||
|
|
|
|||
|
|
@ -3014,7 +3014,6 @@ enum UploadImportFileType {
|
|||
type User {
|
||||
email: String
|
||||
featureList: [Feature!]
|
||||
features: [String]
|
||||
followersCount: Int
|
||||
friendsCount: Int
|
||||
id: ID!
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ export const forwardEmailJob = async (data: EmailJobData) => {
|
|||
)
|
||||
) {
|
||||
logger.info('handling as article')
|
||||
const savedNewsletter = await saveNewsletter(
|
||||
return saveNewsletter(
|
||||
{
|
||||
title: getTitleFromEmailSubject(subject),
|
||||
author: parsedFrom.name || from,
|
||||
|
|
@ -105,15 +105,6 @@ export const forwardEmailJob = async (data: EmailJobData) => {
|
|||
},
|
||||
newsletterEmail
|
||||
)
|
||||
if (!savedNewsletter) {
|
||||
logger.error('Failed to save email', { from, to, subject })
|
||||
return false
|
||||
}
|
||||
|
||||
// update received email type
|
||||
await updateReceivedEmail(receivedEmailId, 'article', user.id)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
analytics.capture({
|
||||
|
|
@ -166,7 +157,7 @@ export const saveNewsletterJob = async (data: EmailJobData) => {
|
|||
text,
|
||||
html,
|
||||
user.id,
|
||||
'article',
|
||||
'non-article', // default to non-article
|
||||
replyTo
|
||||
)
|
||||
|
||||
|
|
@ -178,6 +169,11 @@ export const saveNewsletterJob = async (data: EmailJobData) => {
|
|||
newsletterEmail.user.id
|
||||
)
|
||||
|
||||
if (result) {
|
||||
// update received email type
|
||||
await updateReceivedEmail(receivedEmailId, 'article', user.id)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +201,7 @@ export const saveNewsletterJob = async (data: EmailJobData) => {
|
|||
}
|
||||
|
||||
// save newsletter instead
|
||||
const result = await saveNewsletter(
|
||||
return saveNewsletter(
|
||||
{
|
||||
email: newsletterEmail.address,
|
||||
content,
|
||||
|
|
@ -219,8 +215,6 @@ export const saveNewsletterJob = async (data: EmailJobData) => {
|
|||
},
|
||||
newsletterEmail
|
||||
)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export const saveAttachmentJob = async (data: EmailJobData) => {
|
||||
|
|
@ -235,14 +229,14 @@ export const saveAttachmentJob = async (data: EmailJobData) => {
|
|||
}
|
||||
|
||||
const user = newsletterEmail.user
|
||||
await saveReceivedEmail(
|
||||
const receivedEmail = await saveReceivedEmail(
|
||||
from,
|
||||
to,
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
user.id,
|
||||
'article',
|
||||
'non-article',
|
||||
replyTo
|
||||
)
|
||||
|
||||
|
|
@ -250,6 +244,7 @@ export const saveAttachmentJob = async (data: EmailJobData) => {
|
|||
(tx) =>
|
||||
tx.getRepository(UploadFile).save({
|
||||
...uploadFile,
|
||||
url: '', // no url for email attachments
|
||||
status: UploadFileStatus.Completed,
|
||||
user: { id: user.id },
|
||||
}),
|
||||
|
|
@ -292,6 +287,9 @@ export const saveAttachmentJob = async (data: EmailJobData) => {
|
|||
|
||||
await createOrUpdateLibraryItem(itemToCreate, user.id)
|
||||
|
||||
// update received email type
|
||||
await updateReceivedEmail(receivedEmail.id, 'article', user.id)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -384,17 +384,6 @@ export const functionResolvers = {
|
|||
|
||||
return findUserFeatures(ctx.claims.uid)
|
||||
},
|
||||
async features(
|
||||
user: User,
|
||||
__: Record<string, unknown>,
|
||||
ctx: WithDataSourcesContext
|
||||
) {
|
||||
if (!ctx.claims?.uid) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return (await findUserFeatures(ctx.claims.uid)).map((f) => f.name)
|
||||
},
|
||||
},
|
||||
Article: {
|
||||
async url(article: Article, _: unknown, ctx: WithDataSourcesContext) {
|
||||
|
|
|
|||
|
|
@ -102,9 +102,6 @@ export const markEmailAsItemResolver = authorized<
|
|||
}
|
||||
}
|
||||
|
||||
// update received email type
|
||||
await updateReceivedEmail(recentEmail.id, 'article', uid)
|
||||
|
||||
const text = `A recent email marked as a library item
|
||||
by: ${uid}
|
||||
from: ${recentEmail.from}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ const schema = gql`
|
|||
email: String
|
||||
source: String
|
||||
intercomHash: String
|
||||
features: [String]
|
||||
featureList: [Feature!]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue