@gamastudio/sendwave-provider 0.0.15 → 0.0.17

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.
@@ -7,6 +7,8 @@ export interface ParsedMessage {
7
7
  type: string;
8
8
  media?: string;
9
9
  caption?: string;
10
+ remoteJid: string;
11
+ remoteJidAlt: string;
10
12
  originalPayload: {
11
13
  key: any;
12
14
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamastudio/sendwave-provider",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Librería para interactuar con Sendwave usando configuración dinámica.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "author": "Ameth Galarcio <amethgm@gmail.com>",
23
23
  "license": "ISC",
24
24
  "dependencies": {
25
- "@builderbot/bot": "^1.3.11",
25
+ "@builderbot/bot": "^1.3.15",
26
26
  "@gamastudio/colorslog": "^0.1.8",
27
27
  "@types/mime-types": "^3.0.1",
28
28
  "axios": "^1.13.2",
@@ -29,7 +29,7 @@ class SendWaveCore extends node_events_1.EventEmitter {
29
29
  var _a;
30
30
  try {
31
31
  const { body } = req;
32
- if (!["messages.upsert", "send_message"].includes(body.event)) {
32
+ if (!["messages.upsert", "send.message"].includes(body.event)) {
33
33
  return res.end("Message queued");
34
34
  }
35
35
  const data = (0, parserMsg_1.parseIncomingMsg)(body);
@@ -27,7 +27,9 @@ class SenderMessage {
27
27
  this.sendwaveApi.interceptors.response.use((response) => response, async (error) => {
28
28
  const config = error.config || {};
29
29
  config.__retryCount = config.__retryCount || 0;
30
- const shouldRetry = error.code === 'ECONNRESET' || error.code === 'ETIMEDOUT' || (error.response && error.response.status >= 500);
30
+ const shouldRetry = error.code === "ECONNRESET" ||
31
+ error.code === "ETIMEDOUT" ||
32
+ (error.response && error.response.status >= 500);
31
33
  if (shouldRetry && config.__retryCount < 3) {
32
34
  config.__retryCount += 1;
33
35
  const delay = Math.min(1000 * Math.pow(2, config.__retryCount), 8000);
@@ -327,7 +329,9 @@ class SenderMessage {
327
329
  }));
328
330
  }
329
331
  catch (error) {
330
- const msg = ((_e = (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.message) || (error === null || error === void 0 ? void 0 : error.message) || "Unknown error";
332
+ const msg = ((_e = (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.message) ||
333
+ (error === null || error === void 0 ? void 0 : error.message) ||
334
+ "Unknown error";
331
335
  console.error(`[sendButton Error] ${msg}`);
332
336
  throw new Error(msg);
333
337
  }
@@ -345,7 +349,9 @@ class SenderMessage {
345
349
  }));
346
350
  }
347
351
  catch (error) {
348
- const msg = ((_e = (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.message) || (error === null || error === void 0 ? void 0 : error.message) || "Unknown error";
352
+ const msg = ((_e = (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.message) ||
353
+ (error === null || error === void 0 ? void 0 : error.message) ||
354
+ "Unknown error";
349
355
  console.error(`[sendLocation Error] ${msg}`);
350
356
  throw new Error(msg);
351
357
  }
@@ -360,7 +366,9 @@ class SenderMessage {
360
366
  }));
361
367
  }
362
368
  catch (error) {
363
- const msg = ((_e = (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.message) || (error === null || error === void 0 ? void 0 : error.message) || "Unknown error";
369
+ const msg = ((_e = (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.message) ||
370
+ (error === null || error === void 0 ? void 0 : error.message) ||
371
+ "Unknown error";
364
372
  console.error(`[sendReaction Error] ${msg}`);
365
373
  throw new Error(msg);
366
374
  }
@@ -13,7 +13,10 @@ function parseIncomingMsg(payload) {
13
13
  }
14
14
  // if (msg.key.fromMe) return null
15
15
  const fromMe = msg.key.fromMe;
16
- const from = (((_a = msg.key) === null || _a === void 0 ? void 0 : _a.remoteJid) || "").split("@")[0].split(":")[0];
16
+ const remoteJid = msg.key.remoteJidAlt || "";
17
+ const remoteJidAlt = msg.key.remoteJidAlt;
18
+ const from = (((_a = msg.key) === null || _a === void 0 ? void 0 : _a.remoteJidAlt) || "").split("@")[0].split(":")[0];
19
+ // const from = (msg.key?.remoteJid || "")
17
20
  const to = payload.instance || "";
18
21
  const name = msg.pushName;
19
22
  const messageContent = msg.message || {};
@@ -87,6 +90,8 @@ function parseIncomingMsg(payload) {
87
90
  }
88
91
  return {
89
92
  fromMe,
93
+ remoteJid,
94
+ remoteJidAlt,
90
95
  from,
91
96
  to,
92
97
  name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamastudio/sendwave-provider",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Librería para interactuar con Sendwave usando configuración dinámica.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "author": "Ameth Galarcio <amethgm@gmail.com>",
23
23
  "license": "ISC",
24
24
  "dependencies": {
25
- "@builderbot/bot": "^1.3.11",
25
+ "@builderbot/bot": "^1.3.15",
26
26
  "@gamastudio/colorslog": "^0.1.8",
27
27
  "@types/mime-types": "^3.0.1",
28
28
  "axios": "^1.13.2",