@meltwater/conversations-api-services 1.1.9 → 1.1.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/dist/cjs/data-access/http/facebook.native.js +8 -4
- package/dist/cjs/data-access/http/linkedin.native.js +1 -1
- package/dist/esm/data-access/http/facebook.native.js +8 -4
- package/dist/esm/data-access/http/linkedin.native.js +1 -1
- package/package.json +1 -1
- package/src/data-access/http/facebook.native.js +15 -6
- package/src/data-access/http/linkedin.native.js +1 -1
|
@@ -212,16 +212,20 @@ async function isUserBanned(token, authorId, pageId, logger) {
|
|
|
212
212
|
}
|
|
213
213
|
return false;
|
|
214
214
|
}
|
|
215
|
-
async function getProfile(token, authorId, logger) {
|
|
215
|
+
async function getProfile(token, authorId, fields, logger) {
|
|
216
216
|
if (!authorId) {
|
|
217
217
|
return false;
|
|
218
218
|
}
|
|
219
219
|
let response = {};
|
|
220
220
|
const userNoPrefix = (0, _externalIdHelpers.removePrefix)(authorId);
|
|
221
|
+
const queryParams = {
|
|
222
|
+
access_token: token
|
|
223
|
+
};
|
|
224
|
+
if (fields) {
|
|
225
|
+
queryParams.fields = fields;
|
|
226
|
+
}
|
|
221
227
|
try {
|
|
222
|
-
response = await _superagent.default.get(`${FACEBOOK_URL}/${userNoPrefix}`).set('Accept', 'application/json').set('Content-Type', 'application/json').query(
|
|
223
|
-
access_token: token
|
|
224
|
-
}).send();
|
|
228
|
+
response = await _superagent.default.get(`${FACEBOOK_URL}/${userNoPrefix}`).set('Accept', 'application/json').set('Content-Type', 'application/json').query(queryParams).send();
|
|
225
229
|
} catch (err) {
|
|
226
230
|
if (err?.response?.body?.error) {
|
|
227
231
|
(0, _loggerHelpers.loggerError)(logger, `Failed to call facebook api for userId ${userNoPrefix}: ${err.response.body.error.message}`);
|
|
@@ -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
|
-
|
|
483
|
+
// linkedin throws an error if the user has not liked the post
|
|
484
484
|
return false;
|
|
485
485
|
}
|
|
486
486
|
return true;
|
|
@@ -193,16 +193,20 @@ export async function isUserBanned(token, authorId, pageId, logger) {
|
|
|
193
193
|
}
|
|
194
194
|
return false;
|
|
195
195
|
}
|
|
196
|
-
export async function getProfile(token, authorId, logger) {
|
|
196
|
+
export async function getProfile(token, authorId, fields, logger) {
|
|
197
197
|
if (!authorId) {
|
|
198
198
|
return false;
|
|
199
199
|
}
|
|
200
200
|
let response = {};
|
|
201
201
|
const userNoPrefix = removePrefix(authorId);
|
|
202
|
+
const queryParams = {
|
|
203
|
+
access_token: token
|
|
204
|
+
};
|
|
205
|
+
if (fields) {
|
|
206
|
+
queryParams.fields = fields;
|
|
207
|
+
}
|
|
202
208
|
try {
|
|
203
|
-
response = await superagent.get(`${FACEBOOK_URL}/${userNoPrefix}`).set('Accept', 'application/json').set('Content-Type', 'application/json').query(
|
|
204
|
-
access_token: token
|
|
205
|
-
}).send();
|
|
209
|
+
response = await superagent.get(`${FACEBOOK_URL}/${userNoPrefix}`).set('Accept', 'application/json').set('Content-Type', 'application/json').query(queryParams).send();
|
|
206
210
|
} catch (err) {
|
|
207
211
|
if (err?.response?.body?.error) {
|
|
208
212
|
loggerError(logger, `Failed to call facebook api for userId ${userNoPrefix}: ${err.response.body.error.message}`);
|
|
@@ -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
|
-
|
|
461
|
+
// linkedin throws an error if the user has not liked the post
|
|
462
462
|
return false;
|
|
463
463
|
}
|
|
464
464
|
return true;
|
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.11",
|
|
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",
|
|
@@ -242,7 +242,7 @@ export async function unlike(token, externalId, logger) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
export async function isUserBanned(token, authorId, pageId, logger) {
|
|
245
|
-
try{
|
|
245
|
+
try {
|
|
246
246
|
if (!pageId) {
|
|
247
247
|
// if no pageId to check this call will fail
|
|
248
248
|
// should only happen with temp edge docs
|
|
@@ -279,13 +279,17 @@ export async function isUserBanned(token, authorId, pageId, logger) {
|
|
|
279
279
|
responseBody: JSON.stringify(response.body),
|
|
280
280
|
}
|
|
281
281
|
);
|
|
282
|
-
}catch(err){
|
|
283
|
-
loggerError(
|
|
284
|
-
|
|
282
|
+
} catch (err) {
|
|
283
|
+
loggerError(
|
|
284
|
+
logger,
|
|
285
|
+
`Failed to call facebook api isUserBanned for userId ${authorId} ${pageId}`,
|
|
286
|
+
err
|
|
287
|
+
);
|
|
288
|
+
}
|
|
285
289
|
return false;
|
|
286
290
|
}
|
|
287
291
|
|
|
288
|
-
export async function getProfile(token, authorId, logger) {
|
|
292
|
+
export async function getProfile(token, authorId, fields, logger) {
|
|
289
293
|
if (!authorId) {
|
|
290
294
|
return false;
|
|
291
295
|
}
|
|
@@ -293,12 +297,17 @@ export async function getProfile(token, authorId, logger) {
|
|
|
293
297
|
let response = {};
|
|
294
298
|
const userNoPrefix = removePrefix(authorId);
|
|
295
299
|
|
|
300
|
+
const queryParams = { access_token: token };
|
|
301
|
+
if (fields) {
|
|
302
|
+
queryParams.fields = fields;
|
|
303
|
+
}
|
|
304
|
+
|
|
296
305
|
try {
|
|
297
306
|
response = await superagent
|
|
298
307
|
.get(`${FACEBOOK_URL}/${userNoPrefix}`)
|
|
299
308
|
.set('Accept', 'application/json')
|
|
300
309
|
.set('Content-Type', 'application/json')
|
|
301
|
-
.query(
|
|
310
|
+
.query(queryParams)
|
|
302
311
|
.send();
|
|
303
312
|
} catch (err) {
|
|
304
313
|
if (err?.response?.body?.error) {
|
|
@@ -630,7 +630,7 @@ export async function likedByUser(
|
|
|
630
630
|
})
|
|
631
631
|
.then((result) => result.body);
|
|
632
632
|
} catch (error) {
|
|
633
|
-
|
|
633
|
+
// linkedin throws an error if the user has not liked the post
|
|
634
634
|
return false;
|
|
635
635
|
}
|
|
636
636
|
return true;
|