@andrey4emk/npm-app-back-b24 0.6.9 → 0.6.11
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/package.json +1 -1
- package/sendMessage/wappi.js +9 -7
package/package.json
CHANGED
package/sendMessage/wappi.js
CHANGED
|
@@ -21,6 +21,7 @@ export class Wappi {
|
|
|
21
21
|
this.whatsAppAuth = whatsAppAuth;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// bot_id=1 нужно чтобы сообщение отображалось в открытой линии Битрикс24
|
|
24
25
|
async sendMessageWappi(messangerType, messageData) {
|
|
25
26
|
if (!["whatsApp"].includes(messangerType) && !["telegram"].includes(messangerType) && !["max"].includes(messangerType)) {
|
|
26
27
|
return { error: true, message: "Неверный тип мессенджера", data: null };
|
|
@@ -39,12 +40,12 @@ export class Wappi {
|
|
|
39
40
|
if (messangerType === "telegram") {
|
|
40
41
|
token = this.telegaAuth.token;
|
|
41
42
|
profile_id = this.telegaAuth.profile_id;
|
|
42
|
-
url = `https://wappi.pro/tapi/sync/message/send?profile_id=${profile_id}`;
|
|
43
|
+
url = `https://wappi.pro/tapi/sync/message/send?bot_id=1&profile_id=${profile_id}`;
|
|
43
44
|
}
|
|
44
45
|
if (messangerType === "max") {
|
|
45
46
|
token = this.maxAuth.token;
|
|
46
47
|
profile_id = this.maxAuth.profile_id;
|
|
47
|
-
url = `https://wappi.pro/maxapi/sync/message/send?profile_id=${profile_id}`;
|
|
48
|
+
url = `https://wappi.pro/maxapi/sync/message/send?bot_id=1&profile_id=${profile_id}`;
|
|
48
49
|
}
|
|
49
50
|
let res = await fetch(url, {
|
|
50
51
|
method: "POST",
|
|
@@ -84,6 +85,7 @@ export class Wappi {
|
|
|
84
85
|
let token;
|
|
85
86
|
let profile_id;
|
|
86
87
|
let base64;
|
|
88
|
+
|
|
87
89
|
if (messangerType === "whatsApp") {
|
|
88
90
|
url = ``;
|
|
89
91
|
}
|
|
@@ -99,21 +101,21 @@ export class Wappi {
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
if (fileName.includes(".pdf")) {
|
|
102
|
-
url = `https://wappi.pro/tapi/sync/message/document/send?profile_id=${profile_id}`;
|
|
104
|
+
url = `https://wappi.pro/tapi/sync/message/document/send?bot_id=1&profile_id=${profile_id}`;
|
|
103
105
|
}
|
|
104
106
|
// Если отправили картинку .png, .jpg и т.д.
|
|
105
107
|
if (fileName.includes(".png" || ".jpg" || ".jpeg" || ".gif")) {
|
|
106
|
-
url = `https://wappi.pro/tapi/sync/message/img/send?profile_id=${profile_id}`;
|
|
108
|
+
url = `https://wappi.pro/tapi/sync/message/img/send?bot_id=1&profile_id=${profile_id}`;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
if (messangerType === "max") {
|
|
110
112
|
token = this.maxAuth.token;
|
|
111
113
|
profile_id = this.maxAuth.profile_id;
|
|
112
|
-
url = `https://wappi.pro/maxapi/async/message/file/url/send?profile_id=${profile_id}`;
|
|
114
|
+
url = `https://wappi.pro/maxapi/async/message/file/url/send?bot_id=1&profile_id=${profile_id}`;
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
// Max при отправке pdf не прикрепляет сообщение caption: message, поэтому отправляем его отдельно
|
|
116
|
-
if (fileName.includes(".pdf")) {
|
|
118
|
+
if (fileName.includes(".pdf") && messangerType === "max") {
|
|
117
119
|
await this.sendMessageWappi(messangerType, { phone: phone, message: message });
|
|
118
120
|
}
|
|
119
121
|
console.log("base64:", base64);
|
|
@@ -126,7 +128,7 @@ export class Wappi {
|
|
|
126
128
|
|
|
127
129
|
body: JSON.stringify({
|
|
128
130
|
recipient: phone,
|
|
129
|
-
|
|
131
|
+
url: fileUrl,
|
|
130
132
|
file_name: fileName,
|
|
131
133
|
caption: message,
|
|
132
134
|
b64_file: base64,
|