@meltwater/conversations-api-services 1.3.2 → 1.4.0

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.
Files changed (28) hide show
  1. package/.github/workflows/release.yml +4 -6
  2. package/CLAUDE.md +70 -0
  3. package/dist/cjs/data-access/http/facebook.native.js +122 -106
  4. package/dist/cjs/data-access/http/instagram.native.js +92 -49
  5. package/dist/cjs/data-access/http/linkedin.native.js +135 -56
  6. package/dist/cjs/data-access/http/threads.native.js +53 -18
  7. package/dist/cjs/data-access/http/tiktok.native.js +18 -12
  8. package/dist/cjs/data-access/http/twitter.native.js +142 -40
  9. package/dist/cjs/data-access/http/youtube.native.js +19 -13
  10. package/dist/esm/data-access/http/facebook.native.js +123 -107
  11. package/dist/esm/data-access/http/instagram.native.js +93 -50
  12. package/dist/esm/data-access/http/linkedin.native.js +136 -57
  13. package/dist/esm/data-access/http/threads.native.js +54 -19
  14. package/dist/esm/data-access/http/tiktok.native.js +19 -13
  15. package/dist/esm/data-access/http/twitter.native.js +143 -41
  16. package/dist/esm/data-access/http/youtube.native.js +20 -14
  17. package/package.json +1 -3
  18. package/src/data-access/http/README.md +50 -0
  19. package/src/data-access/http/facebook.native.js +122 -144
  20. package/src/data-access/http/instagram.native.js +113 -93
  21. package/src/data-access/http/linkedin.native.js +144 -83
  22. package/src/data-access/http/threads.native.js +58 -27
  23. package/src/data-access/http/tiktok.native.js +19 -39
  24. package/src/data-access/http/twitter.native.js +145 -65
  25. package/src/data-access/http/youtube.native.js +21 -40
  26. package/dist/cjs/lib/hiddenComment.helper.js +0 -119
  27. package/dist/esm/lib/hiddenComment.helper.js +0 -112
  28. package/src/lib/hiddenComment.helper.js +0 -107
@@ -2,52 +2,41 @@ import superagent from 'superagent';
2
2
  import { removePrefix } from '../../lib/externalId.helpers.js';
3
3
  import {
4
4
  loggerDebug,
5
- loggerError,
6
5
  loggerInfo,
6
+ MeltwaterAttributes,
7
7
  } from '../../lib/logger.helpers.js';
8
8
 
9
9
  const FACEBOOK_URL = 'https://graph.facebook.com';
10
10
 
11
11
  export async function shareCount(token, externalId, logger) {
12
- try {
13
- const response = await getApi(
14
- `${FACEBOOK_URL}/${removePrefix(externalId)}/?fields=shares`,
15
- token
16
- );
17
- return response.body.shares && response.body.shares.count;
18
- } catch (error) {
19
- loggerError(
20
- logger,
21
- `Facebook shareCount error recieved - ${error.code}`,
22
- error
23
- );
24
- }
12
+ const response = await getApi(
13
+ `${FACEBOOK_URL}/${removePrefix(externalId)}/?fields=shares`,
14
+ token,
15
+ undefined,
16
+ {},
17
+ logger
18
+ );
19
+ return response.body.shares && response.body.shares.count;
25
20
  }
26
21
 
27
22
  export async function reactions(token, externalIds, logger) {
28
- try {
29
- const response = await getApi(
30
- `${FACEBOOK_URL}?ids=${externalIds
31
- .map((externalId) => removePrefix(externalId))
32
- .join(',')}&fields=` +
33
- `reactions.limit(0).summary(viewer_reaction).as(fb_post_reaction_of_user),` +
34
- `reactions.type(LOVE).limit(0).summary(total_count).as(fb_post_reactions_love),` +
35
- `reactions.type(WOW).limit(0).summary(total_count).as(fb_post_reactions_wow),` +
36
- `reactions.type(SAD).limit(0).summary(total_count).as(fb_post_reactions_sad),` +
37
- `reactions.type(LIKE).limit(0).summary(total_count).as(fb_post_reactions_like),` +
38
- `reactions.type(ANGRY).limit(0).summary(total_count).as(fb_post_reactions_angry),` +
39
- `reactions.type(HAHA).limit(0).summary(total_count).as(fb_post_reactions_haha)`,
40
- token
41
- );
42
- return response.body;
43
- } catch (error) {
44
- loggerError(
45
- logger,
46
- `Facebook reactions error recieved - ${error.code}`,
47
- error
48
- );
49
- return undefined;
50
- }
23
+ const response = await getApi(
24
+ `${FACEBOOK_URL}?ids=${externalIds
25
+ .map((externalId) => removePrefix(externalId))
26
+ .join(',')}&fields=` +
27
+ `reactions.limit(0).summary(viewer_reaction).as(fb_post_reaction_of_user),` +
28
+ `reactions.type(LOVE).limit(0).summary(total_count).as(fb_post_reactions_love),` +
29
+ `reactions.type(WOW).limit(0).summary(total_count).as(fb_post_reactions_wow),` +
30
+ `reactions.type(SAD).limit(0).summary(total_count).as(fb_post_reactions_sad),` +
31
+ `reactions.type(LIKE).limit(0).summary(total_count).as(fb_post_reactions_like),` +
32
+ `reactions.type(ANGRY).limit(0).summary(total_count).as(fb_post_reactions_angry),` +
33
+ `reactions.type(HAHA).limit(0).summary(total_count).as(fb_post_reactions_haha)`,
34
+ token,
35
+ undefined,
36
+ {},
37
+ logger
38
+ );
39
+ return response.body;
51
40
  }
52
41
 
53
42
  export async function comment(
@@ -106,8 +95,12 @@ export async function privateMessage(
106
95
  .responseType('arrayBuffer');
107
96
 
108
97
  if (imageResponse.status !== 200) {
109
- loggerError(logger, 'Failed to fetch image from CDN', {
110
- responseBody: JSON.stringify(imageResponse.body),
98
+ loggerInfo(logger, 'Failed to fetch image from CDN', {
99
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
100
+ recipientId,
101
+ status: imageResponse.status,
102
+ responseBody: imageResponse.body,
103
+ }),
111
104
  });
112
105
  throw new Error('Failed to fetch image from CDN');
113
106
  }
@@ -242,51 +235,46 @@ export async function unlike(token, externalId, logger) {
242
235
  }
243
236
 
244
237
  export async function isUserBanned(token, authorId, pageId, logger) {
245
- try {
246
- if (!pageId) {
247
- // if no pageId to check this call will fail
248
- // should only happen with temp edge docs
249
- return false;
250
- }
251
- const response = await getApi(
252
- `${FACEBOOK_URL}/${pageId}/blocked`,
253
- token,
254
- undefined, // payload
255
- {
256
- user: removePrefix(authorId),
257
- },
258
- logger
259
- );
238
+ if (!pageId) {
239
+ // if no pageId to check this call will fail
240
+ // should only happen with temp edge docs
241
+ return false;
242
+ }
243
+ const response = await getApi(
244
+ `${FACEBOOK_URL}/${pageId}/blocked`,
245
+ token,
246
+ undefined, // payload
247
+ {
248
+ user: removePrefix(authorId),
249
+ },
250
+ logger
251
+ );
260
252
 
261
- if (response && response.body && response.body.data) {
262
- const userNoPrefix = removePrefix(authorId);
263
- const user = response.body.data.find((user) => {
264
- if (user.id == userNoPrefix) {
265
- return user;
266
- }
267
- });
268
- if (user) {
269
- return true;
270
- } else {
271
- return false;
253
+ if (response && response.body && response.body.data) {
254
+ const userNoPrefix = removePrefix(authorId);
255
+ const user = response.body.data.find((user) => {
256
+ if (user.id == userNoPrefix) {
257
+ return user;
272
258
  }
259
+ });
260
+ if (user) {
261
+ return true;
262
+ } else {
263
+ return false;
273
264
  }
274
-
275
- loggerInfo(
276
- logger,
277
- `Native Facebook API is User Banned Response was invalid`,
278
- {
279
- responseBody: JSON.stringify(response.body),
280
- }
281
- );
282
- } catch (err) {
283
- loggerError(
284
- logger,
285
- `Failed to call facebook api isUserBanned for userId ${authorId} ${pageId}`,
286
- err
287
- );
288
265
  }
289
- return false;
266
+
267
+ loggerInfo(
268
+ logger,
269
+ `Native Facebook API is User Banned Response was invalid`,
270
+ {
271
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
272
+ authorId,
273
+ pageId,
274
+ responseBody: response.body,
275
+ }),
276
+ }
277
+ );
290
278
  }
291
279
 
292
280
  export async function getProfile(token, authorId, fields, logger) {
@@ -310,28 +298,23 @@ export async function getProfile(token, authorId, fields, logger) {
310
298
  .query(queryParams)
311
299
  .send();
312
300
  } catch (err) {
313
- if (err?.response?.body?.error) {
314
- loggerError(
315
- logger,
316
- `Failed to call facebook api for userId ${userNoPrefix}: ${err.response.body.error.message}`
317
- );
318
- } else {
319
- loggerError(
320
- logger,
321
- `Failed to call facebook api for userId ${userNoPrefix}`,
322
- err
323
- );
324
- }
325
-
301
+ loggerInfo(logger, `Failed to call facebook api for userId`, {
302
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
303
+ userNoPrefix,
304
+ error: err?.response?.body?.error?.message ?? err?.message,
305
+ }),
306
+ });
326
307
  return null;
327
308
  }
328
309
 
329
310
  if (response.status !== 200) {
330
- loggerError(
331
- logger,
332
- `Failed to call facebook api for userId ${userNoPrefix}`,
333
- { responseBody: JSON.stringify(response.body) }
334
- );
311
+ loggerInfo(logger, `Failed to call facebook api for userId`, {
312
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
313
+ userNoPrefix,
314
+ status: response.status,
315
+ responseBody: response.body,
316
+ }),
317
+ });
335
318
  let error = new Error(
336
319
  `Failed to call facebook api for userId ${userNoPrefix}`
337
320
  );
@@ -386,8 +369,7 @@ export async function unban(token, sourceId, authorId, logger) {
386
369
 
387
370
  export async function getAttachment(token, externalId, discussionType, logger) {
388
371
  let result;
389
- try {
390
- switch (discussionType) {
372
+ switch (discussionType) {
391
373
  case 're':
392
374
  case 'qt':
393
375
  result = await getApi(
@@ -460,10 +442,6 @@ export async function getAttachment(token, externalId, discussionType, logger) {
460
442
  },
461
443
  ],
462
444
  };
463
- }
464
- } catch (error) {
465
- loggerError(logger, `Error getting facebook attachment`, error);
466
- throw error;
467
445
  }
468
446
  }
469
447
 
@@ -477,30 +455,22 @@ async function getApi(apiUrl, accessToken, payload, queryParams = {}, logger) {
477
455
  .query({ access_token: accessToken, ...queryParams })
478
456
  .send(payload);
479
457
  } catch (err) {
480
- if (
481
- err &&
482
- err.response &&
483
- err.response.body &&
484
- err.response.body.error
485
- ) {
486
- loggerError(
487
- logger,
488
- `Failed to call facebook getApi ${apiUrl}: ${err.response.body.error.message}`
489
- );
490
- } else {
491
- loggerError(
492
- logger,
493
- `Failed to call facebook getApi ${apiUrl}`,
494
- err
495
- );
496
- }
497
-
458
+ loggerInfo(logger, `Failed to call facebook getApi`, {
459
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
460
+ apiUrl,
461
+ error: err?.response?.body?.error?.message ?? err?.message,
462
+ }),
463
+ });
498
464
  throw err;
499
465
  }
500
466
 
501
467
  if (response.status !== 200) {
502
- loggerError(logger, `Failed to call facebook api ${apiUrl}`, {
503
- responseBody: JSON.stringify(response.body),
468
+ loggerInfo(logger, `Failed to call facebook api`, {
469
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
470
+ apiUrl,
471
+ status: response.status,
472
+ responseBody: response.body,
473
+ }),
504
474
  });
505
475
  let error = new Error(`Failed to call facebook api ${apiUrl}`);
506
476
  error.code = response.status;
@@ -551,7 +521,10 @@ async function postApi(
551
521
  err?.response?.body?.error?.error_user_title === "Duplicate Mark Spam Request"
552
522
  ) {
553
523
  loggerInfo(logger, `Content already marked as spam - treating as successful hide operation`, {
554
- responseBody: JSON.stringify(err.response.body),
524
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
525
+ apiUrl,
526
+ responseBody: err.response.body,
527
+ }),
555
528
  });
556
529
  return {
557
530
  status: 200,
@@ -559,13 +532,22 @@ async function postApi(
559
532
  };
560
533
  }
561
534
 
562
- loggerDebug(logger, `Failed to call facebook api`, err);
535
+ loggerDebug(logger, `Failed to call facebook api`, {
536
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
537
+ apiUrl,
538
+ error: err?.message,
539
+ }),
540
+ });
563
541
  throw err;
564
542
  }
565
543
 
566
544
  if (response.status !== 200) {
567
- loggerError(logger, `Failed to call facebook api`, {
568
- responseBody: JSON.stringify(response.body),
545
+ loggerInfo(logger, `Failed to call facebook api`, {
546
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
547
+ apiUrl,
548
+ status: response.status,
549
+ responseBody: response.body,
550
+ }),
569
551
  });
570
552
  throw new Error(`Failed to call facebook api ${response.body}`);
571
553
  }
@@ -583,26 +565,22 @@ async function deleteApi(apiUrl, accessToken, payload, logger) {
583
565
  .query({ access_token: accessToken })
584
566
  .send(payload);
585
567
  } catch (err) {
586
- if (
587
- err &&
588
- err.response &&
589
- err.response.body &&
590
- err.response.body.error
591
- ) {
592
- loggerError(
593
- logger,
594
- `Failed to call facebook api delete: ${err.response.body.error.message}`
595
- );
596
- } else {
597
- loggerError(logger, `Failed to call facebook api delete`, err);
598
- }
599
-
568
+ loggerInfo(logger, `Failed to call facebook api delete`, {
569
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
570
+ apiUrl,
571
+ error: err?.response?.body?.error?.message ?? err?.message,
572
+ }),
573
+ });
600
574
  throw err;
601
575
  }
602
576
 
603
577
  if (response.status !== 200) {
604
- loggerError(logger, `Failed to call facebook api delete`, {
605
- responseBody: JSON.stringify(response.body),
578
+ loggerInfo(logger, `Failed to call facebook api delete`, {
579
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
580
+ apiUrl,
581
+ status: response.status,
582
+ responseBody: response.body,
583
+ }),
606
584
  });
607
585
  let error = new Error(`Failed to call facebook api delete`);
608
586
  error.code = response.status;
@@ -1,6 +1,6 @@
1
1
  import superagent from 'superagent';
2
2
  import { removePrefix } from '../../lib/externalId.helpers.js';
3
- import { loggerDebug, loggerError, loggerInfo, loggerWarn } from '../../lib/logger.helpers.js';
3
+ import { loggerDebug, loggerInfo, loggerWarn, MeltwaterAttributes } from '../../lib/logger.helpers.js';
4
4
 
5
5
 
6
6
  const INSTAGRAM_URL = 'https://graph.facebook.com';
@@ -16,7 +16,6 @@ async function requestApi(
16
16
  logger
17
17
  ) {
18
18
  let response = {};
19
-
20
19
  try {
21
20
  let queryStringArgs =accessToken? { access_token: accessToken } : undefined;
22
21
  if (adCampaign?.adAccountId) {
@@ -42,28 +41,30 @@ async function requestApi(
42
41
  .send(data);
43
42
  }
44
43
  } catch (err) {
45
- if (
46
- err &&
47
- err.response &&
48
- err.response.body &&
49
- err.response.body.error
50
- ) {
51
- loggerError(logger,
52
- `Failed to call instagram api: ${err.response.body.error.message}`
53
- );
54
- } else {
55
- loggerError(logger,
56
- `Failed to call instagram api`,
57
- err
58
- );
59
- }
44
+ loggerInfo(logger, `Failed to call instagram api - requestApi`, {
45
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
46
+ apiUrl,
47
+ discussionType,
48
+ adCampaign: adCampaign || undefined,
49
+ text: text || undefined,
50
+ error: err?.response?.body?.error?.message ?? err?.message,
51
+ }),
52
+ });
60
53
  throw err;
61
54
  }
62
55
 
63
56
  if (response.status !== 200) {
64
- loggerError(logger,
65
- `Failed to call instagram api`,
66
- { responseBody: JSON.stringify(response.body) }
57
+ loggerInfo(logger,
58
+ `Failed to call instagram api - requestApi bad status`,
59
+ {
60
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
61
+ apiUrl,
62
+ discussionType,
63
+ adCampaign: adCampaign || undefined,
64
+ status: response.status,
65
+ responseBody: response.body,
66
+ }),
67
+ }
67
68
  );
68
69
  let error = new Error(
69
70
  `Failed to call instagram api`
@@ -87,24 +88,29 @@ async function getPost(apiUrl, accessToken, fields, logger) {
87
88
  .query({ fields: fields })
88
89
  .send();
89
90
  } catch (err) {
90
- if (err && err.response && err.response.body) {
91
- loggerError(logger,
92
- `Failed to call instagram api`,
93
- err.response.body.error
94
- );
95
- } else {
96
- loggerError(logger,
97
- `Failed to call instagram api`,
98
- err
99
- );
100
- }
91
+ const errObject = {
92
+ apiUrl,
93
+ fields,
94
+ error: err?.response?.body?.error ?? err?.message,
95
+ };
96
+ loggerInfo(logger,
97
+ `Failed to call instagram api - getPost`,
98
+ { [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify(errObject) }
99
+ );
101
100
  throw err;
102
101
  }
103
102
 
104
103
  if (response.status !== 200) {
105
- loggerError(logger,
106
- `Failed to call instagram api`,
107
- { responseBody: JSON.stringify(response.body) }
104
+ loggerInfo(logger,
105
+ `Failed to call instagram api - getPost bad status`,
106
+ {
107
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
108
+ apiUrl,
109
+ fields,
110
+ status: response.status,
111
+ responseBody: response.body,
112
+ }),
113
+ }
108
114
  );
109
115
  let error = new Error(
110
116
  `Failed to call instagram api`
@@ -128,11 +134,16 @@ async function getMessageData(accessToken, sourceId, inReplyToId, logger) {
128
134
 
129
135
  return response.body;
130
136
  } catch (err) {
131
- loggerError(logger,
132
- `Failed to call instagram api`,
133
- err
137
+ loggerInfo(logger,
138
+ `Failed to call instagram api - getMessageData`,
139
+ {
140
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
141
+ sourceId,
142
+ inReplyToId,
143
+ error: err?.message,
144
+ }),
145
+ }
134
146
  );
135
-
136
147
  return null;
137
148
  }
138
149
  }
@@ -156,28 +167,30 @@ async function mentionRequestApi(
156
167
  .query({ message: text })
157
168
  .send();
158
169
  } catch (err) {
159
- if (
160
- err &&
161
- err.response &&
162
- err.response.body &&
163
- err.response.body.error
164
- ) {
165
- loggerError(logger,
166
- `Failed to call instagram api: ${err.response.body.error.message}`
167
- );
168
- } else {
169
- loggerError(logger,
170
- `Failed to call instagram api`,
171
- err
172
- );
173
- }
170
+ const errObject = {
171
+ apiUrl,
172
+ replayObject,
173
+ text,
174
+ error: err?.response?.body?.error?.message ?? err?.message,
175
+ };
176
+ loggerInfo(logger,
177
+ `Failed to call instagram api - mentionRequestApi`,
178
+ { [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify(errObject) }
179
+ );
174
180
  throw err;
175
181
  }
176
182
 
177
183
  if (response.status !== 200) {
178
- loggerError(logger,
179
- `Failed to call instagram api`,
180
- { responseBody: JSON.stringify(response.body) }
184
+ loggerInfo(logger,
185
+ `Failed to call instagram api - mentionRequestApi bad status`,
186
+ {
187
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
188
+ apiUrl,
189
+ replayObject,
190
+ status: response.status,
191
+ responseBody: response.body,
192
+ }),
193
+ }
181
194
  );
182
195
  let error = new Error(
183
196
  `Failed to call instagram api`
@@ -199,24 +212,29 @@ async function hideApi(apiUrl, accessToken, hideStatus, logger) {
199
212
  .query({ hide: hideStatus })
200
213
  .send();
201
214
  } catch (err) {
202
- if (err && err.response && err.response.body) {
203
- loggerError(logger,
204
- `Failed to call instagram api`,
205
- err.response.body.error
206
- );
207
- } else {
208
- loggerError(logger,
209
- `Failed to call instagram api`,
210
- err
211
- );
212
- }
215
+ const errObject = {
216
+ apiUrl,
217
+ hideStatus,
218
+ error: err?.response?.body?.error ?? err?.message,
219
+ };
220
+ loggerInfo(logger,
221
+ `Failed to call instagram api - hideApi`,
222
+ { [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify(errObject) }
223
+ );
213
224
  throw err;
214
225
  }
215
226
 
216
227
  if (response.status !== 200) {
217
- loggerError(logger,
218
- `Failed to call instagram api`,
219
- { responseBody: JSON.stringify(response.body) }
228
+ loggerInfo(logger,
229
+ `Failed to call instagram api - hideApi bad status`,
230
+ {
231
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
232
+ apiUrl,
233
+ hideStatus,
234
+ status: response.status,
235
+ responseBody: response.body,
236
+ }),
237
+ }
220
238
  );
221
239
  let error = new Error(
222
240
  `Failed to call instagram api`
@@ -246,10 +264,17 @@ export async function getLikes(accessToken, externalId, logger) {
246
264
  );
247
265
  return response.body;
248
266
  } catch (err) {
267
+ const errPayload = {
268
+ [MeltwaterAttributes.PAYLOADDATA]: JSON.stringify({
269
+ externalId,
270
+ status: err?.status,
271
+ error: err?.message,
272
+ }),
273
+ };
249
274
  if(err?.status === 400) {
250
- loggerWarn(logger,'Warn getLikes Instagram Comment probably deleted on native', err);
251
- }else{
252
- loggerError(logger,'Error getLikes Instagram '+externalId,err);
275
+ loggerWarn(logger, 'Warn getLikes Instagram Comment probably deleted on native', errPayload);
276
+ } else {
277
+ loggerInfo(logger, 'Error getLikes Instagram', errPayload);
253
278
  }
254
279
  return 0;
255
280
  }
@@ -461,28 +486,23 @@ export async function unhide(accessToken, externalId, logger) {
461
486
  }
462
487
 
463
488
  export async function getAttachment(token, externalId, logger) {
464
- try {
465
- const result = await getPost(
466
- `${INSTAGRAM_URL}/${removePrefix(externalId)}`,
467
- token,
468
- 'media_url,children{media_url}',
469
- logger
470
- );
471
-
472
- const res = result.body;
473
- if (res?.children?.data?.length) {
474
- return {
475
- images: res.children.data.map((item) => {
476
- return { source: item?.media_url };
477
- }),
478
- };
479
- }
489
+ const result = await getPost(
490
+ `${INSTAGRAM_URL}/${removePrefix(externalId)}`,
491
+ token,
492
+ 'media_url,children{media_url}',
493
+ logger
494
+ );
480
495
 
496
+ const res = result.body;
497
+ if (res?.children?.data?.length) {
481
498
  return {
482
- images: [{ source: res?.media_url }],
499
+ images: res.children.data.map((item) => {
500
+ return { source: item?.media_url };
501
+ }),
483
502
  };
484
- } catch (error) {
485
- loggerError(logger,`Error getting instagram attachment`, error);
486
- throw error;
487
503
  }
504
+
505
+ return {
506
+ images: [{ source: res?.media_url }],
507
+ };
488
508
  }