Merge pull request #3707 from omnivore-app/fix/rule

send labels and highlight annotations in page_create event
This commit is contained in:
Hongbo Wu
2024-03-21 10:52:15 +08:00
committed by GitHub
3 changed files with 8 additions and 3 deletions

View File

@ -361,6 +361,7 @@ const createItemWithFeedContent = async (
clientRequestId: '',
author: item.creator,
previewImage,
labels: [{ name: 'RSS' }],
},
user
)

View File

@ -1425,15 +1425,15 @@ export const filterItemEvents = (
return event.itemType?.toString().toLowerCase() === lowercasedValue
}
case 'label': {
const labels = event.labelNames as string[]
const labels = event.labelNames as string[] | undefined
const labelsToTest = lowercasedValue.split(',')
return labelsToTest.some((label) => {
const hasWildcard = label.includes('*')
if (hasWildcard) {
return labels.some((l) => l.match(new RegExp(label, 'i')))
return labels?.some((l) => l.match(new RegExp(label, 'i')))
}
return labels.some((l) => l.toLowerCase() === label)
return labels?.some((l) => l.toLowerCase() === label)
})
}
case 'has':

View File

@ -135,6 +135,7 @@ export const savePage = async (
dir: parseResult.parsedContent?.dir,
preparedDocument,
labelNames: input.labels?.map((label) => label.name),
highlightAnnotations: parseResult.highlightData ? [''] : undefined,
})
const isImported =
input.source === 'csv-importer' || input.source === 'pocket'
@ -215,6 +216,7 @@ export const parsedContentToLibraryItem = ({
feedContent,
dir,
labelNames,
highlightAnnotations,
}: {
url: string
userId: string
@ -237,6 +239,7 @@ export const parsedContentToLibraryItem = ({
feedContent?: string | null
dir?: string | null
labelNames?: string[]
highlightAnnotations?: string[]
}): DeepPartial<LibraryItem> & { originalUrl: string } => {
logger.info('save_page', { url, state, itemId })
return {
@ -285,5 +288,6 @@ export const parsedContentToLibraryItem = ({
? DirectionalityType.RTL
: DirectionalityType.LTR, // default to LTR
labelNames,
highlightAnnotations,
}
}