mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fetch subscription's favicon if the site icon is base64 encoded image
This commit is contained in:
parent
990759da73
commit
22e92256eb
2 changed files with 7 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ import { saveSubscription } from './subscriptions'
|
|||
import { NewsletterEmail } from '../entity/newsletter_email'
|
||||
import { fetchFavicon } from '../utils/parser'
|
||||
import { updatePage } from '../elastic/pages'
|
||||
import { isBase64Image } from '../utils/helpers'
|
||||
|
||||
interface NewsletterMessage {
|
||||
email: string
|
||||
|
|
@ -69,8 +70,8 @@ export const saveNewsletterEmail = async (
|
|||
return false
|
||||
}
|
||||
|
||||
if (!page.siteIcon) {
|
||||
// fetch favicon if not already set
|
||||
if (!page.siteIcon || isBase64Image(page.siteIcon)) {
|
||||
// fetch favicon if not already set or is a base64 image
|
||||
const favicon = await fetchFavicon(page.url)
|
||||
if (favicon) {
|
||||
page.siteIcon = favicon
|
||||
|
|
|
|||
|
|
@ -269,3 +269,7 @@ export const wordsCount = (text: string, isHtml = true): number => {
|
|||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
export const isBase64Image = (str: string): boolean => {
|
||||
return str.startsWith('data:image/')
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue