@meltwater/conversations-api-services 1.0.41 → 1.0.42
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.
|
@@ -113,11 +113,37 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
113
113
|
if (mediaId) {
|
|
114
114
|
mediaId = mediaId.replace('urn:li:image:', 'urn:li:digitalmediaAsset:');
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
// Extract mentions from the messageText
|
|
118
|
+
// https://learn.microsoft.com/en-us/linkedin/compliance/integrations/shares/ugc-post-api?tabs=http#memberattributedentity
|
|
119
|
+
const mentionRegex = /<span class="highlight-mention" data-mention-id="([^"]+)"[^>]*>([^<]+)<\/span>/g;
|
|
120
|
+
let match;
|
|
121
|
+
const attributes = [];
|
|
122
|
+
let textWithoutMentions = messageText;
|
|
123
|
+
while ((match = mentionRegex.exec(messageText)) !== null) {
|
|
124
|
+
attributes.push({
|
|
125
|
+
"type": "MENTION",
|
|
126
|
+
"entity": match[1],
|
|
127
|
+
"start": match.index,
|
|
128
|
+
"length": match[2].length,
|
|
129
|
+
"value": match[1].includes('urn:li:organization') ? {
|
|
130
|
+
"com.linkedin.common.CompanyAttributedEntity": {
|
|
131
|
+
"company": match[1]
|
|
132
|
+
}
|
|
133
|
+
} : {
|
|
134
|
+
// contains person
|
|
135
|
+
"com.linkedin.common.MemberAttributedEntity": {
|
|
136
|
+
"member": match[1]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
textWithoutMentions = textWithoutMentions.replace(match[0], match[2]);
|
|
141
|
+
}
|
|
116
142
|
let body = {
|
|
117
143
|
actor: socialAccountId,
|
|
118
144
|
message: {
|
|
119
|
-
attributes:
|
|
120
|
-
text:
|
|
145
|
+
attributes: attributes,
|
|
146
|
+
text: textWithoutMentions // Replace mention spans with the mention text
|
|
121
147
|
}
|
|
122
148
|
};
|
|
123
149
|
if (discussionType === 're') {
|
|
@@ -93,11 +93,37 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
93
93
|
if (mediaId) {
|
|
94
94
|
mediaId = mediaId.replace('urn:li:image:', 'urn:li:digitalmediaAsset:');
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
// Extract mentions from the messageText
|
|
98
|
+
// https://learn.microsoft.com/en-us/linkedin/compliance/integrations/shares/ugc-post-api?tabs=http#memberattributedentity
|
|
99
|
+
const mentionRegex = /<span class="highlight-mention" data-mention-id="([^"]+)"[^>]*>([^<]+)<\/span>/g;
|
|
100
|
+
let match;
|
|
101
|
+
const attributes = [];
|
|
102
|
+
let textWithoutMentions = messageText;
|
|
103
|
+
while ((match = mentionRegex.exec(messageText)) !== null) {
|
|
104
|
+
attributes.push({
|
|
105
|
+
"type": "MENTION",
|
|
106
|
+
"entity": match[1],
|
|
107
|
+
"start": match.index,
|
|
108
|
+
"length": match[2].length,
|
|
109
|
+
"value": match[1].includes('urn:li:organization') ? {
|
|
110
|
+
"com.linkedin.common.CompanyAttributedEntity": {
|
|
111
|
+
"company": match[1]
|
|
112
|
+
}
|
|
113
|
+
} : {
|
|
114
|
+
// contains person
|
|
115
|
+
"com.linkedin.common.MemberAttributedEntity": {
|
|
116
|
+
"member": match[1]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
textWithoutMentions = textWithoutMentions.replace(match[0], match[2]);
|
|
121
|
+
}
|
|
96
122
|
let body = {
|
|
97
123
|
actor: socialAccountId,
|
|
98
124
|
message: {
|
|
99
|
-
attributes:
|
|
100
|
-
text:
|
|
125
|
+
attributes: attributes,
|
|
126
|
+
text: textWithoutMentions // Replace mention spans with the mention text
|
|
101
127
|
}
|
|
102
128
|
};
|
|
103
129
|
if (discussionType === 're') {
|
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.42",
|
|
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",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import superagent from 'superagent';
|
|
3
2
|
import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.js';
|
|
4
3
|
|
|
@@ -126,12 +125,37 @@ async function publish(token,discussionType, mediaId,inReplyToId,socialAccountId
|
|
|
126
125
|
);
|
|
127
126
|
}
|
|
128
127
|
|
|
128
|
+
// Extract mentions from the messageText
|
|
129
|
+
// https://learn.microsoft.com/en-us/linkedin/compliance/integrations/shares/ugc-post-api?tabs=http#memberattributedentity
|
|
130
|
+
const mentionRegex = /<span class="highlight-mention" data-mention-id="([^"]+)"[^>]*>([^<]+)<\/span>/g;
|
|
131
|
+
let match;
|
|
132
|
+
const attributes = [];
|
|
133
|
+
let textWithoutMentions = messageText;
|
|
134
|
+
while ((match = mentionRegex.exec(messageText)) !== null) {
|
|
135
|
+
attributes.push({
|
|
136
|
+
"type": "MENTION",
|
|
137
|
+
"entity": match[1],
|
|
138
|
+
"start": match.index,
|
|
139
|
+
"length": match[2].length,
|
|
140
|
+
"value": match[1].includes('urn:li:organization') ? {
|
|
141
|
+
"com.linkedin.common.CompanyAttributedEntity": {
|
|
142
|
+
"company": match[1]
|
|
143
|
+
}
|
|
144
|
+
} : { // contains person
|
|
145
|
+
"com.linkedin.common.MemberAttributedEntity": {
|
|
146
|
+
"member": match[1]
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
textWithoutMentions = textWithoutMentions.replace(match[0], match[2]);
|
|
151
|
+
}
|
|
152
|
+
|
|
129
153
|
let body = {
|
|
130
154
|
actor: socialAccountId,
|
|
131
155
|
message: {
|
|
132
|
-
attributes:
|
|
133
|
-
text:
|
|
134
|
-
}
|
|
156
|
+
attributes: attributes,
|
|
157
|
+
text: textWithoutMentions // Replace mention spans with the mention text
|
|
158
|
+
}
|
|
135
159
|
};
|
|
136
160
|
if (discussionType === 're') {
|
|
137
161
|
body.parentComment = inReplyToId;
|