Loading prisma/schema.prisma +3 −2 Original line number Diff line number Diff line Loading @@ -82,10 +82,11 @@ model Image { entity_uuid String @id @default(uuid()) entity_order Int image_path String? @db.Text image_width Int? image_url_initial String? image_width_initial Int file_width_initial Int file_height_initial Int image_url_initial String? image_width Int? file_width Int? file_height Int? image_scale String? Loading src/controllers/entitiesController.ts +2 −2 Original line number Diff line number Diff line Loading @@ -10,9 +10,9 @@ class EntitiesController { console.log(error); } } async createImage(req: Buffer) { async createImage(req: Buffer, isCropImageNow: boolean) { try { return await EntitiesService.createImage(req); return await EntitiesService.createImage(req, isCropImageNow); } catch (error) { console.log(error); } Loading src/index.ts +8 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import { connectBot } from './telegramBot'; await connectBot(); const users = new Set(); let isCropImageNow: boolean = false; const PORT = Number(process.env.PORT) || 5000; const FILES_PORT = process.env.FILES_PORT || 5001; Loading @@ -22,6 +23,7 @@ wss.on('connection', (ws) => { ws.id = Date.now(); ws.on('message', async (req) => { req = JSON.parse(req); if (req.event === 'setCropNow') isCropImageNow = true; await websocketRoute(req); }); }); Loading @@ -36,8 +38,12 @@ filesWss.on('connection', (ws) => { users.add(ws); console.log('users wss: ', users.size); ws.on('message', async (req: Buffer) => { await EntitiesController.createImage(req); await EntitiesController.createImage(req, isCropImageNow); if (!isCropImageNow) { submitToUsers('createImageEntity', ''); } else { isCropImageNow = false; } }); }); Loading src/routes/telegramBot.ts +0 −22 Original line number Diff line number Diff line Loading @@ -223,25 +223,3 @@ export const onSuggestionResponse = async (chatId, suggestion) => { fs.writeFileSync(imagePath, suggestion); await sendMessageOnStart(chatId); }; // export const sendMessageOn = async (chatId) => { // await bot.sendMessage(chatId, 'Что Вас интересует?', { // reply_markup: { // inline_keyboard: [ // [{ text: 'Параграфы', callback_data: '/textInfo' }], // [{ text: 'Изображения', callback_data: '/imageInfo' }], // [{ text: 'Назад', callback_data: '/start' }] // ] // } // }); // }; // export const sendMessageOn = async (chatId) => { // await bot.sendMessage(chatId, 'Что Вас интересует?', { // reply_markup: { // inline_keyboard: [ // [{ text: 'Параграфы', callback_data: '/textInfo' }], // [{ text: 'Изображения', callback_data: '/imageInfo' }], // [{ text: 'Назад', callback_data: '/start' }] // ] // } // }); // }; src/routes/websocket.ts +1 −2 Original line number Diff line number Diff line Loading @@ -59,8 +59,7 @@ export const websocketRoute = async (req: any) => { break; } case 'cropImage': { const editedEntity = await EntitiesController.cropImage(req); submitToUsers('editEntity', editedEntity); await EntitiesController.cropImage(req); break; } case 'returnOriginalSizeImage': { Loading Loading
prisma/schema.prisma +3 −2 Original line number Diff line number Diff line Loading @@ -82,10 +82,11 @@ model Image { entity_uuid String @id @default(uuid()) entity_order Int image_path String? @db.Text image_width Int? image_url_initial String? image_width_initial Int file_width_initial Int file_height_initial Int image_url_initial String? image_width Int? file_width Int? file_height Int? image_scale String? Loading
src/controllers/entitiesController.ts +2 −2 Original line number Diff line number Diff line Loading @@ -10,9 +10,9 @@ class EntitiesController { console.log(error); } } async createImage(req: Buffer) { async createImage(req: Buffer, isCropImageNow: boolean) { try { return await EntitiesService.createImage(req); return await EntitiesService.createImage(req, isCropImageNow); } catch (error) { console.log(error); } Loading
src/index.ts +8 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import { connectBot } from './telegramBot'; await connectBot(); const users = new Set(); let isCropImageNow: boolean = false; const PORT = Number(process.env.PORT) || 5000; const FILES_PORT = process.env.FILES_PORT || 5001; Loading @@ -22,6 +23,7 @@ wss.on('connection', (ws) => { ws.id = Date.now(); ws.on('message', async (req) => { req = JSON.parse(req); if (req.event === 'setCropNow') isCropImageNow = true; await websocketRoute(req); }); }); Loading @@ -36,8 +38,12 @@ filesWss.on('connection', (ws) => { users.add(ws); console.log('users wss: ', users.size); ws.on('message', async (req: Buffer) => { await EntitiesController.createImage(req); await EntitiesController.createImage(req, isCropImageNow); if (!isCropImageNow) { submitToUsers('createImageEntity', ''); } else { isCropImageNow = false; } }); }); Loading
src/routes/telegramBot.ts +0 −22 Original line number Diff line number Diff line Loading @@ -223,25 +223,3 @@ export const onSuggestionResponse = async (chatId, suggestion) => { fs.writeFileSync(imagePath, suggestion); await sendMessageOnStart(chatId); }; // export const sendMessageOn = async (chatId) => { // await bot.sendMessage(chatId, 'Что Вас интересует?', { // reply_markup: { // inline_keyboard: [ // [{ text: 'Параграфы', callback_data: '/textInfo' }], // [{ text: 'Изображения', callback_data: '/imageInfo' }], // [{ text: 'Назад', callback_data: '/start' }] // ] // } // }); // }; // export const sendMessageOn = async (chatId) => { // await bot.sendMessage(chatId, 'Что Вас интересует?', { // reply_markup: { // inline_keyboard: [ // [{ text: 'Параграфы', callback_data: '/textInfo' }], // [{ text: 'Изображения', callback_data: '/imageInfo' }], // [{ text: 'Назад', callback_data: '/start' }] // ] // } // }); // };
src/routes/websocket.ts +1 −2 Original line number Diff line number Diff line Loading @@ -59,8 +59,7 @@ export const websocketRoute = async (req: any) => { break; } case 'cropImage': { const editedEntity = await EntitiesController.cropImage(req); submitToUsers('editEntity', editedEntity); await EntitiesController.cropImage(req); break; } case 'returnOriginalSizeImage': { Loading