diff --git a/corrupt-photo.jpg b/corrupt-photo.jpg new file mode 100644 index 0000000..df39d0c Binary files /dev/null and b/corrupt-photo.jpg differ diff --git a/src/handlers/adminProductHandler.js b/src/handlers/adminProductHandler.js index a6860b4..6e8bc2d 100644 --- a/src/handlers/adminProductHandler.js +++ b/src/handlers/adminProductHandler.js @@ -564,17 +564,22 @@ Coordinates: ${product.hidden_coordinates} // Send product photos if (product.photo_url) { - await this.bot.sendPhoto(chatId, product.photo_url, { caption: 'Public photo' }); + try { + await this.bot.sendPhoto(chatId, product.photo_url, { caption: 'Public photo' }); + } catch (e) { + await this.bot.sendPhoto(chatId, "./corrupt-photo.jpg", { caption: 'Public photo' }) + } } if (product.hidden_photo_url) { - await this.bot.sendPhoto(chatId, product.hidden_photo_url, { caption: 'Hidden photo' }); + try { + await this.bot.sendPhoto(chatId, product.hidden_photo_url, { caption: 'Hidden photo' }); + } catch (e) { + await this.bot.sendPhoto(chatId, "./corrupt-photo.jpg", { caption: 'Hidden photo' }) + } } - await this.bot.editMessageText(message, { - chat_id: chatId, - message_id: messageId, - reply_markup: keyboard - }); + await this.bot.deleteMessage(chatId, messageId); + await this.bot.sendMessage(chatId, message, { reply_markup: keyboard }); } catch (error) { console.error('Error in handleViewProduct:', error); await this.bot.sendMessage(chatId, 'Error loading product details. Please try again.');