@runnerpro/backend 1.8.4 → 1.8.6

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.
@@ -29,11 +29,11 @@ const path_1 = __importDefault(require("path"));
29
29
  const util_1 = require("util");
30
30
  const jimp_1 = __importDefault(require("jimp"));
31
31
  const exifr_1 = __importDefault(require("exifr"));
32
- const axios_1 = __importDefault(require("axios"));
33
32
  const index_1 = require("../../index");
34
33
  const common_1 = require("@runnerpro/common");
35
34
  const index_2 = require("../../locale/index");
36
35
  const multer_1 = __importDefault(require("multer"));
36
+ const axios_1 = __importDefault(require("axios"));
37
37
  const conversationRoute = (_a) => {
38
38
  var { router } = _a, params = __rest(_a, ["router"]);
39
39
  const uploadFile = (0, multer_1.default)({
@@ -44,7 +44,6 @@ const conversationRoute = (_a) => {
44
44
  },
45
45
  });
46
46
  router.get('/conversation', (req, res, next) => getConversation(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
47
- router.get('/conversation/suggestion', (req, res, next) => getConversationSuggestion(req, res).catch((error) => (0, index_1.err)(req, res, error, next)));
48
47
  router.get('/conversation/image/:id', (req, res, next) => getConversationImage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
49
48
  router.get('/conversation/file/:id', (req, res, next) => getConversationFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
50
49
  router.post('/conversation/send', (req, res, next) => sendMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
@@ -139,27 +138,6 @@ const getChatFile = ({ query, bucket, id, isClient, userid }) => __awaiter(void
139
138
  return null;
140
139
  }
141
140
  });
142
- const getConversationSuggestion = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
143
- let result;
144
- try {
145
- result = yield axios_1.default
146
- .post(`${process.env.BACKEND_IA_URL}/api/chat/suggestion`, { userId: req.query.user }, {
147
- headers: {
148
- 'ngrok-skip-browser-warning': true, // working with ngrok
149
- 'Content-Type': 'application/json',
150
- Authorization: `Bearer ${process.env.IA_ACCESS_TOKEN}`,
151
- },
152
- })
153
- .then((response) => response.data);
154
- }
155
- catch (e) {
156
- (0, index_1.err)(null, null, e, null);
157
- result = { error: 'Ha habido un error con el servidor' };
158
- }
159
- finally {
160
- res.send(result);
161
- }
162
- });
163
141
  const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
164
142
  const { text, replyMessageId } = req.body;
165
143
  const { userid } = req.session;
@@ -182,6 +160,14 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
182
160
  body: `Rubén: ${textPreferredLanguage || textSpanish}`,
183
161
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
184
162
  });
163
+ // Enviar a N8N lo que ha escrito el entrenador
164
+ const [lastSuggestionMsg] = yield query('SELECT [ID] FROM [CHAT MESSAGE] WHERE [ID CLIENTE] = ? AND [SUGGESTION TEXT] IS NOT NULL ORDER BY [ID] DESC LIMIT 1', [idCliente]);
165
+ if (lastSuggestionMsg) {
166
+ yield axios_1.default.put(`${process.env.N8N_URL}/edc2484f-7010-44c1-8c1d-82924496a2eb`, {
167
+ id: lastSuggestionMsg.id,
168
+ msg: textSpanish,
169
+ });
170
+ }
185
171
  }
186
172
  res.send({ status: 'ok' });
187
173
  });
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAkBpD,CAAC;AAyRF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAiBpD,CAAC;AA4QF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"