@andrey4emk/npm-app-back-b24 0.6.11 → 0.6.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrey4emk/npm-app-back-b24",
3
- "version": "0.6.11",
3
+ "version": "0.6.13",
4
4
  "description": "Bitrix24 OAuth helpers for Node.js projects",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -35,7 +35,9 @@ export class Wappi {
35
35
  let token;
36
36
  let profile_id;
37
37
  if (messangerType === "whatsApp") {
38
- url = ``;
38
+ token = this.whatsAppAuth.token;
39
+ profile_id = this.whatsAppAuth.profile_id;
40
+ url = `https://wappi.pro/api/async/message/send?bot_id=1&profile_id=${profile_id}`;
39
41
  }
40
42
  if (messangerType === "telegram") {
41
43
  token = this.telegaAuth.token;
@@ -87,7 +89,23 @@ export class Wappi {
87
89
  let base64;
88
90
 
89
91
  if (messangerType === "whatsApp") {
90
- url = ``;
92
+ token = this.whatsAppAuth.token;
93
+ profile_id = this.whatsAppAuth.profile_id;
94
+ // скачивам файл и конвертируем в base64
95
+ let resConvert = await this.convertToBase64(fileUrl);
96
+ if (resConvert.error) {
97
+ return { error: true, message: `Ошибка при конвертации файла в base64 для WhatsApp: ${resConvert.message}`, data: null };
98
+ } else {
99
+ base64 = resConvert.data;
100
+ }
101
+
102
+ if (fileName.includes(".pdf")) {
103
+ url = `https://wappi.pro/api/async/message/document/send?bot_id=1&profile_id=${profile_id}`;
104
+ }
105
+ // Если отправили картинку .png, .jpg и т.д.
106
+ if (fileName.includes(".png") || fileName.includes(".jpg") || fileName.includes(".jpeg") || fileName.includes(".gif")) {
107
+ url = `https://wappi.pro/api/async/message/img/send?bot_id=1&profile_id=${profile_id}`;
108
+ }
91
109
  }
92
110
  if (messangerType === "telegram") {
93
111
  token = this.telegaAuth.token;
@@ -104,7 +122,7 @@ export class Wappi {
104
122
  url = `https://wappi.pro/tapi/sync/message/document/send?bot_id=1&profile_id=${profile_id}`;
105
123
  }
106
124
  // Если отправили картинку .png, .jpg и т.д.
107
- if (fileName.includes(".png" || ".jpg" || ".jpeg" || ".gif")) {
125
+ if (fileName.includes(".png") || fileName.includes(".jpg") || fileName.includes(".jpeg") || fileName.includes(".gif")) {
108
126
  url = `https://wappi.pro/tapi/sync/message/img/send?bot_id=1&profile_id=${profile_id}`;
109
127
  }
110
128
  }
@@ -153,7 +171,9 @@ export class Wappi {
153
171
  let token;
154
172
  let profile_id;
155
173
  if (messangerType === "whatsApp") {
156
- url = ``;
174
+ token = this.whatsAppAuth.token;
175
+ profile_id = this.whatsAppAuth.profile_id;
176
+ url = `https://wappi.pro/api/sync/contact/check?profile_id=${profile_id}&phone=${phone}`;
157
177
  }
158
178
  if (messangerType === "telegram") {
159
179
  // 1 Проверяем существует контакт или нет.
@@ -195,7 +215,7 @@ export class Wappi {
195
215
  } else {
196
216
  // Проверяем нашли max или нет
197
217
  data.check = false;
198
- if (data.detail === "found" || data.on_max) {
218
+ if (data.detail === "found" || data.on_max || data.on_whatsapp) {
199
219
  data.check = true;
200
220
  }
201
221
  return { error: false, message: `Номер ${phone} проверен для мессенджера ${messangerType}`, data: data };