@meltwater/conversations-api-services 1.0.36 → 1.0.38
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/dist/cjs/data-access/http/assetManager.client.js +12 -1
- package/dist/cjs/data-access/http/linkedin.native.js +1 -1
- package/dist/esm/data-access/http/assetManager.client.js +12 -1
- package/dist/esm/data-access/http/linkedin.native.js +1 -1
- package/package.json +1 -1
- package/src/data-access/http/assetManager.client.js +12 -2
- package/src/data-access/http/linkedin.native.js +1 -1
|
@@ -14,7 +14,12 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
14
14
|
const gatewayURL = _configuration.default.get('ASSETMANAGER_GATEWAY_URL');
|
|
15
15
|
const ASSET_LIBRARY_S3_BUCKET = _configuration.default.get('ASSET_LIBRARY_S3_BUCKET');
|
|
16
16
|
async function getAsset(jwt, assetId, logger) {
|
|
17
|
+
let retry = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
17
18
|
try {
|
|
19
|
+
if (retry > 5) {
|
|
20
|
+
(0, _loggerHelpers.loggerInfo)(logger, `No Results From AssetManager giving up ${assetId}`);
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
18
23
|
const response = await _superagent.default.post(`${gatewayURL}`).set('apollographql-client-name', 'phoenix-conversations').set('Authorization', jwt).send({
|
|
19
24
|
query: `
|
|
20
25
|
query getAssetUrlForPublishing(
|
|
@@ -44,7 +49,13 @@ async function getAsset(jwt, assetId, logger) {
|
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
});
|
|
47
|
-
|
|
52
|
+
let result = response.body?.data?.assets?.edges[0]?.node;
|
|
53
|
+
if (!result) {
|
|
54
|
+
retry = retry + 1;
|
|
55
|
+
(0, _loggerHelpers.loggerInfo)(logger, `No Results From AssetManager ${assetId} round ${retry}`);
|
|
56
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
57
|
+
return getAsset(jwt, assetId, logger, retry);
|
|
58
|
+
}
|
|
48
59
|
} catch (exception) {
|
|
49
60
|
// How would you prefer to handle this
|
|
50
61
|
(0, _loggerHelpers.loggerError)(logger, 'Error getting asset url', exception);
|
|
@@ -160,7 +160,7 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
} catch (err) {
|
|
163
|
-
(0, _loggerHelpers.loggerError)(logger`Exception in linkedin publish `, err);
|
|
163
|
+
(0, _loggerHelpers.loggerError)(logger, `Exception in linkedin publish `, err);
|
|
164
164
|
throw err;
|
|
165
165
|
}
|
|
166
166
|
return {
|
|
@@ -6,7 +6,12 @@ import AWS from 'aws-sdk';
|
|
|
6
6
|
const gatewayURL = configuration.get('ASSETMANAGER_GATEWAY_URL');
|
|
7
7
|
const ASSET_LIBRARY_S3_BUCKET = configuration.get('ASSET_LIBRARY_S3_BUCKET');
|
|
8
8
|
export async function getAsset(jwt, assetId, logger) {
|
|
9
|
+
let retry = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
9
10
|
try {
|
|
11
|
+
if (retry > 5) {
|
|
12
|
+
loggerInfo(logger, `No Results From AssetManager giving up ${assetId}`);
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
10
15
|
const response = await superagent.post(`${gatewayURL}`).set('apollographql-client-name', 'phoenix-conversations').set('Authorization', jwt).send({
|
|
11
16
|
query: `
|
|
12
17
|
query getAssetUrlForPublishing(
|
|
@@ -36,7 +41,13 @@ export async function getAsset(jwt, assetId, logger) {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
});
|
|
39
|
-
|
|
44
|
+
let result = response.body?.data?.assets?.edges[0]?.node;
|
|
45
|
+
if (!result) {
|
|
46
|
+
retry = retry + 1;
|
|
47
|
+
loggerInfo(logger, `No Results From AssetManager ${assetId} round ${retry}`);
|
|
48
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
49
|
+
return getAsset(jwt, assetId, logger, retry);
|
|
50
|
+
}
|
|
40
51
|
} catch (exception) {
|
|
41
52
|
// How would you prefer to handle this
|
|
42
53
|
loggerError(logger, 'Error getting asset url', exception);
|
|
@@ -140,7 +140,7 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
} catch (err) {
|
|
143
|
-
loggerError(logger`Exception in linkedin publish `, err);
|
|
143
|
+
loggerError(logger, `Exception in linkedin publish `, err);
|
|
144
144
|
throw err;
|
|
145
145
|
}
|
|
146
146
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meltwater/conversations-api-services",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
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",
|
|
@@ -11,8 +11,12 @@ const gatewayURL = configuration.get(
|
|
|
11
11
|
const ASSET_LIBRARY_S3_BUCKET= configuration.get(
|
|
12
12
|
'ASSET_LIBRARY_S3_BUCKET'
|
|
13
13
|
);
|
|
14
|
-
export async function getAsset(jwt, assetId, logger) {
|
|
14
|
+
export async function getAsset(jwt, assetId, logger, retry = 0) {
|
|
15
15
|
try {
|
|
16
|
+
if(retry > 5){
|
|
17
|
+
loggerInfo(logger, `No Results From AssetManager giving up ${assetId}`);
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
16
20
|
const response = await superagent
|
|
17
21
|
.post(`${gatewayURL}`)
|
|
18
22
|
.set('apollographql-client-name', 'phoenix-conversations')
|
|
@@ -49,7 +53,13 @@ export async function getAsset(jwt, assetId, logger) {
|
|
|
49
53
|
},
|
|
50
54
|
},
|
|
51
55
|
});
|
|
52
|
-
|
|
56
|
+
let result = response.body?.data?.assets?.edges[0]?.node;
|
|
57
|
+
if(!result){
|
|
58
|
+
retry = retry + 1;
|
|
59
|
+
loggerInfo(logger, `No Results From AssetManager ${assetId} round ${retry}`);
|
|
60
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
61
|
+
return getAsset(jwt,assetId,logger,retry);
|
|
62
|
+
}
|
|
53
63
|
} catch (exception) {
|
|
54
64
|
// How would you prefer to handle this
|
|
55
65
|
loggerError(logger,'Error getting asset url', exception);
|