@meltwater/conversations-api-services 1.0.12 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
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",
@@ -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
+ }
@@ -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
+ }