@meltwater/conversations-api-services 1.0.11 → 1.0.13

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.
@@ -2,6 +2,7 @@ import superagent from 'superagent';
2
2
  import configuration from '../../lib/configuration.js';
3
3
  import { CredentialsApiClient } from '../http/credentialsApi.client.js';
4
4
  import logger from '../../lib/logger.js';
5
+ import { MeltwaterAttributes } from '../../lib/logger.helpers.js';
5
6
 
6
7
  export class LinkedInApiClient {
7
8
  constructor() {
@@ -27,25 +28,25 @@ export class LinkedInApiClient {
27
28
  } = document;
28
29
 
29
30
  const loggerChild = logger.child({
30
- 'meltwater.document.id': documentId,
31
- 'meltwater.company.id': companyId,
32
- 'meltwater.social.credential_id': credentialId,
33
- 'meltwater.document.externalId': externalId,
31
+ [MeltwaterAttributes.DOCUMENTID]: documentId,
32
+ [MeltwaterAttributes.COMPANYID]: companyId,
33
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
34
+ [MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
34
35
  });
35
36
 
36
37
  let response;
37
38
  let payload = { actor: socialAccountId, object: externalId };
38
39
  let query = likedByUser
39
40
  ? `${configuration.get(
40
- 'LINKEDIN_API'
41
- )}/socialActions/${fixedEncodeURIComponent(externalId)}/likes`
41
+ 'LINKEDIN_API'
42
+ )}/socialActions/${fixedEncodeURIComponent(externalId)}/likes`
42
43
  : `${configuration.get(
43
- 'LINKEDIN_API'
44
- )}/socialActions/${fixedEncodeURIComponent(
45
- externalId
46
- )}/likes/${fixedEncodeURIComponent(
47
- payload.actor
48
- )}?actor=${fixedEncodeURIComponent(payload.actor)}`;
44
+ 'LINKEDIN_API'
45
+ )}/socialActions/${fixedEncodeURIComponent(
46
+ externalId
47
+ )}/likes/${fixedEncodeURIComponent(
48
+ payload.actor
49
+ )}?actor=${fixedEncodeURIComponent(payload.actor)}`;
49
50
 
50
51
  try {
51
52
  let credential = await this.credentialsAPI.getToken(
@@ -55,7 +56,7 @@ export class LinkedInApiClient {
55
56
  if (!likedByUser) {
56
57
  loggerChild.debug(`${documentId} - trying Delete `, {
57
58
  query,
58
- payload,
59
+ payload: JSON.stringify(payload),
59
60
  });
60
61
  response = await superagent
61
62
  .delete(query)
@@ -70,7 +71,7 @@ export class LinkedInApiClient {
70
71
  } else {
71
72
  loggerChild.debug(`${documentId} - sending to linkedin `, {
72
73
  query,
73
- payload,
74
+ payload: JSON.stringify(payload),
74
75
  });
75
76
  response = await superagent
76
77
  .post(query)
@@ -95,9 +96,7 @@ export class LinkedInApiClient {
95
96
  }
96
97
  );
97
98
  } catch (err) {
98
- loggerChild.error(documentId + ' - exception details', {
99
- err,
100
- });
99
+ loggerChild.error(`${documentId} - exception details`, err);
101
100
  throw err;
102
101
  }
103
102
  return response.connection || response;
@@ -120,10 +119,10 @@ export class LinkedInApiClient {
120
119
  } = document;
121
120
 
122
121
  const loggerChild = logger.child({
123
- 'meltwater.document.id': documentId,
124
- 'meltwater.company.id': companyId,
125
- 'meltwater.social.credential_id': credentialId,
126
- 'meltwater.document.externalId': externalId,
122
+ [MeltwaterAttributes.DOCUMENTID]: documentId,
123
+ [MeltwaterAttributes.COMPANYID]: companyId,
124
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
125
+ [MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
127
126
  });
128
127
 
129
128
  const [, comment] = externalId.split(',');
@@ -257,14 +256,11 @@ export class LinkedInApiClient {
257
256
  };
258
257
  } catch (err) {
259
258
  logger.error(
260
- documentId + ' - exception linkedin publish ' + err,
261
- err,
262
- {
263
- 'meltwater.document.id': documentId,
264
- 'meltwater.company.id': companyId,
265
- 'meltwater.social.credential_id': credentialId,
266
- }
267
- );
259
+ `${documentId} - exception linkedin publish`, err, {
260
+ [MeltwaterAttributes.DOCUMENTID]: documentId,
261
+ [MeltwaterAttributes.COMPANYID]: companyId,
262
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
263
+ });
268
264
  }
269
265
 
270
266
  return response;
@@ -312,14 +308,11 @@ export class LinkedInApiClient {
312
308
  return response;
313
309
  } catch (err) {
314
310
  logger.error(
315
- documentId + ' - exception linkedin media register ' + err,
316
- err,
317
- {
318
- 'meltwater.document.id': documentId,
319
- 'meltwater.company.id': companyId,
320
- 'meltwater.social.credential_id': credentialId,
321
- }
322
- );
311
+ `${documentId} - exception linkedin media register`, err, {
312
+ [MeltwaterAttributes.DOCUMENTID]: documentId,
313
+ [MeltwaterAttributes.COMPANYID]: companyId,
314
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
315
+ });
323
316
  }
324
317
  }
325
318
 
@@ -393,15 +386,15 @@ export class LinkedInApiClient {
393
386
  async getAllStats(externalId, token) {
394
387
  let response = {};
395
388
  const loggerChild = logger.child({
396
- 'meltwater.document.externalId': externalId,
389
+ [MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
397
390
  });
398
391
 
399
392
  try {
400
393
  response = await superagent
401
394
  .get(
402
395
  configuration.get('LINKEDIN_API') +
403
- '/socialMetadata/' +
404
- fixedEncodeURIComponent(externalId)
396
+ '/socialMetadata/' +
397
+ fixedEncodeURIComponent(externalId)
405
398
  )
406
399
  .timeout(5000) // 5 seconds
407
400
  .set({
@@ -412,7 +405,7 @@ export class LinkedInApiClient {
412
405
  'LinkedIn-Version': '202311',
413
406
  });
414
407
  } catch (error) {
415
- loggerChild.error('Error in getAllStats ' + error, error);
408
+ loggerChild.error('Error in getAllStats', error);
416
409
  }
417
410
 
418
411
  let { commentSummary, reactionSummaries } = response.body || {};
@@ -420,9 +413,8 @@ export class LinkedInApiClient {
420
413
  return { commentSummary, reactionSummaries };
421
414
  } else {
422
415
  loggerChild.error(
423
- `Invalid response getting all Linkedin Stats for externalId = ${externalId} ` +
424
- response,
425
- response
416
+ `Invalid response getting all Linkedin Stats for externalId = ${externalId}`,
417
+ { response: JSON.stringify(response) }
426
418
  );
427
419
  return {};
428
420
  }
@@ -440,8 +432,8 @@ export class LinkedInApiClient {
440
432
  reactionSummaries,
441
433
  };
442
434
  } catch (error) {
443
- logger.error('Error in getSocialStats: ' + error, error, {
444
- 'meltwater.document.externalId': externalId,
435
+ logger.error('Error in getSocialStats', error, {
436
+ [MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
445
437
  });
446
438
  }
447
439
  }
@@ -449,8 +441,8 @@ export class LinkedInApiClient {
449
441
  async getImageMedia(mediaId, credentialId, companyId) {
450
442
  let response = {};
451
443
  const loggerChild = logger.child({
452
- 'meltwater.company.id': companyId,
453
- 'meltwater.social.credential_id': credentialId,
444
+ [MeltwaterAttributes.COMPANYID]: companyId,
445
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
454
446
  });
455
447
 
456
448
  let credential = await this.credentialsAPI.getToken(
@@ -469,8 +461,8 @@ export class LinkedInApiClient {
469
461
  response = await superagent
470
462
  .get(
471
463
  configuration.get('LINKEDIN_API') +
472
- '/images/' +
473
- fixedEncodeURIComponent(mediaId)
464
+ '/images/' +
465
+ fixedEncodeURIComponent(mediaId)
474
466
  )
475
467
  .timeout(5000) // 5 seconds
476
468
  .set({
@@ -481,7 +473,7 @@ export class LinkedInApiClient {
481
473
  'LinkedIn-Version': '202311',
482
474
  });
483
475
  } catch (error) {
484
- loggerChild.error('Error in getImageMedia ' + error, error);
476
+ loggerChild.error('Error in getImageMedia', error);
485
477
  }
486
478
 
487
479
  let { downloadUrl } = response.body || {};
@@ -489,9 +481,8 @@ export class LinkedInApiClient {
489
481
  return { downloadUrl };
490
482
  } else {
491
483
  loggerChild.error(
492
- `Invalid response getting Linkedin media for mediaId = ${mediaId} ` +
493
- response,
494
- response
484
+ `Invalid response getting Linkedin media for mediaId: ${mediaId}`,
485
+ { response: JSON.stringify(response) }
495
486
  );
496
487
  return {};
497
488
  }
@@ -501,8 +492,8 @@ export class LinkedInApiClient {
501
492
  let response = {};
502
493
  let tempValue;
503
494
  const loggerChild = logger.child({
504
- 'meltwater.company.id': companyId,
505
- 'meltwater.social.credential_id': credentialId,
495
+ [MeltwaterAttributes.COMPANYID]: companyId,
496
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
506
497
  });
507
498
 
508
499
  let credential = await this.credentialsAPI.getToken(
@@ -529,8 +520,8 @@ export class LinkedInApiClient {
529
520
  response = await superagent
530
521
  .get(
531
522
  configuration.get('LINKEDIN_API') +
532
- '/videos/' +
533
- fixedEncodeURIComponent(mediaId)
523
+ '/videos/' +
524
+ fixedEncodeURIComponent(mediaId)
534
525
  )
535
526
  .timeout(5000) // 5 seconds
536
527
  .set({
@@ -541,7 +532,7 @@ export class LinkedInApiClient {
541
532
  'LinkedIn-Version': '202311',
542
533
  });
543
534
  } catch (error) {
544
- loggerChild.error('Error in getVideoMedia ' + error, error);
535
+ loggerChild.error('Error in getVideoMedia', error);
545
536
  }
546
537
 
547
538
  let { thumbnail, downloadUrl } = response.body || {};
@@ -549,9 +540,8 @@ export class LinkedInApiClient {
549
540
  return { thumbnail, downloadUrl };
550
541
  } else {
551
542
  loggerChild.error(
552
- `Invalid response getting Linkedin media for mediaId = ${mediaId} ` +
553
- response,
554
- response
543
+ `Invalid response getting Linkedin media for mediaId: ${mediaId}`,
544
+ { response: JSON.stringify(response) }
555
545
  );
556
546
  return {};
557
547
  }
@@ -589,9 +579,9 @@ export class LinkedInApiClient {
589
579
 
590
580
  return {};
591
581
  } catch (error) {
592
- logger.error('Error in getMedia: ' + error, error, {
593
- 'meltwater.company.id': companyId,
594
- 'meltwater.social.credential_id': credentialId,
582
+ logger.error('Error in getMedia', error, {
583
+ [MeltwaterAttributes.COMPANYID]: companyId,
584
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
595
585
  });
596
586
  }
597
587
  }
@@ -626,10 +616,10 @@ export class LinkedInApiClient {
626
616
  })
627
617
  .then((result) => result.body);
628
618
  } catch (error) {
629
- logger.error('Error in getLikesByUser: ' + error, error, {
630
- 'meltwater.company.id': companyId,
631
- 'meltwater.document.externalId': externalId,
632
- 'meltwater.social.credential_id': credentialId,
619
+ logger.error('Error in getLikesByUser', error, {
620
+ [MeltwaterAttributes.COMPANYID]: companyId,
621
+ [MeltwaterAttributes.DOCUMENTEXTERNALID]: externalId,
622
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
633
623
  });
634
624
  return false;
635
625
  }
@@ -1,6 +1,7 @@
1
1
  import superagent from 'superagent';
2
2
  import logger from '../../lib/logger.js';
3
3
  import configuration from '../../lib/configuration.js';
4
+ import { MeltwaterAttributes } from '../../lib/logger.helpers.js';
4
5
 
5
6
  export class MasfClient {
6
7
  constructor() {
@@ -25,7 +26,7 @@ export class MasfClient {
25
26
  logger.error(
26
27
  `Failed requesting Search Services for search list `,
27
28
  error,
28
- { 'meltwater.company.id': companyId }
29
+ { [MeltwaterAttributes.COMPANYID]: companyId }
29
30
  );
30
31
  }
31
32
  }
@@ -50,7 +51,7 @@ export class MasfClient {
50
51
  logger.error(
51
52
  `Failed requesting Search Services for author list `,
52
53
  error,
53
- { 'meltwater.company.id': companyId }
54
+ { [MeltwaterAttributes.COMPANYID]: companyId }
54
55
  );
55
56
  }
56
57
  }
@@ -67,7 +68,7 @@ export class MasfClient {
67
68
  logger.error(
68
69
  `Failed requesting Search Services for author list `,
69
70
  error,
70
- { 'meltwater.company.id': companyId }
71
+ { [MeltwaterAttributes.COMPANYID]: companyId }
71
72
  );
72
73
  }
73
74
  }
@@ -3,6 +3,7 @@ import configuration from '../../lib/configuration.js';
3
3
  import logger from '../../lib/logger.js';
4
4
  import { removePrefix } from '../../lib/externalId.helpers.js';
5
5
  import { CredentialsApiClient } from '../http/credentialsApi.client.js';
6
+ import { MeltwaterAttributes } from '../../lib/logger.helpers.js';
6
7
 
7
8
  export class TikTokApiClient {
8
9
  constructor() {
@@ -26,15 +27,11 @@ export class TikTokApiClient {
26
27
  );
27
28
  return `${credential.token}`;
28
29
  } catch (error) {
29
- logger.error(
30
- `${documentId} - error getting tiktok token - ${error.code}`,
31
- error,
32
- {
33
- 'meltwater.document.id': documentId,
34
- 'meltwater.company.id': companyId,
35
- 'meltwater.social.credential_id': credentialId,
36
- }
37
- );
30
+ logger.error(`${documentId} - error getting tiktok token - ${error.code}`, error, {
31
+ [MeltwaterAttributes.DOCUMENTID]: documentId,
32
+ [MeltwaterAttributes.COMPANYID]: companyId,
33
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
34
+ });
38
35
  }
39
36
  }
40
37
 
@@ -106,7 +103,7 @@ export class TikTokApiClient {
106
103
  `Failed to call tiktok api for documentId ${document.documentId}`,
107
104
  response.body,
108
105
  {
109
- 'meltwater.document.id': document.documentId,
106
+ [MeltwaterAttributes.DOCUMENTID]: document.documentId,
110
107
  }
111
108
  );
112
109
  let error = new Error(
@@ -146,7 +143,7 @@ export class TikTokApiClient {
146
143
  paramArray.forEach((paramString) => {
147
144
  let discussionTypeBucket =
148
145
  retObj[
149
- `${paramString}${document.systemData.connectionsCredential}`
146
+ `${paramString}${document.systemData.connectionsCredential}`
150
147
  ];
151
148
  if (!discussionTypeBucket) {
152
149
  discussionTypeBucket = {
@@ -190,14 +187,13 @@ export class TikTokApiClient {
190
187
  } = documentsByTypeAndCredential.document;
191
188
  const trimmedBusinessId = removePrefix(business_id);
192
189
  const requestResult = await this.sendRequest({
193
- paramString: `${
194
- documentsByTypeAndCredential.paramString
195
- }?business_id=${trimmedBusinessId}&fields=["item_id","create_time","thumbnail_url","share_url","embed_url","caption","video_views","likes","comments","shares"]&filters=${JSON.stringify(
196
- {
197
- video_ids:
198
- documentsByTypeAndCredential.externalIds,
199
- }
200
- )}`,
190
+ paramString: `${documentsByTypeAndCredential.paramString
191
+ }?business_id=${trimmedBusinessId}&fields=["item_id","create_time","thumbnail_url","share_url","embed_url","caption","video_views","likes","comments","shares"]&filters=${JSON.stringify(
192
+ {
193
+ video_ids:
194
+ documentsByTypeAndCredential.externalIds,
195
+ }
196
+ )}`,
201
197
  document: documentsByTypeAndCredential.document,
202
198
  });
203
199
  requestResult.data.videos.forEach(
@@ -343,26 +339,19 @@ export class TikTokApiClient {
343
339
  } else {
344
340
  response = await this.unhide(document, parentDoc);
345
341
  }
346
- logger.info(
347
- `Native Tiktok API Hide Response for documentId ${documentId}`,
348
- {
349
- status: response.status,
350
- ok: response.ok,
351
- 'meltwater.document.id': documentId,
352
- }
353
- );
342
+ logger.info(`Native Tiktok API Hide Response for documentId ${documentId}`, {
343
+ status: response.status,
344
+ ok: response.ok,
345
+ [MeltwaterAttributes.DOCUMENTID]: documentId,
346
+ });
354
347
 
355
348
  if (response.message === 'OK') {
356
349
  return response;
357
350
  }
358
351
  } catch (error) {
359
- logger.error(
360
- `${documentId} - error recieved - ${error.code}`,
361
- error,
362
- {
363
- 'meltwater.document.id': documentId,
364
- }
365
- );
352
+ logger.error(`${documentId} - error recieved - ${error.code}`, error, {
353
+ [MeltwaterAttributes.DOCUMENTID]: documentId,
354
+ });
366
355
  }
367
356
  }
368
357
 
@@ -419,9 +408,9 @@ export class TikTokApiClient {
419
408
  const video_id =
420
409
  discussionType === 're'
421
410
  ? parentDoc?.metaData?.inReplyTo?.id ||
422
- parentDoc?.metaData?.inReplyTo?.externalId
411
+ parentDoc?.metaData?.inReplyTo?.externalId
423
412
  : document?.metaData?.inReplyTo?.id ||
424
- document?.metaData?.inReplyTo?.externalId;
413
+ document?.metaData?.inReplyTo?.externalId;
425
414
 
426
415
  const { body: publishedMessage } =
427
416
  (await this.sendPost({
@@ -13,6 +13,13 @@ import { LinkedInApiClient } from './http/linkedInApi.client.js';
13
13
  import { TikTokApiClient } from './http/tiktokApi.client.js';
14
14
  import { MasfClient } from './http/masf.client.js';
15
15
  import { WarpZoneApiClient } from './http/WarpZoneApi.client.js';
16
+ import * as messageHelpers from '../lib/message.helpers.js';
17
+ import * as applicationTagFunctions from '../lib/applicationTags.helpers.js';
18
+
19
+ const DocumentHelperFunctions = {
20
+ ...messageHelpers,
21
+ ...applicationTagFunctions
22
+ }
16
23
 
17
24
  export {
18
25
  awsS3Client,
@@ -30,4 +37,5 @@ export {
30
37
  TikTokApiClient,
31
38
  MasfClient,
32
39
  WarpZoneApiClient,
40
+ DocumentHelperFunctions,
33
41
  };
@@ -20,3 +20,8 @@ export function checkApplicationTagsForUserLikes(applicationTags) {
20
20
  return false;
21
21
  }
22
22
  }
23
+
24
+ export function getCredentialIdFromApplicationTags(applicationTags) {
25
+ return applicationTags.find((appTag) => appTag.startsWith('connectionsCredential=') || appTag.startsWith('connectionscredential='))
26
+ ?.substring(22);
27
+ }
@@ -2,6 +2,7 @@ import logger from '../lib/logger.js';
2
2
  import { IRClient } from '../data-access/http/ir.clien.jst';
3
3
  import XRunes from '@meltwater/xrunes';
4
4
  import xRunesCore from '@meltwater/xrunes-core';
5
+ import { MeltwaterAttributes } from '../lib/logger.helpers.js';
5
6
 
6
7
  class HiddenCommentHelper {
7
8
  constructor({ company, user, traceId }) {
@@ -88,15 +89,15 @@ class HiddenCommentHelper {
88
89
  runes.query = await this.xRunes.render(runes.query);
89
90
 
90
91
  logger.debug(`export api query: ${JSON.stringify(runes.query)}`, {
91
- 'meltwater.company.id': companyId,
92
- 'meltwater.social.credential_id': credentialId,
92
+ [MeltwaterAttributes.COMPANYID]: companyId,
93
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
93
94
  });
94
95
 
95
96
  let results = await this.irClient.export(runes);
96
97
 
97
98
  logger.debug(`export api result: ${JSON.stringify(results)}`, {
98
- 'meltwater.company.id': companyId,
99
- 'meltwater.social.credential_id': credentialId,
99
+ [MeltwaterAttributes.COMPANYID]: companyId,
100
+ [MeltwaterAttributes.CREDENTIALID]: credentialId,
100
101
  });
101
102
 
102
103
  return results;
@@ -0,0 +1,27 @@
1
+ const MeltwaterAttributes = {
2
+ COMPANYID: 'meltwater.company.id', // Unique identifier of a company as it applies to meltwater search
3
+ DOCUMENTID: 'meltwater.document.id', // Unique identifier of a document indexed into search
4
+ DOCUMENTLANG: 'meltwater.document.lang', // Two-letter country code (lower-case) of the original document
5
+ DOCUMENTEXTERNALID: 'meltwater.document.external_id', // The external ID of the document
6
+ REQUESTFORMAT: 'meltwater.document.request_format', // The document format requested (“gyda”/”quiddity”)
7
+ DOCUMENTIDS: 'meltwater.document_ids', // A list of document Ids
8
+ SEARCHIDS: 'meltwater.search_ids', // List of IDs of saved searches.
9
+ AUTHORLISTIDS: 'meltwater.authorlist_ids', // List of IDs of author lists.
10
+ TAGNAMES: 'meltwater.tag_names', // List of tag names
11
+ SEARCHID: 'meltwater.search.id', // ID for a saved search
12
+ CREDENTIALID: 'meltwater.social.credential_id', // Identifier for Owned and Paid Social Connections.
13
+ CREDENTIALIDS: 'meltwater.social.credential_ids', // List of Credential IDs
14
+ SOCIALEXTERNALID: 'meltwater.social.external_id', // External ID for Owned and Paid Social Connections.
15
+ ASSETID: 'meltwater.asset.id', // Asset ID in the asset library
16
+ ASSETIDS: 'meltwater.asset.ids', // List of Asset IDs
17
+ WORKSPACEID: 'meltwater.workspace.id', // Workspace ID
18
+ PRODUCTTYPE: 'meltwater.product_type', // The name of the product for the search request
19
+ CLIENTNAME: 'meltwater.client_name', // The “client_name” identifier used for API calls
20
+ ORIGINALCLIENTNAME: 'meltwater.original_client_name', // The originating “client_name” identifier used for API calls
21
+ AUTHKEYID: 'meltwater.auth.kid', // The JWT Key ID for the request.
22
+ AUTHEXP: 'meltwater.auth.exp', // The expiration of the auth credentials.
23
+ AUTHPERMISSIONS: 'meltwater.auth.permissions', // List of auth permermissions.
24
+ USERID: 'user.id', // ID of the user
25
+ };
26
+
27
+ export { MeltwaterAttributes };
@@ -0,0 +1,72 @@
1
+
2
+
3
+
4
+ export function isMention({
5
+ appData:{
6
+ isMention = false,
7
+ } = {},
8
+ body:{
9
+ mentions = []
10
+ } = {},
11
+ metaData:{
12
+ authors:[
13
+ {
14
+ authorInfo:{
15
+ externalId: authorExternalId
16
+ } = {}
17
+ } = {}
18
+ ] = [{}],
19
+ inReplyTo:{
20
+ author:{
21
+ externalId: inReplyToExternalId,
22
+ handle: inReplyToHandle,
23
+ } = {},
24
+ } = {},
25
+ discussionType = '',
26
+ source:{
27
+ socialOriginType
28
+ } = {}
29
+ } = {},
30
+ providerSpecific,
31
+ }, credential){
32
+
33
+ // if inReplyToExternalId is the same as the credential's social_account_id, then it's not a mention
34
+ if(inReplyToExternalId && credential.social_account_id &&
35
+ (
36
+ inReplyToExternalId === credential.social_account_id) ||
37
+ inReplyToHandle === credential.username
38
+ ){
39
+ return false;
40
+ }
41
+
42
+ let retIsMention =
43
+ (['og', 're', 'qt'].includes(discussionType) ||
44
+ (discussionType === 'dm' &&
45
+ socialOriginType ===
46
+ 'instagram')) &&
47
+ ((mentions?.length &&
48
+ mentions.some(
49
+ (mention) =>
50
+ mention.toLowerCase() ===
51
+ credential.pageName?.toLowerCase() ||
52
+ mention.toLowerCase() ===
53
+ credential.target_page_name?.toLowerCase() ||
54
+ mention.toLowerCase() ===
55
+ credential.userName?.toLowerCase()||
56
+ mention.toLowerCase() ===
57
+ credential.username?.toLowerCase()
58
+ ))
59
+ ||
60
+ (isMention && socialOriginType === 'facebook'));
61
+ if (providerSpecific) {
62
+ let hasMention = providerSpecific.some(
63
+ ({ facebookPostType }) => facebookPostType === 'mention'
64
+ );
65
+
66
+ if (hasMention) {
67
+ retIsMention = true;
68
+ }
69
+ }
70
+ console.log('isMention '+retIsMention);
71
+ return retIsMention;
72
+ }