import from json
This commit is contained in:
@@ -449,8 +449,11 @@ export default class AdminProductHandler {
|
||||
}
|
||||
|
||||
const file = await this.bot.getFile(msg.document.file_id);
|
||||
const fileContent = await this.bot.downloadFile(file.file_id, '/tmp');
|
||||
|
||||
const fileContent = await this.bot.downloadFile(file.file_id, '.');
|
||||
jsonContent = await fs.readFile(fileContent, 'utf8');
|
||||
await fs.rm(fileContent);
|
||||
|
||||
} else if (msg.text) {
|
||||
jsonContent = msg.text;
|
||||
} else {
|
||||
@@ -503,9 +506,9 @@ export default class AdminProductHandler {
|
||||
|
||||
this.userStates.delete(chatId);
|
||||
} catch (error) {
|
||||
await db.runAsync('ROLLBACK');
|
||||
console.error('Error importing products:', error);
|
||||
await this.bot.sendMessage(chatId, 'Error importing products. Please check the data and try again.');
|
||||
await db.runAsync('ROLLBACK');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user