mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
do not send content in the thumbnail task payload
This commit is contained in:
parent
d231907945
commit
163dbc73a6
6 changed files with 19 additions and 25 deletions
|
|
@ -106,12 +106,8 @@ export const saveEmail = async (
|
|||
|
||||
// create a task to update thumbnail and pre-cache all images
|
||||
try {
|
||||
const taskId = await enqueueThumbnailTask(
|
||||
ctx.uid,
|
||||
slug,
|
||||
articleToSave.content
|
||||
)
|
||||
logger.info('Created thumbnail task', taskId)
|
||||
const taskId = await enqueueThumbnailTask(ctx.uid, slug)
|
||||
logger.info('Created thumbnail task', { taskId })
|
||||
} catch (e) {
|
||||
logger.error('Failed to create thumbnail task', e)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,12 +187,8 @@ export const savePage = async (
|
|||
|
||||
// create a task to update thumbnail and pre-cache all images
|
||||
try {
|
||||
const taskId = await enqueueThumbnailTask(
|
||||
saver.userId,
|
||||
slug,
|
||||
articleToSave.content
|
||||
)
|
||||
logger.info('Created thumbnail task', taskId)
|
||||
const taskId = await enqueueThumbnailTask(saver.userId, slug)
|
||||
logger.info('Created thumbnail task', { taskId })
|
||||
} catch (e) {
|
||||
logger.error('Failed to create thumbnail task', e)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import View = google.cloud.tasks.v2.Task.View
|
|||
// Instantiates a client.
|
||||
const client = new CloudTasksClient()
|
||||
|
||||
const logError = (error: Error): void => {
|
||||
const logError = (error: any): void => {
|
||||
if (axios.isAxiosError(error)) {
|
||||
logger.error(error.response)
|
||||
} else {
|
||||
|
|
@ -102,7 +102,12 @@ const createHttpTaskWithToken = async ({
|
|||
: null,
|
||||
}
|
||||
|
||||
return client.createTask({ parent, task })
|
||||
try {
|
||||
return client.createTask({ parent, task })
|
||||
} catch (error) {
|
||||
logError(error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export const createAppEngineTask = async ({
|
||||
|
|
@ -526,14 +531,12 @@ export const enqueueImportFromIntegration = async (
|
|||
|
||||
export const enqueueThumbnailTask = async (
|
||||
userId: string,
|
||||
slug: string,
|
||||
content: string
|
||||
slug: string
|
||||
): Promise<string> => {
|
||||
const { GOOGLE_CLOUD_PROJECT } = process.env
|
||||
const payload = {
|
||||
userId,
|
||||
slug,
|
||||
content,
|
||||
}
|
||||
|
||||
const headers = {
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ export const isUrl = (str: string): boolean => {
|
|||
validateUrl(str)
|
||||
return true
|
||||
} catch {
|
||||
logger.error('not an url', str)
|
||||
logger.info('not an url', { url: str })
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -505,9 +505,9 @@ export const fetchFavicon = async (
|
|||
return `https://api.faviconkit.com/${domain}/128`
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logger.error('failed to get favicon:', e.response?.status)
|
||||
logger.error('failed to get favicon', e.response)
|
||||
} else {
|
||||
logger.error('failed to get favicon:', e)
|
||||
logger.error('failed to get favicon', e)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ interface UpdatePageResponse {
|
|||
|
||||
interface ThumbnailRequest {
|
||||
slug: string
|
||||
content: string
|
||||
}
|
||||
|
||||
interface ImageSize {
|
||||
|
|
@ -188,7 +187,7 @@ const updatePageMutation = async (
|
|||
}
|
||||
|
||||
const isThumbnailRequest = (body: any): body is ThumbnailRequest => {
|
||||
return 'slug' in body && 'content' in body
|
||||
return 'slug' in body
|
||||
}
|
||||
|
||||
const fetchImage = async (url: string): Promise<AxiosResponse | null> => {
|
||||
|
|
@ -201,7 +200,7 @@ const fetchImage = async (url: string): Promise<AxiosResponse | null> => {
|
|||
maxContentLength: 20000000, // 20mb
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.log('fetch image error', e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
@ -334,7 +333,7 @@ export const thumbnailHandler = Sentry.GCPFunction.wrapHttpFunction(
|
|||
return res.status(400).send('BAD_REQUEST')
|
||||
}
|
||||
|
||||
const { slug, content } = req.body
|
||||
const { slug } = req.body
|
||||
|
||||
try {
|
||||
const page = await articleQuery(uid, slug)
|
||||
|
|
@ -352,7 +351,7 @@ export const thumbnailHandler = Sentry.GCPFunction.wrapHttpFunction(
|
|||
|
||||
console.log('pre-caching all images...')
|
||||
// pre-cache all images in the content and get their sizes
|
||||
const imageSizes = await fetchAllImageSizes(content)
|
||||
const imageSizes = await fetchAllImageSizes(page.content)
|
||||
// find thumbnail from all images if thumbnail not set
|
||||
if (!page.image && imageSizes.length > 0) {
|
||||
console.log('finding thumbnail...')
|
||||
|
|
|
|||
Loading…
Reference in a new issue