@meltwater/conversations-api-services 1.1.8 → 1.1.10

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.
@@ -0,0 +1,24 @@
1
+ name: "Code Scanning"
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ actions: write
14
+ contents: read
15
+ security-events: write
16
+ packages: read
17
+ pull-requests: read
18
+
19
+
20
+ jobs:
21
+ code-scan-analysis:
22
+ name: Code Scan Analysis
23
+ secrets: inherit
24
+ uses: meltwater/sec-global-gh-actions/.github/workflows/codeql-horusec-analysis.yml@main
@@ -480,7 +480,7 @@ async function likedByUser(token, externalId, authorExternalId, logger) {
480
480
  'LinkedIn-Version': LINKEDIN_VERSION
481
481
  }).then(result => result.body);
482
482
  } catch (error) {
483
- (0, _loggerHelpers.loggerError)(logger, 'Error in getLikesByUser', error);
483
+ // linkedin throws an error if the user has not liked the post
484
484
  return false;
485
485
  }
486
486
  return true;
@@ -504,6 +504,14 @@ async function doRequest(_ref4) {
504
504
  }
505
505
  });
506
506
  } catch (e) {
507
+ if (e.response.status == 503) {
508
+ loggerWarn(logger, `Twitter API 503 error - Service Unavailable`, {
509
+ url,
510
+ convertPayloadToUri,
511
+ payload: JSON.stringify(payload)
512
+ });
513
+ return reject(e);
514
+ }
507
515
  (0, _loggerHelpers.loggerError)(logger, `Error in twitter doRequest`, e, {
508
516
  url,
509
517
  convertPayloadToUri,
@@ -7,6 +7,7 @@ exports.MeltwaterAttributes = void 0;
7
7
  exports.loggerDebug = loggerDebug;
8
8
  exports.loggerError = loggerError;
9
9
  exports.loggerInfo = loggerInfo;
10
+ exports.loggerWarn = loggerWarn;
10
11
  const MeltwaterAttributes = exports.MeltwaterAttributes = {
11
12
  COMPANYID: 'meltwater.company.id',
12
13
  // Unique identifier of a company as it applies to meltwater search
@@ -77,4 +78,12 @@ function loggerError(logger, message) {
77
78
  } else {
78
79
  console.log(message, meta);
79
80
  }
81
+ }
82
+ function loggerWarn(logger, message) {
83
+ let meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
84
+ if (logger) {
85
+ logger.warn(message, meta);
86
+ } else {
87
+ console.log(message, meta);
88
+ }
80
89
  }
@@ -458,7 +458,7 @@ export async function likedByUser(token, externalId, authorExternalId, logger) {
458
458
  'LinkedIn-Version': LINKEDIN_VERSION
459
459
  }).then(result => result.body);
460
460
  } catch (error) {
461
- loggerError(logger, 'Error in getLikesByUser', error);
461
+ // linkedin throws an error if the user has not liked the post
462
462
  return false;
463
463
  }
464
464
  return true;
@@ -481,6 +481,14 @@ async function doRequest(_ref4) {
481
481
  }
482
482
  });
483
483
  } catch (e) {
484
+ if (e.response.status == 503) {
485
+ loggerWarn(logger, `Twitter API 503 error - Service Unavailable`, {
486
+ url,
487
+ convertPayloadToUri,
488
+ payload: JSON.stringify(payload)
489
+ });
490
+ return reject(e);
491
+ }
484
492
  loggerError(logger, `Error in twitter doRequest`, e, {
485
493
  url,
486
494
  convertPayloadToUri,
@@ -69,4 +69,12 @@ export function loggerError(logger, message) {
69
69
  console.log(message, meta);
70
70
  }
71
71
  }
72
+ export function loggerWarn(logger, message) {
73
+ let meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
74
+ if (logger) {
75
+ logger.warn(message, meta);
76
+ } else {
77
+ console.log(message, meta);
78
+ }
79
+ }
72
80
  export { MeltwaterAttributes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "Repository to contain all conversations api services shared across our services",
5
5
  "main": "dist/cjs/data-access/index.js",
6
6
  "module": "dist/esm/data-access/index.js",
@@ -630,7 +630,7 @@ export async function likedByUser(
630
630
  })
631
631
  .then((result) => result.body);
632
632
  } catch (error) {
633
- loggerError(logger,'Error in getLikesByUser', error);
633
+ // linkedin throws an error if the user has not liked the post
634
634
  return false;
635
635
  }
636
636
  return true;
@@ -578,6 +578,14 @@ async function doRequest({
578
578
  resp: { ...result },
579
579
  });
580
580
  } catch (e) {
581
+ if(e.response.status == 503){
582
+ loggerWarn(logger,`Twitter API 503 error - Service Unavailable`,{
583
+ url,
584
+ convertPayloadToUri,
585
+ payload: JSON.stringify(payload),
586
+ });
587
+ return reject(e);
588
+ }
581
589
  loggerError(logger,`Error in twitter doRequest`, e, {
582
590
  url,
583
591
  convertPayloadToUri,
@@ -48,4 +48,12 @@ export function loggerError(logger, message, meta = {}) {
48
48
  }
49
49
  }
50
50
 
51
+ export function loggerWarn(logger, message, meta = {}) {
52
+ if(logger){
53
+ logger.warn(message, meta);
54
+ }else{
55
+ console.log(message,meta);
56
+ }
57
+ }
58
+
51
59
  export { MeltwaterAttributes };