@meltwater/conversations-api-services 1.0.9 → 1.0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Repository to contain all conversations api services shared across our services",
5
5
  "type": "module",
6
6
  "main": "src/data-access/index.js",
@@ -65,7 +65,7 @@ export class LinkedInApiClient {
65
65
  'X-RestLi-Protocol-Version': configuration.get(
66
66
  'LINKEDIN_API_VERSION'
67
67
  ),
68
- 'LinkedIn-Version': '202305',
68
+ 'LinkedIn-Version': '202311',
69
69
  });
70
70
  } else {
71
71
  loggerChild.debug(`${documentId} - sending to linkedin `, {
@@ -80,7 +80,7 @@ export class LinkedInApiClient {
80
80
  'X-RestLi-Protocol-Version': configuration.get(
81
81
  'LINKEDIN_API_VERSION'
82
82
  ),
83
- 'LinkedIn-Version': '202305',
83
+ 'LinkedIn-Version': '202311',
84
84
  })
85
85
  .send(payload);
86
86
  }
@@ -153,7 +153,7 @@ export class LinkedInApiClient {
153
153
  'X-RestLi-Protocol-Version': configuration.get(
154
154
  'LINKEDIN_API_VERSION'
155
155
  ),
156
- 'LinkedIn-Version': '202305',
156
+ 'LinkedIn-Version': '202311',
157
157
  });
158
158
 
159
159
  loggerChild.info(
@@ -247,7 +247,7 @@ export class LinkedInApiClient {
247
247
  'X-RestLi-Protocol-Version': configuration.get(
248
248
  'LINKEDIN_API_VERSION'
249
249
  ),
250
- 'LinkedIn-Version': '202305',
250
+ 'LinkedIn-Version': '202311',
251
251
  })
252
252
  .send(body);
253
253
 
@@ -301,7 +301,7 @@ export class LinkedInApiClient {
301
301
  'X-RestLi-Protocol-Version': configuration.get(
302
302
  'LINKEDIN_API_VERSION'
303
303
  ),
304
- 'LinkedIn-Version': '202305',
304
+ 'LinkedIn-Version': '202311',
305
305
  })
306
306
  .send(body);
307
307
 
@@ -340,7 +340,7 @@ export class LinkedInApiClient {
340
340
  'X-RestLi-Protocol-Version': configuration.get(
341
341
  'LINKEDIN_API_VERSION'
342
342
  ),
343
- 'LinkedIn-Version': '202305',
343
+ 'LinkedIn-Version': '202311',
344
344
  })
345
345
  .then((result) => result.body);
346
346
  } catch (error) {
@@ -373,7 +373,7 @@ export class LinkedInApiClient {
373
373
  'X-RestLi-Protocol-Version': configuration.get(
374
374
  'LINKEDIN_API_VERSION'
375
375
  ),
376
- 'LinkedIn-Version': '202305',
376
+ 'LinkedIn-Version': '202311',
377
377
  })
378
378
  .then((result) => result.body);
379
379
  } catch (error) {
@@ -409,7 +409,7 @@ export class LinkedInApiClient {
409
409
  'X-RestLi-Protocol-Version': configuration.get(
410
410
  'LINKEDIN_API_VERSION'
411
411
  ),
412
- 'LinkedIn-Version': '202305',
412
+ 'LinkedIn-Version': '202311',
413
413
  });
414
414
  } catch (error) {
415
415
  loggerChild.error('Error in getAllStats ' + error, error);
@@ -478,7 +478,7 @@ export class LinkedInApiClient {
478
478
  'X-RestLi-Protocol-Version': configuration.get(
479
479
  'LINKEDIN_API_VERSION'
480
480
  ),
481
- 'LinkedIn-Version': '202305',
481
+ 'LinkedIn-Version': '202311',
482
482
  });
483
483
  } catch (error) {
484
484
  loggerChild.error('Error in getImageMedia ' + error, error);
@@ -538,7 +538,7 @@ export class LinkedInApiClient {
538
538
  'X-RestLi-Protocol-Version': configuration.get(
539
539
  'LINKEDIN_API_VERSION'
540
540
  ),
541
- 'LinkedIn-Version': '202305',
541
+ 'LinkedIn-Version': '202311',
542
542
  });
543
543
  } catch (error) {
544
544
  loggerChild.error('Error in getVideoMedia ' + error, error);
@@ -622,7 +622,7 @@ export class LinkedInApiClient {
622
622
  'X-RestLi-Protocol-Version': configuration.get(
623
623
  'LINKEDIN_API_VERSION'
624
624
  ),
625
- 'LinkedIn-Version': '202305',
625
+ 'LinkedIn-Version': '202311',
626
626
  })
627
627
  .then((result) => result.body);
628
628
  } catch (error) {
@@ -653,7 +653,7 @@ export class LinkedInApiClient {
653
653
  'X-RestLi-Protocol-Version': configuration.get(
654
654
  'LINKEDIN_API_VERSION'
655
655
  ),
656
- 'LinkedIn-Version': '202305',
656
+ 'LinkedIn-Version': '202311',
657
657
  })
658
658
  .send(data)
659
659
  .catch((err) => {
@@ -330,7 +330,7 @@ export class TikTokApiClient {
330
330
  }
331
331
  }
332
332
 
333
- async toggleHide(document) {
333
+ async toggleHide(document, parentDoc = undefined) {
334
334
  const {
335
335
  documentId,
336
336
  appData: { hidden: hiddenOnNative },
@@ -339,9 +339,9 @@ export class TikTokApiClient {
339
339
  let response;
340
340
  try {
341
341
  if (hiddenOnNative) {
342
- response = await this.hide(document);
342
+ response = await this.hide(document, parentDoc);
343
343
  } else {
344
- response = await this.unhide(document);
344
+ response = await this.unhide(document, parentDoc);
345
345
  }
346
346
  logger.info(
347
347
  `Native Tiktok API Hide Response for documentId ${documentId}`,
@@ -406,14 +406,23 @@ export class TikTokApiClient {
406
406
  return publishedMessage;
407
407
  }
408
408
 
409
- async hide(document) {
409
+ async hide(document, parentDoc = undefined) {
410
410
  const {
411
411
  metaData: {
412
412
  externalId: comment_id,
413
413
  source: { id: sourceId },
414
- inReplyTo: { id: video_id },
414
+ discussionType,
415
415
  },
416
416
  } = document;
417
+
418
+ //very small chance we get externalid instead of id
419
+ const video_id =
420
+ discussionType === 're'
421
+ ? parentDoc?.metaData?.inReplyTo?.id ||
422
+ parentDoc?.metaData?.inReplyTo?.externalId
423
+ : document?.metaData?.inReplyTo?.id ||
424
+ document?.metaData?.inReplyTo?.externalId;
425
+
417
426
  const { body: publishedMessage } =
418
427
  (await this.sendPost({
419
428
  paramString: 'comment/hide/',
@@ -428,14 +437,20 @@ export class TikTokApiClient {
428
437
  return publishedMessage;
429
438
  }
430
439
 
431
- async unhide(document) {
440
+ async unhide(document, parentDoc = undefined) {
432
441
  const {
433
442
  metaData: {
434
443
  externalId: comment_id,
435
444
  source: { id: sourceId },
436
- inReplyTo: { id: video_id },
445
+ discussionType,
437
446
  },
438
447
  } = document;
448
+
449
+ const video_id =
450
+ discussionType === 're'
451
+ ? parentDoc?.metaData?.inReplyTo?.id
452
+ : document?.metaData?.inReplyTo?.id;
453
+
439
454
  const { body: publishedMessage } =
440
455
  (await this.sendPost({
441
456
  paramString: 'comment/hide/',