@meltwater/conversations-api-services 1.0.28 → 1.0.30

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.
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.LinkedInApiClient = void 0;
7
7
  exports.getOrganization = getOrganization;
8
+ exports.getOrganizations = getOrganizations;
8
9
  exports.getProfile = getProfile;
9
10
  var _superagent = _interopRequireDefault(require("superagent"));
10
11
  var _configuration = _interopRequireDefault(require("../../lib/configuration.js"));
@@ -486,6 +487,25 @@ async function getOrganization(urn, token) {
486
487
  _logger.default.info(`Finished requesting LinkedIn API for organizationId ${urn}`);
487
488
  return organization;
488
489
  }
490
+ async function getOrganizations(urn, token) {
491
+ const [,,, id] = urn.split(':');
492
+ let organizations;
493
+ try {
494
+ organizations = await _superagent.default.get(`${_configuration.default.get('LINKEDIN_API_DATE')}/organizationsLookup?ids=List(${id})`).timeout(5000) // 5 seconds
495
+ .set({
496
+ Authorization: `Bearer ${token}`,
497
+ 'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
498
+ 'LinkedIn-Version': '202411'
499
+ }).then(result => {
500
+ const res = result.body;
501
+ return res.results[id];
502
+ });
503
+ } catch (error) {
504
+ _logger.default.error(`Failed requesting LinkedIn API for organization id ${id}`, error);
505
+ }
506
+ _logger.default.info(`Finished requesting LinkedIn API for organization id ${id}`);
507
+ return organizations;
508
+ }
489
509
  function fixedEncodeURIComponent(str) {
490
510
  return encodeURIComponent(str).replace('(', '%28').replace(')', '%29');
491
511
  }
@@ -37,7 +37,8 @@ const DocumentHelperFunctions = {
37
37
  };
38
38
  const LinkedInHelpers = {
39
39
  getOrganization: _linkedInApiClient.getOrganization,
40
- getProfile: _linkedInApiClient.getProfile
40
+ getProfile: _linkedInApiClient.getProfile,
41
+ getOrganizations: _linkedInApiClient.getOrganizations
41
42
  };
42
43
  var _default = exports.default = {
43
44
  InstagramNative,
@@ -42,7 +42,7 @@ function isMention(_ref, credential) {
42
42
  if (authorExternalId && credential.social_account_id && authorExternalId === credential.social_account_id || authorHandle?.length && (authorHandle.toLowerCase() === credential.username?.toLowerCase || authorHandle.toLowerCase() === credential.handle?.toLowerCase())) {
43
43
  return false;
44
44
  }
45
- let retIsMention = (['og', 're', 'qt'].includes(discussionType) || discussionType === 'dm' && socialOriginType === 'instagram') && (mentions?.length && mentions.some(mention => mention.toLowerCase() === credential.pageName?.toLowerCase() || mention.toLowerCase() === credential.target_page_name?.toLowerCase() || mention.toLowerCase() === credential.userName?.toLowerCase() || mention.toLowerCase() === credential.username?.toLowerCase()) || isMention && socialOriginType === 'facebook');
45
+ let retIsMention = (['og', 're', 'qt'].includes(discussionType) || discussionType === 'dm' && socialOriginType === 'instagram') && (mentions?.length && mentions.some(mention => mention.toLowerCase() === credential.pageName?.toLowerCase() || mention.toLowerCase() === credential.target_page_name?.toLowerCase() || mention.toLowerCase() === credential.userName?.toLowerCase() || mention.toLowerCase() === credential.username?.toLowerCase() || mention.toLowerCase() === credential.social_account_id?.toLowerCase() || mention.toLowerCase() === credential.SocialAccountId?.toLowerCase()) || isMention && socialOriginType === 'facebook');
46
46
  if (providerSpecific) {
47
47
  let hasMention = providerSpecific.some(_ref2 => {
48
48
  let {
@@ -476,6 +476,25 @@ export async function getOrganization(urn, token) {
476
476
  logger.info(`Finished requesting LinkedIn API for organizationId ${urn}`);
477
477
  return organization;
478
478
  }
479
+ export async function getOrganizations(urn, token) {
480
+ const [,,, id] = urn.split(':');
481
+ let organizations;
482
+ try {
483
+ organizations = await superagent.get(`${configuration.get('LINKEDIN_API_DATE')}/organizationsLookup?ids=List(${id})`).timeout(5000) // 5 seconds
484
+ .set({
485
+ Authorization: `Bearer ${token}`,
486
+ 'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
487
+ 'LinkedIn-Version': '202411'
488
+ }).then(result => {
489
+ const res = result.body;
490
+ return res.results[id];
491
+ });
492
+ } catch (error) {
493
+ logger.error(`Failed requesting LinkedIn API for organization id ${id}`, error);
494
+ }
495
+ logger.info(`Finished requesting LinkedIn API for organization id ${id}`);
496
+ return organizations;
497
+ }
479
498
  function fixedEncodeURIComponent(str) {
480
499
  return encodeURIComponent(str).replace('(', '%28').replace(')', '%29');
481
500
  }
@@ -9,7 +9,7 @@ import { IdentityServicesClient } from './http/identityServices.client.js';
9
9
  import { InstagramApiClient } from './http/instagramApi.client.js';
10
10
  import { InstagramVideoClient } from './http/InstagramVideoClient.js';
11
11
  import { IRClient } from './http/ir.client.js';
12
- import { LinkedInApiClient, getOrganization, getProfile } from './http/linkedInApi.client.js';
12
+ import { LinkedInApiClient, getOrganization, getProfile, getOrganizations } 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';
@@ -29,7 +29,8 @@ const DocumentHelperFunctions = {
29
29
  };
30
30
  const LinkedInHelpers = {
31
31
  getOrganization,
32
- getProfile
32
+ getProfile,
33
+ getOrganizations
33
34
  };
34
35
  export default {
35
36
  InstagramNative,
@@ -36,7 +36,7 @@ export function isMention(_ref, credential) {
36
36
  if (authorExternalId && credential.social_account_id && authorExternalId === credential.social_account_id || authorHandle?.length && (authorHandle.toLowerCase() === credential.username?.toLowerCase || authorHandle.toLowerCase() === credential.handle?.toLowerCase())) {
37
37
  return false;
38
38
  }
39
- let retIsMention = (['og', 're', 'qt'].includes(discussionType) || discussionType === 'dm' && socialOriginType === 'instagram') && (mentions?.length && mentions.some(mention => mention.toLowerCase() === credential.pageName?.toLowerCase() || mention.toLowerCase() === credential.target_page_name?.toLowerCase() || mention.toLowerCase() === credential.userName?.toLowerCase() || mention.toLowerCase() === credential.username?.toLowerCase()) || isMention && socialOriginType === 'facebook');
39
+ let retIsMention = (['og', 're', 'qt'].includes(discussionType) || discussionType === 'dm' && socialOriginType === 'instagram') && (mentions?.length && mentions.some(mention => mention.toLowerCase() === credential.pageName?.toLowerCase() || mention.toLowerCase() === credential.target_page_name?.toLowerCase() || mention.toLowerCase() === credential.userName?.toLowerCase() || mention.toLowerCase() === credential.username?.toLowerCase() || mention.toLowerCase() === credential.social_account_id?.toLowerCase() || mention.toLowerCase() === credential.SocialAccountId?.toLowerCase()) || isMention && socialOriginType === 'facebook');
40
40
  if (providerSpecific) {
41
41
  let hasMention = providerSpecific.some(_ref2 => {
42
42
  let {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
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",
@@ -654,6 +654,43 @@ export async function getOrganization(urn, token) {
654
654
 
655
655
  return organization;
656
656
  }
657
+
658
+ export async function getOrganizations(urn, token) {
659
+ const [, , , id] = urn.split(':');
660
+ let organizations;
661
+ try {
662
+ organizations = await superagent
663
+ .get(
664
+ `${configuration.get(
665
+ 'LINKEDIN_API_DATE'
666
+ )}/organizationsLookup?ids=List(${id})`
667
+ )
668
+ .timeout(5000) // 5 seconds
669
+ .set({
670
+ Authorization: `Bearer ${token}`,
671
+ 'X-RestLi-Protocol-Version': configuration.get(
672
+ 'LINKEDIN_API_VERSION'
673
+ ),
674
+ 'LinkedIn-Version': '202411',
675
+ })
676
+ .then((result) => {
677
+ const res = result.body;
678
+ return res.results[id];
679
+ });
680
+ } catch (error) {
681
+ logger.error(
682
+ `Failed requesting LinkedIn API for organization id ${id}`,
683
+ error
684
+ );
685
+ }
686
+
687
+ logger.info(
688
+ `Finished requesting LinkedIn API for organization id ${id}`
689
+ );
690
+
691
+ return organizations;
692
+ }
693
+
657
694
  function fixedEncodeURIComponent(str) {
658
695
  return encodeURIComponent(str).replace('(', '%28').replace(')', '%29');
659
696
  }
@@ -9,12 +9,17 @@ import { IdentityServicesClient } from './http/identityServices.client.js';
9
9
  import { InstagramApiClient } from './http/instagramApi.client.js';
10
10
  import { InstagramVideoClient } from './http/InstagramVideoClient.js';
11
11
  import { IRClient } from './http/ir.client.js';
12
- import { LinkedInApiClient, getOrganization, getProfile } from './http/linkedInApi.client.js';
12
+ import {
13
+ LinkedInApiClient,
14
+ getOrganization,
15
+ getProfile,
16
+ getOrganizations,
17
+ } from './http/linkedInApi.client.js';
13
18
  import { TikTokApiClient } from './http/tiktokApi.client.js';
14
19
  import { MasfClient } from './http/masf.client.js';
15
20
  import { WarpZoneApiClient } from './http/WarpZoneApi.client.js';
16
21
  import * as messageHelpers from '../lib/message.helpers.js';
17
- import * as applicationTagFunctions from '../lib/applicationTags.helpers.js';
22
+ import * as applicationTagFunctions from '../lib/applicationTags.helpers.js';
18
23
  import * as hiddenHelpers from '../lib/hidden.helpers.js';
19
24
  import * as FacebookNative from './http/facebook.native.js';
20
25
  import * as TiktokNative from './http/tiktok.native.js';
@@ -27,11 +32,12 @@ const DocumentHelperFunctions = {
27
32
  ...messageHelpers,
28
33
  ...applicationTagFunctions,
29
34
  ...hiddenHelpers,
30
- }
35
+ };
31
36
  const LinkedInHelpers = {
32
37
  getOrganization,
33
38
  getProfile,
34
- }
39
+ getOrganizations,
40
+ };
35
41
 
36
42
  export default {
37
43
  InstagramNative,
@@ -69,9 +69,13 @@ export function isMention({
69
69
  mention.toLowerCase() ===
70
70
  credential.target_page_name?.toLowerCase() ||
71
71
  mention.toLowerCase() ===
72
- credential.userName?.toLowerCase()||
72
+ credential.userName?.toLowerCase() ||
73
73
  mention.toLowerCase() ===
74
- credential.username?.toLowerCase()
74
+ credential.username?.toLowerCase() ||
75
+ mention.toLowerCase() ===
76
+ credential.social_account_id?.toLowerCase() ||
77
+ mention.toLowerCase() ===
78
+ credential.SocialAccountId?.toLowerCase()
75
79
  ))
76
80
  ||
77
81
  (isMention && socialOriginType === 'facebook'));