mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix page id not get in auto-synthesize subscription
This commit is contained in:
parent
7f83045c0c
commit
3cea785336
3 changed files with 8 additions and 13 deletions
|
|
@ -194,9 +194,10 @@ export const createPage = async (
|
|||
refresh: ctx.refresh,
|
||||
})
|
||||
|
||||
page.id = body._id as string
|
||||
await ctx.pubsub.entityCreated<Page>(EntityType.PAGE, page, ctx.uid)
|
||||
|
||||
return body._id as string
|
||||
return page.id
|
||||
} catch (e) {
|
||||
console.error('failed to create a page in elastic', JSON.stringify(e))
|
||||
return undefined
|
||||
|
|
@ -317,6 +318,8 @@ export const getPageByParam = async <K extends keyof ParamSet>(
|
|||
|
||||
export const getPageById = async (id: string): Promise<Page | undefined> => {
|
||||
try {
|
||||
if (!id) return undefined
|
||||
|
||||
const { body } = await client.get({
|
||||
index: INDEX_ALIAS,
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -247,15 +247,7 @@ export interface SearchItem {
|
|||
highlights?: Highlight[]
|
||||
}
|
||||
|
||||
const keys = [
|
||||
'_id',
|
||||
'url',
|
||||
'slug',
|
||||
'userId',
|
||||
'uploadFileId',
|
||||
'state',
|
||||
'id',
|
||||
] as const
|
||||
const keys = ['_id', 'url', 'slug', 'userId', 'uploadFileId', 'state'] as const
|
||||
|
||||
export type ParamSet = PickTuple<Page, typeof keys>
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ export function speechServiceRouter() {
|
|||
const data: { userId: string; type: string; id: string } =
|
||||
JSON.parse(msgStr)
|
||||
const { userId, type, id } = data
|
||||
if (!userId || !type) {
|
||||
logger.info('No userId or type found in message')
|
||||
if (!userId || !type || !id) {
|
||||
logger.info('Invalid data')
|
||||
return res.status(400).send('Bad Request')
|
||||
}
|
||||
|
||||
|
|
@ -49,13 +49,13 @@ export function speechServiceRouter() {
|
|||
return res.status(200).send('Not a page')
|
||||
}
|
||||
|
||||
// checks if this page needs to be synthesized automatically
|
||||
const page = await getPageById(id)
|
||||
if (!page) {
|
||||
logger.info('No page found', { id })
|
||||
return res.status(200).send('No page found')
|
||||
}
|
||||
|
||||
// checks if this page needs to be synthesized automatically
|
||||
if (await shouldSynthesize(userId, page)) {
|
||||
logger.info('page needs to be synthesized')
|
||||
// initialize state
|
||||
|
|
|
|||
Loading…
Reference in a new issue