@meltwater/conversations-api-services 1.0.8 → 1.0.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.
- package/package.json +2 -1
- package/src/data-access/http/asset-manager-tvm.client.js +1 -1
- package/src/data-access/http/companiesApi.client.js +2 -1
- package/src/data-access/http/credentialsApi.client.js +15 -5
- package/src/data-access/http/entitlementsApi.client.js +6 -2
- package/src/data-access/http/facebookApi.client.js +129 -42
- package/src/data-access/http/featureToggleApi.client.js +1 -1
- package/src/data-access/http/identityServices.client.js +14 -5
- package/src/data-access/http/instagramApi.client.js +82 -43
- package/src/data-access/http/ir.client.js +24 -13
- package/src/data-access/http/linkedInApi.client.js +63 -19
- package/src/data-access/http/masf.client.js +6 -3
- package/src/data-access/http/tiktokApi.client.js +41 -13
- package/src/lib/hiddenComment.helper.js +8 -2
- package/src/lib/logger.js +11 -6
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.10",
|
|
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",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/meltwater/conversations-api-services#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@elastic/ecs-winston-format": "^1.5.3",
|
|
26
27
|
"@hapi/joi": "^17.1.1",
|
|
27
28
|
"@meltwater/date-range": "^3.6.0",
|
|
28
29
|
"@meltwater/engage-conversations-schemas": "^2.3.10",
|
|
@@ -38,10 +38,15 @@ export class CredentialsApiClient {
|
|
|
38
38
|
{ companyId, userId, productArea },
|
|
39
39
|
userPermissionsEnabled
|
|
40
40
|
) {
|
|
41
|
+
const loggerChild = logger.child({
|
|
42
|
+
'meltwater.company.id': companyId,
|
|
43
|
+
'user.id': userId,
|
|
44
|
+
});
|
|
45
|
+
|
|
41
46
|
let credentials;
|
|
42
47
|
try {
|
|
43
48
|
if (productArea) {
|
|
44
|
-
|
|
49
|
+
loggerChild.info(
|
|
45
50
|
`Get Credentials for company: ${companyId} and user: ${userId}`
|
|
46
51
|
);
|
|
47
52
|
credentials = await superagent
|
|
@@ -66,14 +71,14 @@ export class CredentialsApiClient {
|
|
|
66
71
|
.then((result) => result.body.data);
|
|
67
72
|
}
|
|
68
73
|
} catch (error) {
|
|
69
|
-
|
|
74
|
+
loggerChild.error(
|
|
70
75
|
`Failed requesting Credentials API for companyId ${companyId} ${userId}`,
|
|
71
76
|
error
|
|
72
77
|
);
|
|
73
78
|
return [];
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
|
|
81
|
+
loggerChild.info(
|
|
77
82
|
`Finished requesting Credentials API for companyId ${companyId}`
|
|
78
83
|
);
|
|
79
84
|
|
|
@@ -82,6 +87,11 @@ export class CredentialsApiClient {
|
|
|
82
87
|
|
|
83
88
|
// todo: will this need to ever use productArea?
|
|
84
89
|
async getToken(credentialId, companyId) {
|
|
90
|
+
const loggerChild = logger.child({
|
|
91
|
+
'meltwater.company.id': companyId,
|
|
92
|
+
'meltwater.social.credential_id': credentialId,
|
|
93
|
+
});
|
|
94
|
+
|
|
85
95
|
let token;
|
|
86
96
|
try {
|
|
87
97
|
token = await superagent
|
|
@@ -92,14 +102,14 @@ export class CredentialsApiClient {
|
|
|
92
102
|
return result.body;
|
|
93
103
|
});
|
|
94
104
|
} catch (error) {
|
|
95
|
-
|
|
105
|
+
loggerChild.error(
|
|
96
106
|
`Failed requesting Credentials API for credentialId ${credentialId} and companyId ${companyId}`,
|
|
97
107
|
error
|
|
98
108
|
);
|
|
99
109
|
return;
|
|
100
110
|
}
|
|
101
111
|
|
|
102
|
-
|
|
112
|
+
loggerChild.info(
|
|
103
113
|
`Finished requesting Credentials API for credentialId ${credentialId} and companyId ${companyId}`
|
|
104
114
|
);
|
|
105
115
|
|
|
@@ -10,6 +10,10 @@ export class EntitlementsApiClient {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async getById(entitlementId, companyId, jwt, retries = 0) {
|
|
13
|
+
const loggerChild = logger.child({
|
|
14
|
+
'meltwater.company.id': companyId,
|
|
15
|
+
});
|
|
16
|
+
|
|
13
17
|
let entitlement;
|
|
14
18
|
try {
|
|
15
19
|
let resignedToken = await this.authService.getResignedToken(jwt);
|
|
@@ -21,7 +25,7 @@ export class EntitlementsApiClient {
|
|
|
21
25
|
.set('x-client-name', configuration.get('CLIENT_NAME_HEADER'))
|
|
22
26
|
.then((result) => result.body);
|
|
23
27
|
} catch (error) {
|
|
24
|
-
|
|
28
|
+
loggerChild.error(
|
|
25
29
|
`Failed requesting entitlement ${entitlementId} for companyId ${companyId} retry ${retries}`,
|
|
26
30
|
error
|
|
27
31
|
);
|
|
@@ -32,7 +36,7 @@ export class EntitlementsApiClient {
|
|
|
32
36
|
return;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
loggerChild.info(
|
|
36
40
|
`Finished requesting entitlement ${entitlementId} for companyId ${companyId}`
|
|
37
41
|
);
|
|
38
42
|
|
|
@@ -38,7 +38,12 @@ export class FacebookApiClient {
|
|
|
38
38
|
} catch (error) {
|
|
39
39
|
logger.error(
|
|
40
40
|
`${documentId} - error recieved - ${error.code}`,
|
|
41
|
-
error
|
|
41
|
+
error,
|
|
42
|
+
{
|
|
43
|
+
'meltwater.document.id': documentId,
|
|
44
|
+
'meltwater.company.id': companyId,
|
|
45
|
+
'meltwater.social.credential_id': credentialId,
|
|
46
|
+
}
|
|
42
47
|
);
|
|
43
48
|
return undefined;
|
|
44
49
|
}
|
|
@@ -77,7 +82,12 @@ export class FacebookApiClient {
|
|
|
77
82
|
} catch (error) {
|
|
78
83
|
logger.error(
|
|
79
84
|
`${documentId} - error recieved - ${error.code}`,
|
|
80
|
-
error
|
|
85
|
+
error,
|
|
86
|
+
{
|
|
87
|
+
'meltwater.document.id': documentId,
|
|
88
|
+
'meltwater.company.id': companyId,
|
|
89
|
+
'meltwater.social.credential_id': credentialId,
|
|
90
|
+
}
|
|
81
91
|
);
|
|
82
92
|
return undefined;
|
|
83
93
|
}
|
|
@@ -87,8 +97,11 @@ export class FacebookApiClient {
|
|
|
87
97
|
let response;
|
|
88
98
|
const { inReplyToId, text, documentId, attachment } = payload;
|
|
89
99
|
const isGif = attachment && attachment.mimeType === 'image/gif';
|
|
100
|
+
const loggerChild = logger.child({
|
|
101
|
+
'meltwater.document.id': documentId,
|
|
102
|
+
});
|
|
90
103
|
|
|
91
|
-
|
|
104
|
+
loggerChild.debug(
|
|
92
105
|
`Starting to call facebook comment api for documentId ${documentId}`,
|
|
93
106
|
payload
|
|
94
107
|
);
|
|
@@ -105,9 +118,13 @@ export class FacebookApiClient {
|
|
|
105
118
|
isGif && { attachment_share_url: attachment.link }),
|
|
106
119
|
}
|
|
107
120
|
);
|
|
108
|
-
|
|
121
|
+
loggerChild.info(
|
|
109
122
|
`Native Facebook API Publish Comment Response for documentId ${documentId}`,
|
|
110
|
-
{
|
|
123
|
+
{
|
|
124
|
+
'meltwater.document.id': documentId,
|
|
125
|
+
status: response.status,
|
|
126
|
+
ok: response.ok,
|
|
127
|
+
}
|
|
111
128
|
);
|
|
112
129
|
return response.body;
|
|
113
130
|
}
|
|
@@ -117,7 +134,11 @@ export class FacebookApiClient {
|
|
|
117
134
|
const { profileId, recipientId, text, documentId, attachment } =
|
|
118
135
|
payload;
|
|
119
136
|
const isGif = attachment && attachment.mimeType === 'image/gif';
|
|
120
|
-
logger.
|
|
137
|
+
const loggerChild = logger.child({
|
|
138
|
+
'meltwater.document.id': documentId,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
loggerChild.debug(
|
|
121
142
|
`Starting to call facebook messages api for documentId ${documentId}`,
|
|
122
143
|
payload
|
|
123
144
|
);
|
|
@@ -145,14 +166,21 @@ export class FacebookApiClient {
|
|
|
145
166
|
tag: 'HUMAN_AGENT',
|
|
146
167
|
}
|
|
147
168
|
);
|
|
148
|
-
|
|
169
|
+
loggerChild.info(
|
|
149
170
|
`Native Facebook API Publish Private Message Response for documentId ${documentId}`,
|
|
150
|
-
{
|
|
171
|
+
{
|
|
172
|
+
status: response.status,
|
|
173
|
+
ok: response.ok,
|
|
174
|
+
}
|
|
151
175
|
);
|
|
152
176
|
return response.body;
|
|
153
177
|
}
|
|
154
178
|
|
|
155
179
|
async getApi(apiUrl, accessToken, documentId, payload, queryParams = {}) {
|
|
180
|
+
const loggerChild = logger.child({
|
|
181
|
+
'meltwater.document.id': documentId,
|
|
182
|
+
});
|
|
183
|
+
|
|
156
184
|
let response = {};
|
|
157
185
|
try {
|
|
158
186
|
response = await superagent
|
|
@@ -170,17 +198,17 @@ export class FacebookApiClient {
|
|
|
170
198
|
err.response.body.error
|
|
171
199
|
) {
|
|
172
200
|
errorText = `Failed to call facebook api for documentId ${documentId}: ${err.response.body.error.message}`;
|
|
173
|
-
|
|
201
|
+
loggerChild.error(errorText);
|
|
174
202
|
} else {
|
|
175
203
|
errorText = `Failed to call facebook api for documentId ${documentId}`;
|
|
176
|
-
|
|
204
|
+
loggerChild.error(errorText, err);
|
|
177
205
|
}
|
|
178
206
|
|
|
179
207
|
throw new Error(errorText);
|
|
180
208
|
}
|
|
181
209
|
|
|
182
210
|
if (response.status !== 200) {
|
|
183
|
-
|
|
211
|
+
loggerChild.error(
|
|
184
212
|
`Failed to call facebook api for documentId ${documentId}`,
|
|
185
213
|
response.body
|
|
186
214
|
);
|
|
@@ -196,6 +224,10 @@ export class FacebookApiClient {
|
|
|
196
224
|
|
|
197
225
|
async postApi(apiUrl, accessToken, documentId, payload) {
|
|
198
226
|
let response = {};
|
|
227
|
+
const loggerChild = logger.child({
|
|
228
|
+
'meltwater.document.id': documentId,
|
|
229
|
+
});
|
|
230
|
+
|
|
199
231
|
try {
|
|
200
232
|
response = await superagent
|
|
201
233
|
.post(apiUrl)
|
|
@@ -212,17 +244,17 @@ export class FacebookApiClient {
|
|
|
212
244
|
err.response.body.error
|
|
213
245
|
) {
|
|
214
246
|
errorText = `Failed to call facebook api for documentId ${documentId}: ${err.response.body.error.message}`;
|
|
215
|
-
|
|
247
|
+
loggerChild.error(errorText);
|
|
216
248
|
} else {
|
|
217
249
|
errorText = `Failed to call facebook api for documentId ${documentId}`;
|
|
218
|
-
|
|
250
|
+
loggerChild.error(errorText, err);
|
|
219
251
|
}
|
|
220
252
|
|
|
221
253
|
throw new Error(errorText);
|
|
222
254
|
}
|
|
223
255
|
|
|
224
256
|
if (response.status !== 200) {
|
|
225
|
-
|
|
257
|
+
loggerChild.error(
|
|
226
258
|
`Failed to call facebook api for documentId ${documentId}`,
|
|
227
259
|
response.body
|
|
228
260
|
);
|
|
@@ -237,6 +269,10 @@ export class FacebookApiClient {
|
|
|
237
269
|
}
|
|
238
270
|
|
|
239
271
|
async deleteApi(apiUrl, accessToken, documentId, payload) {
|
|
272
|
+
const loggerChild = logger.child({
|
|
273
|
+
'meltwater.document.id': documentId,
|
|
274
|
+
});
|
|
275
|
+
|
|
240
276
|
let response = {};
|
|
241
277
|
try {
|
|
242
278
|
response = await superagent
|
|
@@ -254,17 +290,17 @@ export class FacebookApiClient {
|
|
|
254
290
|
err.response.body.error
|
|
255
291
|
) {
|
|
256
292
|
errorText = `Failed to call facebook api for documentId ${documentId}: ${err.response.body.error.message}`;
|
|
257
|
-
|
|
293
|
+
loggerChild.error(errorText);
|
|
258
294
|
} else {
|
|
259
295
|
errorText = `Failed to call facebook api for documentId ${documentId}`;
|
|
260
|
-
|
|
296
|
+
loggerChild.error(errorText, err);
|
|
261
297
|
}
|
|
262
298
|
|
|
263
299
|
throw new Error(errorText);
|
|
264
300
|
}
|
|
265
301
|
|
|
266
302
|
if (response.status !== 200) {
|
|
267
|
-
|
|
303
|
+
loggerChild.error(
|
|
268
304
|
`Failed to call facebook api for documentId ${documentId}`,
|
|
269
305
|
response.body
|
|
270
306
|
);
|
|
@@ -295,6 +331,12 @@ export class FacebookApiClient {
|
|
|
295
331
|
} = {},
|
|
296
332
|
} = document;
|
|
297
333
|
|
|
334
|
+
const loggerChild = logger.child({
|
|
335
|
+
'meltwater.document.id': documentId,
|
|
336
|
+
'meltwater.company.id': companyId,
|
|
337
|
+
'meltwater.social.credential_id': credentialId,
|
|
338
|
+
});
|
|
339
|
+
|
|
298
340
|
let updatedDocument;
|
|
299
341
|
let apiResponse;
|
|
300
342
|
try {
|
|
@@ -302,8 +344,8 @@ export class FacebookApiClient {
|
|
|
302
344
|
credentialId,
|
|
303
345
|
companyId
|
|
304
346
|
);
|
|
305
|
-
|
|
306
|
-
`finished fetching token for Facebook for ${documentId} on company ${companyId}
|
|
347
|
+
loggerChild.debug(
|
|
348
|
+
`finished fetching token for Facebook for ${documentId} on company ${companyId}`
|
|
307
349
|
);
|
|
308
350
|
let payload;
|
|
309
351
|
switch (discussionType) {
|
|
@@ -355,7 +397,7 @@ export class FacebookApiClient {
|
|
|
355
397
|
);
|
|
356
398
|
}
|
|
357
399
|
} catch (exception) {
|
|
358
|
-
|
|
400
|
+
loggerChild.error(
|
|
359
401
|
documentId + ' - exception details ' + exception,
|
|
360
402
|
exception
|
|
361
403
|
);
|
|
@@ -390,8 +432,14 @@ export class FacebookApiClient {
|
|
|
390
432
|
} = document;
|
|
391
433
|
let hideResponse;
|
|
392
434
|
|
|
435
|
+
const loggerChild = logger.child({
|
|
436
|
+
'meltwater.document.id': documentId,
|
|
437
|
+
'meltwater.company.id': companyId,
|
|
438
|
+
'meltwater.social.credential_id': credentialId,
|
|
439
|
+
});
|
|
440
|
+
|
|
393
441
|
try {
|
|
394
|
-
|
|
442
|
+
loggerChild.debug(
|
|
395
443
|
`processing Facebook Version ${version} for documentID ${documentId} on company ${companyId}`
|
|
396
444
|
);
|
|
397
445
|
|
|
@@ -400,7 +448,7 @@ export class FacebookApiClient {
|
|
|
400
448
|
companyId
|
|
401
449
|
);
|
|
402
450
|
|
|
403
|
-
|
|
451
|
+
loggerChild.debug(
|
|
404
452
|
`finished fetching token for facebook for ${documentId} on company ${companyId} `
|
|
405
453
|
);
|
|
406
454
|
|
|
@@ -416,14 +464,14 @@ export class FacebookApiClient {
|
|
|
416
464
|
});
|
|
417
465
|
}
|
|
418
466
|
|
|
419
|
-
|
|
467
|
+
loggerChild.debug(
|
|
420
468
|
`finished hiding in facebook for ${documentId} on company ${companyId} `,
|
|
421
469
|
{ hideResponse }
|
|
422
470
|
);
|
|
423
471
|
|
|
424
472
|
return hideResponse;
|
|
425
473
|
} catch (error) {
|
|
426
|
-
|
|
474
|
+
loggerChild.error(
|
|
427
475
|
`${documentId} - error recieved - ${error.code}`,
|
|
428
476
|
error
|
|
429
477
|
);
|
|
@@ -444,11 +492,17 @@ export class FacebookApiClient {
|
|
|
444
492
|
version,
|
|
445
493
|
} = document;
|
|
446
494
|
|
|
495
|
+
const loggerChild = logger.child({
|
|
496
|
+
'meltwater.document.id': documentId,
|
|
497
|
+
'meltwater.company.id': companyId,
|
|
498
|
+
'meltwater.social.credential_id': credentialId,
|
|
499
|
+
});
|
|
500
|
+
|
|
447
501
|
let banResponse;
|
|
448
502
|
let authorId = authors[0].authorInfo.externalId;
|
|
449
503
|
|
|
450
504
|
try {
|
|
451
|
-
|
|
505
|
+
loggerChild.debug(
|
|
452
506
|
`processing Facebook Version ${version} for profileId ${authorId} on company ${companyId}`
|
|
453
507
|
);
|
|
454
508
|
|
|
@@ -457,7 +511,7 @@ export class FacebookApiClient {
|
|
|
457
511
|
companyId
|
|
458
512
|
);
|
|
459
513
|
|
|
460
|
-
|
|
514
|
+
loggerChild.debug(
|
|
461
515
|
`finished fetching token for facebook for ${authorId} on company ${companyId} `
|
|
462
516
|
);
|
|
463
517
|
|
|
@@ -473,12 +527,15 @@ export class FacebookApiClient {
|
|
|
473
527
|
});
|
|
474
528
|
}
|
|
475
529
|
|
|
476
|
-
|
|
530
|
+
loggerChild.debug(
|
|
477
531
|
`finished banning in facebook for ${authorId} on company ${companyId} `,
|
|
478
532
|
{ banResponse }
|
|
479
533
|
);
|
|
480
534
|
} catch (error) {
|
|
481
|
-
|
|
535
|
+
loggerChild.error(
|
|
536
|
+
`${authorId} - error recieved - ${error.code}`,
|
|
537
|
+
error
|
|
538
|
+
);
|
|
482
539
|
}
|
|
483
540
|
}
|
|
484
541
|
|
|
@@ -495,13 +552,18 @@ export class FacebookApiClient {
|
|
|
495
552
|
} = {},
|
|
496
553
|
version,
|
|
497
554
|
} = document;
|
|
555
|
+
const loggerChild = logger.child({
|
|
556
|
+
'meltwater.document.id': documentId,
|
|
557
|
+
'meltwater.company.id': companyId,
|
|
558
|
+
'meltwater.social.credential_id': credentialId,
|
|
559
|
+
});
|
|
498
560
|
|
|
499
561
|
try {
|
|
500
|
-
|
|
562
|
+
loggerChild.debug(
|
|
501
563
|
`processing Facebook Version ${version} for documentID ${documentId}`
|
|
502
564
|
);
|
|
503
565
|
|
|
504
|
-
|
|
566
|
+
loggerChild.debug(
|
|
505
567
|
`starting to fetch tokens for facebook for ${documentId} on company ${companyId} `
|
|
506
568
|
);
|
|
507
569
|
const token = await this.credentialsAPI.getToken(
|
|
@@ -509,7 +571,7 @@ export class FacebookApiClient {
|
|
|
509
571
|
companyId
|
|
510
572
|
);
|
|
511
573
|
|
|
512
|
-
|
|
574
|
+
loggerChild.debug(
|
|
513
575
|
`finished fetching token for facebook for ${documentId} on company ${companyId} `
|
|
514
576
|
);
|
|
515
577
|
|
|
@@ -517,12 +579,15 @@ export class FacebookApiClient {
|
|
|
517
579
|
? this.like(token, { externalId, documentId })
|
|
518
580
|
: this.unlike(token, { externalId, documentId }));
|
|
519
581
|
|
|
520
|
-
|
|
582
|
+
loggerChild.debug(
|
|
521
583
|
`finished liking in facebook for ${documentId} on company ${companyId} `,
|
|
522
584
|
{ likeResponse }
|
|
523
585
|
);
|
|
524
586
|
} catch (error) {
|
|
525
|
-
|
|
587
|
+
loggerChild.error(
|
|
588
|
+
`${document} - error recieved - ${error.code}`,
|
|
589
|
+
error
|
|
590
|
+
);
|
|
526
591
|
throw error;
|
|
527
592
|
}
|
|
528
593
|
}
|
|
@@ -530,8 +595,11 @@ export class FacebookApiClient {
|
|
|
530
595
|
async like(accessToken, command) {
|
|
531
596
|
let response;
|
|
532
597
|
const { externalId, documentId } = command;
|
|
598
|
+
const loggerChild = logger.child({
|
|
599
|
+
'meltwater.document.id': documentId,
|
|
600
|
+
});
|
|
533
601
|
|
|
534
|
-
|
|
602
|
+
loggerChild.debug(
|
|
535
603
|
`Starting to call facebook like api for documentId ${documentId}`,
|
|
536
604
|
{ command }
|
|
537
605
|
);
|
|
@@ -542,7 +610,7 @@ export class FacebookApiClient {
|
|
|
542
610
|
documentId
|
|
543
611
|
);
|
|
544
612
|
|
|
545
|
-
|
|
613
|
+
loggerChild.info(
|
|
546
614
|
`Native Facebook API Like Response for documentId ${documentId}`,
|
|
547
615
|
{ status: response.status, ok: response.ok }
|
|
548
616
|
);
|
|
@@ -552,8 +620,11 @@ export class FacebookApiClient {
|
|
|
552
620
|
async unlike(accessToken, command) {
|
|
553
621
|
let response;
|
|
554
622
|
const { externalId, documentId } = command;
|
|
623
|
+
const loggerChild = logger.child({
|
|
624
|
+
'meltwater.document.id': documentId,
|
|
625
|
+
});
|
|
555
626
|
|
|
556
|
-
|
|
627
|
+
loggerChild.debug(
|
|
557
628
|
`Starting to call facebook unlike api for documentId ${documentId}`,
|
|
558
629
|
command
|
|
559
630
|
);
|
|
@@ -564,7 +635,7 @@ export class FacebookApiClient {
|
|
|
564
635
|
documentId
|
|
565
636
|
);
|
|
566
637
|
|
|
567
|
-
|
|
638
|
+
loggerChild.info(
|
|
568
639
|
`Native Facebook API Unlike Response for documentId ${documentId}`,
|
|
569
640
|
{ status: response.status, ok: response.ok }
|
|
570
641
|
);
|
|
@@ -574,8 +645,12 @@ export class FacebookApiClient {
|
|
|
574
645
|
async hide(accessToken, command) {
|
|
575
646
|
let response;
|
|
576
647
|
const { externalId, documentId } = command;
|
|
648
|
+
const loggerChild = logger.child({
|
|
649
|
+
'meltwater.document.id': documentId,
|
|
650
|
+
'meltwater.document.external_id': externalId,
|
|
651
|
+
});
|
|
577
652
|
|
|
578
|
-
|
|
653
|
+
loggerChild.debug(
|
|
579
654
|
`Starting to call facebook hide api for documentId ${documentId}`,
|
|
580
655
|
{ command }
|
|
581
656
|
);
|
|
@@ -587,7 +662,7 @@ export class FacebookApiClient {
|
|
|
587
662
|
{ is_hidden: true }
|
|
588
663
|
);
|
|
589
664
|
|
|
590
|
-
|
|
665
|
+
loggerChild.info(
|
|
591
666
|
`Native Facebook API Hide Response for documentId ${documentId}`,
|
|
592
667
|
{ status: response.status, ok: response.ok }
|
|
593
668
|
);
|
|
@@ -597,8 +672,12 @@ export class FacebookApiClient {
|
|
|
597
672
|
async unhide(accessToken, command) {
|
|
598
673
|
let response;
|
|
599
674
|
const { externalId, documentId } = command;
|
|
675
|
+
const loggerChild = logger.child({
|
|
676
|
+
'meltwater.document.id': documentId,
|
|
677
|
+
'meltwater.document.external_id': externalId,
|
|
678
|
+
});
|
|
600
679
|
|
|
601
|
-
|
|
680
|
+
loggerChild.debug(
|
|
602
681
|
`Starting to call facebook unhide api for documentId ${documentId}`,
|
|
603
682
|
command
|
|
604
683
|
);
|
|
@@ -610,7 +689,7 @@ export class FacebookApiClient {
|
|
|
610
689
|
{ is_hidden: false }
|
|
611
690
|
);
|
|
612
691
|
|
|
613
|
-
|
|
692
|
+
loggerChild.info(
|
|
614
693
|
`Native Facebook API Unhide Response for documentId ${documentId}`,
|
|
615
694
|
{ status: response.status, ok: response.ok }
|
|
616
695
|
);
|
|
@@ -646,10 +725,18 @@ export class FacebookApiClient {
|
|
|
646
725
|
return false;
|
|
647
726
|
}
|
|
648
727
|
}
|
|
728
|
+
|
|
649
729
|
logger.info(
|
|
650
730
|
`Native Facebook API is User Banned Response was invalid for userId ${userId} ${credentialId}`,
|
|
651
|
-
{ status: response.status, ok: response.ok }
|
|
731
|
+
{ status: response.status, ok: response.ok },
|
|
732
|
+
{
|
|
733
|
+
'meltwater.document.id': documentId,
|
|
734
|
+
'meltwater.social.credential_id': credentialId,
|
|
735
|
+
'meltwater.company.id': companyId,
|
|
736
|
+
'user.id': userId,
|
|
737
|
+
}
|
|
652
738
|
);
|
|
739
|
+
|
|
653
740
|
return false;
|
|
654
741
|
}
|
|
655
742
|
|
|
@@ -14,6 +14,11 @@ export class IdentityServicesClient {
|
|
|
14
14
|
let user;
|
|
15
15
|
try {
|
|
16
16
|
let resignedToken = await this.authService.getResignedToken(jwt);
|
|
17
|
+
const loggerChild = logger.child({
|
|
18
|
+
'meltwater.user.id': userId,
|
|
19
|
+
'meltwater.company.id': this.companyId,
|
|
20
|
+
});
|
|
21
|
+
|
|
17
22
|
user = await superagent
|
|
18
23
|
.get(`${this.identityServicesUrl}/users/${userId}`)
|
|
19
24
|
.set('Authorization', resignedToken)
|
|
@@ -21,13 +26,13 @@ export class IdentityServicesClient {
|
|
|
21
26
|
.then((result) => result.body.user);
|
|
22
27
|
} catch (error) {
|
|
23
28
|
if (retries <= 3) {
|
|
24
|
-
|
|
29
|
+
loggerChild.error(
|
|
25
30
|
`getById Failed requesting Identity Services for userId ${userId} retry ${retries}`,
|
|
26
31
|
error
|
|
27
32
|
);
|
|
28
33
|
return this.getById(userId, jwt, ++retries);
|
|
29
34
|
} else {
|
|
30
|
-
|
|
35
|
+
loggerChild.error(
|
|
31
36
|
`getById Failed requesting Identity Services app settings for userId ${userId} complete failure`,
|
|
32
37
|
error
|
|
33
38
|
);
|
|
@@ -40,6 +45,10 @@ export class IdentityServicesClient {
|
|
|
40
45
|
|
|
41
46
|
async getAllUsers(jwt, retries = 0) {
|
|
42
47
|
let users;
|
|
48
|
+
const loggerChild = logger.child({
|
|
49
|
+
'meltwater.company.id': this.companyId,
|
|
50
|
+
});
|
|
51
|
+
|
|
43
52
|
try {
|
|
44
53
|
let resignedToken = await this.authService.getResignedToken(jwt);
|
|
45
54
|
users = await superagent
|
|
@@ -51,14 +60,14 @@ export class IdentityServicesClient {
|
|
|
51
60
|
.then((result) => result.body.map((record) => record.user));
|
|
52
61
|
} catch (error) {
|
|
53
62
|
if (retries <= 3) {
|
|
54
|
-
|
|
63
|
+
loggerChild.error(
|
|
55
64
|
`getAllUsers Failed requesting Identity Services for ${this.companyId} retrying ${retries}`,
|
|
56
65
|
error
|
|
57
66
|
);
|
|
58
67
|
return await this.getAllUsers(jwt, ++retries);
|
|
59
68
|
} else {
|
|
60
|
-
|
|
61
|
-
`getAllUsers Failed requesting Identity Services app settings for companyId ${companyId} complete failure`,
|
|
69
|
+
loggerChild.error(
|
|
70
|
+
`getAllUsers Failed requesting Identity Services app settings for companyId ${this.companyId} complete failure`,
|
|
62
71
|
error
|
|
63
72
|
);
|
|
64
73
|
}
|