Merge pull request #3696 from omnivore-app/fix/thumbnail

fix/thumbnail
This commit is contained in:
Hongbo Wu 2024-03-20 10:26:34 +08:00 committed by GitHub
commit 7e04b25497
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 8 deletions

View file

@ -48,12 +48,14 @@ export const isRefreshFeedRequest = (data: any): data is RefreshFeedRequest => {
// link can be a string or an object
type RssFeedItemLink = string | { $: { rel?: string; href: string } }
type RssFeedItemAuthor = string | { name: string }
type RssFeed = Parser.Output<{
published?: string
updated?: string
created?: string
link?: RssFeedItemLink
links?: RssFeedItemLink[]
author?: RssFeedItemAuthor
}> & {
lastBuildDate?: string
'syn:updatePeriod'?: string
@ -386,6 +388,7 @@ const parser = new Parser({
'created',
['media:content', 'media:content', { keepArray: true }],
['media:thumbnail'],
'author',
],
feed: [
'lastBuildDate',
@ -473,6 +476,14 @@ const getLink = (
return url
}
// get author
const getAuthor = (author: RssFeedItemAuthor) => {
if (typeof author === 'string') {
return author
}
return author.name
}
const processSubscription = async (
fetchContentTasks: Map<string, FetchContentTask>,
subscriptionId: string,
@ -536,10 +547,13 @@ const processSubscription = async (
throw new Error('Invalid feed item link')
}
const creator = item.creator || (item.author && getAuthor(item.author))
const feedItem = {
...item,
isoDate,
link,
creator,
}
const publishedAt = feedItem.isoDate

View file

@ -229,8 +229,8 @@ export const subscribeResolver = authorized<
...existingSubscription,
fetchContentType: input.fetchContentType
? (input.fetchContentType as FetchContentType)
: undefined,
folder: input.folder ?? undefined,
: existingSubscription.fetchContentType,
folder: input.folder ?? existingSubscription.folder,
isPrivate: input.isPrivate,
status: SubscriptionStatus.Active,
})

View file

@ -103,7 +103,7 @@ export const savePage = async (
}
}
const parseResult = await parsePreparedContent(input.url, {
const preparedDocument: PreparedDocumentInput = {
document: input.originalContent,
pageInfo: {
title: input.title,
@ -111,7 +111,9 @@ export const savePage = async (
previewImage: input.previewImage,
author: input.author,
},
})
}
const parseResult = await parsePreparedContent(input.url, preparedDocument)
const itemToSave = parsedContentToLibraryItem({
itemId: clientRequestId,
@ -131,6 +133,7 @@ export const savePage = async (
folder: input.folder,
feedContent: input.feedContent,
dir: parseResult.parsedContent?.dir,
preparedDocument,
})
const isImported =
input.source === 'csv-importer' || input.source === 'pocket'
@ -247,7 +250,7 @@ export const parsedContentToLibraryItem = ({
croppedPathname ||
parsedContent?.siteName ||
url,
author: parsedContent?.byline,
author: preparedDocument?.pageInfo.author || parsedContent?.byline,
originalUrl: cleanUrl(canonicalUrl || url),
itemType,
textContentHash:

View file

@ -2049,14 +2049,14 @@ Readability.prototype = {
values["article:date"];
// get preview image
metadata.previewImage = jsonld.previewImage ||
values["image"] ||
metadata.previewImage = values["image"] ||
values["twitter:image"] ||
values["dc:image"] ||
values["dcterm:image"] ||
values["og:image"] ||
values["weibo:article:image"] ||
values["weibo:webpage:image"];
values["weibo:webpage:image"] ||
jsonld.previewImage
metadata.locale = values["og:locale"];