mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: log thumb gen errors
This commit is contained in:
@@ -607,7 +607,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
userJid,
|
||||
getUrlInfo: text => getUrlInfo(
|
||||
text,
|
||||
{ thumbnailWidth: linkPreviewImageThumbnailWidth, timeoutMs: 3_000 }
|
||||
{ thumbnailWidth: linkPreviewImageThumbnailWidth, timeoutMs: 3_000 },
|
||||
logger
|
||||
),
|
||||
upload: waUploadToServer,
|
||||
mediaCache: config.mediaCache,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Logger } from 'pino'
|
||||
import { WAUrlInfo } from '../Types'
|
||||
import { extractImageThumb, getHttpStream } from './messages-media'
|
||||
|
||||
@@ -23,7 +24,8 @@ export type URLGenerationOptions = {
|
||||
*/
|
||||
export const getUrlInfo = async(
|
||||
text: string,
|
||||
opts: URLGenerationOptions = { thumbnailWidth: THUMBNAIL_WIDTH_PX, timeoutMs: 3000 }
|
||||
opts: URLGenerationOptions = { thumbnailWidth: THUMBNAIL_WIDTH_PX, timeoutMs: 3000 },
|
||||
logger?: Logger
|
||||
): Promise<WAUrlInfo | undefined> => {
|
||||
try {
|
||||
const { getLinkPreview } = await import('link-preview-js')
|
||||
@@ -42,6 +44,10 @@ export const getUrlInfo = async(
|
||||
? await getCompressedJpegThumbnail(image, opts)
|
||||
: undefined
|
||||
} catch(error) {
|
||||
logger?.debug(
|
||||
{ err: error.stack, url: previewLink },
|
||||
'error in generating thumbnail'
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user