A full-featured CRM built with React, shadcn/ui, and Supabase.
Use a more robust company avatar discovery service
fzaninotto48bc83ce6655
diff --git a/src/atomic-crm/providers/commons/getCompanyAvatar.ts b/src/atomic-crm/providers/commons/getCompanyAvatar.tsindex b515c433..f844d9b0 100644--- a/src/atomic-crm/providers/commons/getCompanyAvatar.ts+++ b/src/atomic-crm/providers/commons/getCompanyAvatar.ts@@ -1,42 +1,21 @@-import { fetchWithTimeout } from "../../misc/fetchWithTimeout";import type { Company } from "../../types";-// Helper function to get the favicon URL-async function getFaviconUrl(website: string): Promise<string | null> {- try {- // get favicon from domain- const url = new URL(website);- const domain = url.origin;- const faviconUrl = `${domain}/favicon.ico`;- const response = await fetchWithTimeout(faviconUrl);- if (response.ok) {- return faviconUrl;- }- } catch {- return null;- }- return null;-}-// Main function to get the avatar URLexport async function getCompanyAvatar(record: Partial<Company>): Promise<{src: string;title: string;} | null> {+ // TODO: Step 1: Try to get image from LinkedIn.++ // Step 2: Fallback to the favicon from website domainif (!record.website) {return null;}-- // Step 1: Try to get favicon from website domain- const faviconUrl = await getFaviconUrl(record.website);- if (faviconUrl) {- return {- src: faviconUrl,- title: "Company favicon",- };- }-- // TODO: Step 2: Try to get image from LinkedIn.-- return null;+ const websiteUrlWithoutScheme = record.website+ .replace(/^https?:\/\//, "")+ .replace(/\/$/, "");+ return {+ src: `https://favicon.show/${websiteUrlWithoutScheme}`,+ title: "Company favicon",+ };}