save content reader in the item

This commit is contained in:
Hongbo Wu
2023-10-12 12:59:36 +08:00
parent d1472c6519
commit 4d64231abf
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,10 @@
import express from 'express'
import { DeepPartial } from 'typeorm'
import { LibraryItem, LibraryItemState } from '../../entity/library_item'
import {
ContentReaderType,
LibraryItem,
LibraryItemState,
} from '../../entity/library_item'
import { UploadFile } from '../../entity/upload_file'
import { env } from '../../env'
import { PageType, UploadFileStatus } from '../../generated/graphql'
@ -160,6 +164,10 @@ export function emailAttachmentRouter() {
slug: generateSlug(title),
state: LibraryItemState.Succeeded,
user: { id: user.id },
contentReader:
itemType === PageType.File
? ContentReaderType.PDF
: ContentReaderType.EPUB,
}
const item = await createLibraryItem(itemToCreate, user.id)

View File

@ -94,6 +94,7 @@ describe('Email attachments Router', () => {
const item = await findLibraryItemById(res2.body.id, user.id)
expect(item).to.exist
expect(item?.contentReader).to.eq('PDF')
})
})
})