Merge pull request #16 from avoylenko/fix-message-media

Fix media options for message
This commit is contained in:
Anton Voylenko 2025-04-09 21:13:58 +03:00 • committed by GitHub
commit 990318c355
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,10 +71,11 @@ const sendMessage = async (req, res) => {
switch (contentType) { switch (contentType) {
case 'string': case 'string':
if (options?.media) { if (options?.media) {
const media = options.media const { mimetype, data, filename = null, filesize = null } = options.media
media.filename = null if (!mimetype || !data) {
media.filesize = null return sendErrorResponse(res, 400, 'invalid media options')
options.media = new MessageMedia(media.mimetype, media.data, media.filename, media.filesize) }
options.media = new MessageMedia(mimetype, data, filename, filesize)
} }
messageOut = await client.sendMessage(chatId, content, options) messageOut = await client.sendMessage(chatId, content, options)
break break