diff --git a/src/Utils/messages-media.ts b/src/Utils/messages-media.ts index 76207614..98c107fc 100644 --- a/src/Utils/messages-media.ts +++ b/src/Utils/messages-media.ts @@ -1,5 +1,5 @@ import { Boom } from '@hapi/boom' -import { exec } from 'child_process' +import { execFile } from 'child_process' import * as Crypto from 'crypto' import { once } from 'events' import { createReadStream, createWriteStream, promises as fs, WriteStream } from 'fs' @@ -127,8 +127,7 @@ const extractVideoThumb = async ( size: { width: number; height: number } ) => new Promise((resolve, reject) => { - const cmd = `ffmpeg -ss ${time} -i ${path} -y -vf scale=${size.width}:-1 -vframes 1 -f image2 ${destPath}` - exec(cmd, err => { + execFile('ffmpeg', ['-ss', time, '-i', path, '-y', '-vf', `scale=${size.width}:-1`, '-vframes', '1', '-f', 'image2', destPath], err => { if (err) { reject(err) } else { diff --git a/src/Utils/messages.ts b/src/Utils/messages.ts index 70690031..5f6016bb 100644 --- a/src/Utils/messages.ts +++ b/src/Utils/messages.ts @@ -288,7 +288,7 @@ export const prepareWAMessageMedia = async ( logger?.debug('computed backgroundColor audio status') } } catch (error) { - logger?.warn({ trace: (error as any).stack }, 'failed to obtain extra info') + logger?.warn({ trace: error instanceof Error ? error.stack : String(error) }, 'failed to obtain extra info') } })() ]).finally(async () => { @@ -390,8 +390,8 @@ export const hasNonNullishProperty = ( typeof message === 'object' && message !== null && key in message && - (message as any)[key] !== null && - (message as any)[key] !== undefined + (message as Record)[key] !== null && + (message as Record)[key] !== undefined ) } @@ -1153,7 +1153,7 @@ export const generateListMessageLegacy = ( } function hasOptionalProperty(obj: T, key: K): obj is WithKey { - return typeof obj === 'object' && obj !== null && key in obj && (obj as any)[key] !== null + return typeof obj === 'object' && obj !== null && key in obj && (obj as Record)[key] !== null } export const generateWAMessageContent = async ( @@ -2034,7 +2034,7 @@ export function getAggregateResponsesInEventMessage( } for (const update of eventResponses || []) { - const responseType = (update as any).eventResponse || 'UNKNOWN' + const responseType = (update as unknown as { eventResponse?: string }).eventResponse || 'UNKNOWN' if (responseType !== 'UNKNOWN' && responseMap[responseType]) { responseMap[responseType].responders.push(getKeyAuthor(update.eventResponseMessageKey, meId)) }