Commit 9125b327 authored by Дмитрий Малюгин's avatar Дмитрий Малюгин 🕓
Browse files

finished to change image architecture

parent 82edf1fb
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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?
+2 −2
Original line number Diff line number Diff line
@@ -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);
    }
+8 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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);
  });
});
@@ -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;
    }
  });
});

+0 −22
Original line number Diff line number Diff line
@@ -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' }]
//       ]
//     }
//   });
// };
+1 −2
Original line number Diff line number Diff line
@@ -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