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,
|
userJid,
|
||||||
getUrlInfo: text => getUrlInfo(
|
getUrlInfo: text => getUrlInfo(
|
||||||
text,
|
text,
|
||||||
{ thumbnailWidth: linkPreviewImageThumbnailWidth, timeoutMs: 3_000 }
|
{ thumbnailWidth: linkPreviewImageThumbnailWidth, timeoutMs: 3_000 },
|
||||||
|
logger
|
||||||
),
|
),
|
||||||
upload: waUploadToServer,
|
upload: waUploadToServer,
|
||||||
mediaCache: config.mediaCache,
|
mediaCache: config.mediaCache,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Logger } from 'pino'
|
||||||
import { WAUrlInfo } from '../Types'
|
import { WAUrlInfo } from '../Types'
|
||||||
import { extractImageThumb, getHttpStream } from './messages-media'
|
import { extractImageThumb, getHttpStream } from './messages-media'
|
||||||
|
|
||||||
@@ -23,7 +24,8 @@ export type URLGenerationOptions = {
|
|||||||
*/
|
*/
|
||||||
export const getUrlInfo = async(
|
export const getUrlInfo = async(
|
||||||
text: string,
|
text: string,
|
||||||
opts: URLGenerationOptions = { thumbnailWidth: THUMBNAIL_WIDTH_PX, timeoutMs: 3000 }
|
opts: URLGenerationOptions = { thumbnailWidth: THUMBNAIL_WIDTH_PX, timeoutMs: 3000 },
|
||||||
|
logger?: Logger
|
||||||
): Promise<WAUrlInfo | undefined> => {
|
): Promise<WAUrlInfo | undefined> => {
|
||||||
try {
|
try {
|
||||||
const { getLinkPreview } = await import('link-preview-js')
|
const { getLinkPreview } = await import('link-preview-js')
|
||||||
@@ -42,6 +44,10 @@ export const getUrlInfo = async(
|
|||||||
? await getCompressedJpegThumbnail(image, opts)
|
? await getCompressedJpegThumbnail(image, opts)
|
||||||
: undefined
|
: undefined
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
|
logger?.debug(
|
||||||
|
{ err: error.stack, url: previewLink },
|
||||||
|
'error in generating thumbnail'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user