@meltwater/conversations-api-services 1.1.11 → 1.1.12
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/instagram.native.js +5 -1
- package/dist/cjs/data-access/http/linkedInApi.client.js +0 -19
- package/dist/cjs/data-access/http/twitter.native.js +6 -1
- package/dist/esm/data-access/http/instagram.native.js +6 -2
- package/dist/esm/data-access/http/linkedInApi.client.js +0 -19
- package/dist/esm/data-access/http/twitter.native.js +6 -1
- package/package.json +1 -1
- package/src/data-access/http/instagram.native.js +6 -2
- package/src/data-access/http/linkedInApi.client.js +0 -40
- package/src/data-access/http/twitter.native.js +6 -1
|
@@ -150,7 +150,11 @@ async function getLikes(accessToken, externalId, logger) {
|
|
|
150
150
|
});
|
|
151
151
|
return response.body;
|
|
152
152
|
} catch (err) {
|
|
153
|
-
|
|
153
|
+
if (err?.status === 400) {
|
|
154
|
+
(0, _loggerHelpers.loggerWarn)(logger, 'Warn getLikes Instagram Comment probably deleted on native', err);
|
|
155
|
+
} else {
|
|
156
|
+
(0, _loggerHelpers.loggerError)(logger, 'Error getLikes Instagram ' + externalId, err);
|
|
157
|
+
}
|
|
154
158
|
return 0;
|
|
155
159
|
}
|
|
156
160
|
}
|
|
@@ -384,25 +384,6 @@ class LinkedInApiClient {
|
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
async getLikedByUser(externalId, authorExternalId, credentialId, companyId) {
|
|
388
|
-
let result;
|
|
389
|
-
try {
|
|
390
|
-
let credential = await this.credentialsAPI.getToken(credentialId, companyId);
|
|
391
|
-
result = await _superagent.default.get(`${_configuration.default.get('LINKEDIN_API')}/reactions/(actor:${fixedEncodeURIComponent(authorExternalId)},entity:${fixedEncodeURIComponent(externalId)})`).set({
|
|
392
|
-
Authorization: `Bearer ${credential.token}`,
|
|
393
|
-
'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
|
|
394
|
-
'LinkedIn-Version': '202311'
|
|
395
|
-
}).then(result => result.body);
|
|
396
|
-
} catch (error) {
|
|
397
|
-
_logger.default.error('Error in getLikesByUser', error, {
|
|
398
|
-
[_loggerHelpers.MeltwaterAttributes.COMPANYID]: companyId,
|
|
399
|
-
[_loggerHelpers.MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
|
|
400
|
-
[_loggerHelpers.MeltwaterAttributes.CREDENTIALID]: credentialId
|
|
401
|
-
});
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
return true;
|
|
405
|
-
}
|
|
406
387
|
async uploadMedia(query) {
|
|
407
388
|
const {
|
|
408
389
|
socialAccountId,
|
|
@@ -48,7 +48,12 @@ function addOAuthToToken(token, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET) {
|
|
|
48
48
|
}
|
|
49
49
|
async function getUserInfoFromHandles(token, handles, logger) {
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
const handlesJoin = handles.join(',');
|
|
52
|
+
if (!handlesJoin.length) {
|
|
53
|
+
loggerWarn(logger, `No handles provided to twitterNative getUserInfoFromHandles`);
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
let query = `users/lookup.json?screen_name=${handlesJoin}`;
|
|
52
57
|
let result = await postRequest({
|
|
53
58
|
token,
|
|
54
59
|
uri: query,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import superagent from 'superagent';
|
|
2
2
|
import { removePrefix } from '../../lib/externalId.helpers.js';
|
|
3
|
-
import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.js';
|
|
3
|
+
import { loggerDebug, loggerError, loggerInfo, loggerWarn } from '../../lib/logger.helpers.js';
|
|
4
4
|
const INSTAGRAM_URL = 'https://graph.facebook.com';
|
|
5
5
|
async function requestApi(apiUrl, accessToken, text, data) {
|
|
6
6
|
let discussionType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 're';
|
|
@@ -135,7 +135,11 @@ export async function getLikes(accessToken, externalId, logger) {
|
|
|
135
135
|
});
|
|
136
136
|
return response.body;
|
|
137
137
|
} catch (err) {
|
|
138
|
-
|
|
138
|
+
if (err?.status === 400) {
|
|
139
|
+
loggerWarn(logger, 'Warn getLikes Instagram Comment probably deleted on native', err);
|
|
140
|
+
} else {
|
|
141
|
+
loggerError(logger, 'Error getLikes Instagram ' + externalId, err);
|
|
142
|
+
}
|
|
139
143
|
return 0;
|
|
140
144
|
}
|
|
141
145
|
}
|
|
@@ -374,25 +374,6 @@ export class LinkedInApiClient {
|
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
async getLikedByUser(externalId, authorExternalId, credentialId, companyId) {
|
|
378
|
-
let result;
|
|
379
|
-
try {
|
|
380
|
-
let credential = await this.credentialsAPI.getToken(credentialId, companyId);
|
|
381
|
-
result = await superagent.get(`${configuration.get('LINKEDIN_API')}/reactions/(actor:${fixedEncodeURIComponent(authorExternalId)},entity:${fixedEncodeURIComponent(externalId)})`).set({
|
|
382
|
-
Authorization: `Bearer ${credential.token}`,
|
|
383
|
-
'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
|
|
384
|
-
'LinkedIn-Version': '202311'
|
|
385
|
-
}).then(result => result.body);
|
|
386
|
-
} catch (error) {
|
|
387
|
-
logger.error('Error in getLikesByUser', error, {
|
|
388
|
-
[MeltwaterAttributes.COMPANYID]: companyId,
|
|
389
|
-
[MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
|
|
390
|
-
[MeltwaterAttributes.CREDENTIALID]: credentialId
|
|
391
|
-
});
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
return true;
|
|
395
|
-
}
|
|
396
377
|
async uploadMedia(query) {
|
|
397
378
|
const {
|
|
398
379
|
socialAccountId,
|
|
@@ -25,7 +25,12 @@ export function addOAuthToToken(token, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SE
|
|
|
25
25
|
}
|
|
26
26
|
export async function getUserInfoFromHandles(token, handles, logger) {
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
const handlesJoin = handles.join(',');
|
|
29
|
+
if (!handlesJoin.length) {
|
|
30
|
+
loggerWarn(logger, `No handles provided to twitterNative getUserInfoFromHandles`);
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
let query = `users/lookup.json?screen_name=${handlesJoin}`;
|
|
29
34
|
let result = await postRequest({
|
|
30
35
|
token,
|
|
31
36
|
uri: query,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meltwater/conversations-api-services",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import superagent from 'superagent';
|
|
2
2
|
import { removePrefix } from '../../lib/externalId.helpers.js';
|
|
3
|
-
import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.js';
|
|
3
|
+
import { loggerDebug, loggerError, loggerInfo, loggerWarn } from '../../lib/logger.helpers.js';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const INSTAGRAM_URL = 'https://graph.facebook.com';
|
|
@@ -239,7 +239,11 @@ export async function getLikes(accessToken, externalId, logger) {
|
|
|
239
239
|
);
|
|
240
240
|
return response.body;
|
|
241
241
|
} catch (err) {
|
|
242
|
-
|
|
242
|
+
if(err?.status === 400) {
|
|
243
|
+
loggerWarn(logger,'Warn getLikes Instagram Comment probably deleted on native', err);
|
|
244
|
+
}else{
|
|
245
|
+
loggerError(logger,'Error getLikes Instagram '+externalId,err);
|
|
246
|
+
}
|
|
243
247
|
return 0;
|
|
244
248
|
}
|
|
245
249
|
}
|
|
@@ -496,46 +496,6 @@ export class LinkedInApiClient {
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
async getLikedByUser(
|
|
500
|
-
externalId,
|
|
501
|
-
authorExternalId,
|
|
502
|
-
credentialId,
|
|
503
|
-
companyId
|
|
504
|
-
) {
|
|
505
|
-
let result;
|
|
506
|
-
try {
|
|
507
|
-
let credential = await this.credentialsAPI.getToken(
|
|
508
|
-
credentialId,
|
|
509
|
-
companyId
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
result = await superagent
|
|
513
|
-
.get(
|
|
514
|
-
`${configuration.get(
|
|
515
|
-
'LINKEDIN_API'
|
|
516
|
-
)}/reactions/(actor:${fixedEncodeURIComponent(
|
|
517
|
-
authorExternalId
|
|
518
|
-
)},entity:${fixedEncodeURIComponent(externalId)})`
|
|
519
|
-
)
|
|
520
|
-
.set({
|
|
521
|
-
Authorization: `Bearer ${credential.token}`,
|
|
522
|
-
'X-RestLi-Protocol-Version': configuration.get(
|
|
523
|
-
'LINKEDIN_API_VERSION'
|
|
524
|
-
),
|
|
525
|
-
'LinkedIn-Version': '202311',
|
|
526
|
-
})
|
|
527
|
-
.then((result) => result.body);
|
|
528
|
-
} catch (error) {
|
|
529
|
-
logger.error('Error in getLikesByUser', error, {
|
|
530
|
-
[MeltwaterAttributes.COMPANYID]: companyId,
|
|
531
|
-
[MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
|
|
532
|
-
[MeltwaterAttributes.CREDENTIALID]: credentialId,
|
|
533
|
-
});
|
|
534
|
-
return false;
|
|
535
|
-
}
|
|
536
|
-
return true;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
499
|
async uploadMedia(query) {
|
|
540
500
|
const { socialAccountId, url, token, data } = query;
|
|
541
501
|
|
|
@@ -32,7 +32,12 @@ export function addOAuthToToken(token, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SE
|
|
|
32
32
|
|
|
33
33
|
export async function getUserInfoFromHandles(token, handles, logger) {
|
|
34
34
|
try {
|
|
35
|
-
|
|
35
|
+
const handlesJoin = handles.join(',');
|
|
36
|
+
if(!handlesJoin.length){
|
|
37
|
+
loggerWarn(logger,`No handles provided to twitterNative getUserInfoFromHandles`);
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
let query = `users/lookup.json?screen_name=${handlesJoin}`;
|
|
36
41
|
let result = await postRequest({ token, uri: query, logger });
|
|
37
42
|
return result.data;
|
|
38
43
|
} catch (e) {
|