@runnerpro/backend 1.6.17 → 1.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,7 +56,7 @@ const getConversation = (req, res, { query, isClient }) => __awaiter(void 0, voi
56
56
  const idCliente = isClient ? req.session.userid : req.query.id;
57
57
  const [header] = yield query('SELECT [NAME], [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
58
58
  let messages = yield query(`SELECT [CHAT MESSAGE].*,
59
- [WORKOUT].[DATE] AS [WORKOUT DATE], [WORKOUT].[TYPE] AS [WORKOUT TYPE], [WORKOUT].[TITLE] AS [WORKOUT TITLE],
59
+ [WORKOUT].[DATE] AS [WORKOUT DATE], [WORKOUT].[TYPE] AS [WORKOUT TYPE], [WORKOUT].[TITLE] AS [WORKOUT TITLE], [WORKOUT].[TITLE PREFERRED LANGUAGE] AS [WORKOUT TITLE],
60
60
  [WORKOUT].[PHOTO URL SHARE] AS [WORKOUT PHOTO URL SHARE], [FEELINGS], [FEELINGS DESCRIPTION]
61
61
  FROM [CHAT MESSAGE]
62
62
  LEFT JOIN [WORKOUT] ON [WORKOUT].[ID] = [CHAT MESSAGE].[ID WORKOUT]
@@ -71,6 +71,8 @@ const getConversation = (req, res, { query, isClient }) => __awaiter(void 0, voi
71
71
  message.text = message.textPreferredLanguage || message.text;
72
72
  if (message.replyMessageId)
73
73
  message.reply = messages.find((m) => m.id === message.replyMessageId);
74
+ if (message.workoutTitlePreferredLanguage)
75
+ message.workoutTitle = message.workoutTitlePreferredLanguage;
74
76
  return message;
75
77
  });
76
78
  }
@@ -225,7 +227,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
225
227
  if (req.file.mimetype.includes('image')) {
226
228
  try {
227
229
  const fileDataResize = yield resizeImage(fileData, filePath, req.file.mimetype);
228
- const fileDataOriented = yield orientationImage(fileData, filePath, null, req.file.mimetype);
230
+ const fileDataOriented = yield rotateOrientationImage(fileData, filePath, null, req.file.mimetype);
229
231
  files.push({ data: fileDataResize, id: idFile });
230
232
  files.push({ data: fileDataOriented, id: `${idFile}-original` });
231
233
  }
@@ -273,24 +275,23 @@ const resizeImage = (data, filePath, mimetype) => __awaiter(void 0, void 0, void
273
275
  const newHeight = Math.round((imageHeight * newWidth) / imageWidth);
274
276
  let image = yield jimp_1.default.read(filePath);
275
277
  image = yield image.resize(newWidth, newHeight);
276
- return orientationImage(data, image, null, mimetype);
278
+ return rotateOrientationImage(data, image, null, mimetype);
277
279
  });
278
- const orientationImage = (data, filePath, image = null, mimetype) => __awaiter(void 0, void 0, void 0, function* () {
280
+ const rotateOrientationImage = (data, filePath, image = null, mimetype) => __awaiter(void 0, void 0, void 0, function* () {
279
281
  if (mimetype.includes('webp'))
280
282
  return data;
281
283
  if (!image)
282
284
  image = yield jimp_1.default.read(filePath);
283
285
  const orientation = yield exifr_1.default.orientation(data);
284
- let rotate = 0;
285
- if (orientation === 6)
286
+ let rotate;
287
+ if ([7, 8].includes(orientation))
286
288
  rotate = 90;
287
- else if (orientation === 8)
288
- rotate = -90;
289
- else if (orientation === 3)
289
+ else if ([3].includes(orientation))
290
290
  rotate = 180;
291
- if (rotate) {
291
+ else if ([5, 8].includes(orientation))
292
+ rotate = -90;
293
+ if (rotate)
292
294
  image = yield image.rotate(rotate);
293
- }
294
295
  return image.getBufferAsync(jimp_1.default.MIME_JPEG);
295
296
  });
296
297
  const saveResponseTime = ({ query, isClient, idCliente }) => __awaiter(void 0, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.6.17",
3
+ "version": "1.6.19",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"