From 77da28e980cebfa4538522932c932befe3ec7175 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sat, 1 Jun 2024 18:52:03 -0300 Subject: [PATCH] fix(whatsapp.lib): Sending of images in official. --- packages/kb.gbapp/services/KBService.ts | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/kb.gbapp/services/KBService.ts b/packages/kb.gbapp/services/KBService.ts index ce894863..34206385 100644 --- a/packages/kb.gbapp/services/KBService.ts +++ b/packages/kb.gbapp/services/KBService.ts @@ -1047,19 +1047,24 @@ export class KBService implements IGBKBService { const logoPath = Path.join(process.env.PWD, 'work', path, 'cache'); const baseUrl = page.url().split('/').slice(0, 3).join('/'); logo = logo.startsWith('https') ? logo : urlJoin(baseUrl, logo); - const logoBinary = await page.goto(logo); - const buffer = await logoBinary.buffer(); - const logoFilename = Path.basename(logo); - sharp(buffer) - .resize({ - width: 48, - height: 48, - fit: 'inside', // Resize the image to fit within the specified dimensions - withoutEnlargement: true // Don't enlarge the image if its dimensions are already smaller - }) - .toFile(Path.join(logoPath, logoFilename)); + + try { + const logoBinary = await page.goto(logo); + const buffer = await logoBinary.buffer(); + const logoFilename = Path.basename(logo); + sharp(buffer) + .resize({ + width: 48, + height: 48, + fit: 'inside', // Resize the image to fit within the specified dimensions + withoutEnlargement: true // Don't enlarge the image if its dimensions are already smaller + }) + .toFile(Path.join(logoPath, logoFilename)); + await min.core['setConfig'](min, 'Logo', logoFilename); + } catch (error) { + GBLogEx.debug(min, error); + } - await min.core['setConfig'](min, 'Logo', logoFilename); } // Extract dominant colors from the screenshot