rez_core 3.1.104 → 3.1.105
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.
- package/dist/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.js +9 -6
- package/dist/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.ts +17 -20
- package/.vscode/extensions.json +0 -5
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Injectable, Logger } from '@nestjs/common';
|
|
2
|
-
import axios
|
|
2
|
+
import axios from 'axios';
|
|
3
3
|
import { randomUUID } from 'crypto';
|
|
4
|
-
import {
|
|
5
|
-
IntegrationResult,
|
|
6
|
-
IntegrationStrategy,
|
|
7
|
-
} from '../integration.strategy';
|
|
4
|
+
import { IntegrationResult, IntegrationStrategy } from '../integration.strategy';
|
|
8
5
|
|
|
9
6
|
interface TubelightWhatsAppConfig {
|
|
10
7
|
userName: string;
|
|
@@ -56,24 +53,24 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
|
56
53
|
|
|
57
54
|
const payload = [this.prepareMessagePayload(to, message, config)];
|
|
58
55
|
|
|
59
|
-
console.log(payload)
|
|
56
|
+
console.log(payload);
|
|
60
57
|
|
|
61
|
-
const response
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'Content-Type': 'application/json',
|
|
67
|
-
Authorization: `Bearer ${token}`,
|
|
68
|
-
},
|
|
69
|
-
timeout: 30000,
|
|
58
|
+
const response = await fetch(url, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
Authorization: `Bearer ${token}`,
|
|
70
63
|
},
|
|
71
|
-
|
|
64
|
+
body: JSON.stringify(payload),
|
|
65
|
+
signal: AbortSignal.timeout(30000),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const data = await response.json();
|
|
72
69
|
|
|
73
70
|
if (
|
|
74
71
|
response.status === 200
|
|
75
72
|
) {
|
|
76
|
-
const messageId =
|
|
73
|
+
const messageId = data.messageId || data.id;
|
|
77
74
|
this.logger.log(
|
|
78
75
|
`Tubelight WhatsApp message sent successfully to ${to}, messageId: ${messageId}`,
|
|
79
76
|
);
|
|
@@ -87,8 +84,8 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
|
87
84
|
};
|
|
88
85
|
} else {
|
|
89
86
|
throw new Error(
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
data?.error ||
|
|
88
|
+
data?.message ||
|
|
92
89
|
'Invalid response from Tubelight API',
|
|
93
90
|
);
|
|
94
91
|
}
|
|
@@ -174,7 +171,7 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
|
174
171
|
|
|
175
172
|
// Add body_params if provided
|
|
176
173
|
if (config.variables) {
|
|
177
|
-
console.log(
|
|
174
|
+
console.log('variables', config.variables);
|
|
178
175
|
try {
|
|
179
176
|
// Parse JSON string
|
|
180
177
|
const parsedVariables = typeof config.variables === 'string'
|