@runnerpro/backend 1.8.8 → 1.8.10

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.
@@ -153,6 +153,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
153
153
  query,
154
154
  });
155
155
  yield query('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [REPLY MESSAGE ID], [TYPE]) VALUES (?, ?, ?, ?, ?, ?, ?)', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage, replyMessageId, 1]);
156
+ res.send({ status: 'ok' });
156
157
  if (!isClient) {
157
158
  sendNotification({
158
159
  firebaseMessaging,
@@ -169,7 +170,6 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
169
170
  });
170
171
  }
171
172
  }
172
- res.send({ status: 'ok' });
173
173
  });
174
174
  const getPreferredLanguageForChat = ({ text, idCliente, isClient, query }) => __awaiter(void 0, void 0, void 0, function* () {
175
175
  const [{ preferredLanguage }] = yield query('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
@@ -16,10 +16,16 @@ const index_2 = require("../sendNotification/index");
16
16
  const index_3 = require("../db/index");
17
17
  const common_1 = require("@runnerpro/common");
18
18
  const sendMessageChatToClient = (idCliente, text, textPreferredLanguage, preferredLanguage, options) => __awaiter(void 0, void 0, void 0, function* () {
19
- const { notification } = options;
20
- const [entrenador] = yield (0, index_3.query)('SELECT [ID ENTRENADOR] FROM [CLIENTE ENTRENADOR] WHERE [ID CLIENTE] = ? LIMIT 1', [idCliente]);
21
- if (!entrenador)
22
- return;
19
+ const { notification, entrenador } = options;
20
+ let idEntrenador;
21
+ if (entrenador)
22
+ idEntrenador = entrenador;
23
+ else {
24
+ const [entrenadorBBDD] = yield (0, index_3.query)('SELECT [ID ENTRENADOR] FROM [CLIENTE ENTRENADOR] WHERE [ID CLIENTE] = ? LIMIT 1', [idCliente]);
25
+ if (!entrenadorBBDD)
26
+ return;
27
+ idEntrenador = entrenadorBBDD.idEntrenador;
28
+ }
23
29
  if (notification) {
24
30
  try {
25
31
  yield (0, index_2.sendNotification)({
@@ -33,6 +39,6 @@ const sendMessageChatToClient = (idCliente, text, textPreferredLanguage, preferr
33
39
  (0, index_1.err)(null, null, e, null);
34
40
  }
35
41
  }
36
- yield (0, index_3.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [TYPE]) VALUES (?, ?, ?, ?, ?, 1)', [idCliente, entrenador.idEntrenador, text, textPreferredLanguage, preferredLanguage]);
42
+ yield (0, index_3.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [TYPE]) VALUES (?, ?, ?, ?, ?, 1)', [idCliente, idEntrenador, text, textPreferredLanguage, preferredLanguage]);
37
43
  });
38
44
  exports.sendMessageChatToClient = sendMessageChatToClient;
@@ -1 +1 @@
1
- {"version":3,"file":"sendMessageChatToClient.d.ts","sourceRoot":"","sources":["../../../../src/chat/sendMessageChatToClient.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,uBAAuB,gHAsB5B,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"sendMessageChatToClient.d.ts","sourceRoot":"","sources":["../../../../src/chat/sendMessageChatToClient.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,uBAAuB,gHA2B5B,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.8.8",
3
+ "version": "1.8.10",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"