@meltwater/conversations-api-services 1.1.15 → 1.1.17
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.
|
@@ -32,7 +32,7 @@ async function like(token, externalId, socialAccountId, logger) {
|
|
|
32
32
|
actor: socialAccountId,
|
|
33
33
|
object: externalId
|
|
34
34
|
};
|
|
35
|
-
let query = `${
|
|
35
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(externalId)}/likes`;
|
|
36
36
|
try {
|
|
37
37
|
(0, _loggerHelpers.loggerDebug)(logger, `Linkedin trying to Like `, {
|
|
38
38
|
query,
|
|
@@ -59,7 +59,7 @@ async function unlike(token, externalId, socialAccountId, logger) {
|
|
|
59
59
|
actor: socialAccountId,
|
|
60
60
|
object: externalId
|
|
61
61
|
};
|
|
62
|
-
let query = `${
|
|
62
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(externalId)}/likes/${fixedEncodeURIComponent(payload.actor)}?actor=${fixedEncodeURIComponent(payload.actor)}`;
|
|
63
63
|
try {
|
|
64
64
|
(0, _loggerHelpers.loggerDebug)(logger, `Linkedin trying Delete Previous Like `, {
|
|
65
65
|
query,
|
|
@@ -83,7 +83,7 @@ async function deleteMessage(token, externalId, sourceId, inReplyToId, logger) {
|
|
|
83
83
|
const [, comment] = externalId.split(',');
|
|
84
84
|
const commentId = comment.split(')')[0];
|
|
85
85
|
let response;
|
|
86
|
-
const query = `${
|
|
86
|
+
const query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(inReplyToId)}/comments/${commentId}?actor=${fixedEncodeURIComponent(sourceId)}`;
|
|
87
87
|
try {
|
|
88
88
|
(0, _loggerHelpers.loggerDebug)(logger, `Linkedin trying Delete `, {
|
|
89
89
|
query
|
|
@@ -150,11 +150,6 @@ async function privateMessage(token, messageText, inReplyToId, sourceId, mediaId
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
async function publish(token, discussionType, mediaId, inReplyToId, socialAccountId, messageText, logger) {
|
|
153
|
-
// for now this is needed to make the urns from the images api work until the docs are updated to reflect how to use these new ids.
|
|
154
|
-
if (mediaId) {
|
|
155
|
-
mediaId = mediaId.replace('urn:li:image:', 'urn:li:digitalmediaAsset:');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
153
|
// Extract mentions from the messageText
|
|
159
154
|
// https://learn.microsoft.com/en-us/linkedin/compliance/integrations/shares/ugc-post-api?tabs=http#memberattributedentity
|
|
160
155
|
const mentionRegex = /<span class="highlight-mention" data-mention-id="([^"]+)"[^>]*>([^<]+)<\/span>/g;
|
|
@@ -182,6 +177,8 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
182
177
|
}
|
|
183
178
|
let body = {
|
|
184
179
|
actor: socialAccountId,
|
|
180
|
+
object: inReplyToId,
|
|
181
|
+
// Required field for REST API
|
|
185
182
|
message: {
|
|
186
183
|
attributes: attributes,
|
|
187
184
|
text: textWithoutMentions || '' // Replace mention spans with the mention text
|
|
@@ -191,14 +188,14 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
191
188
|
body.parentComment = inReplyToId;
|
|
192
189
|
}
|
|
193
190
|
if (mediaId) {
|
|
191
|
+
const imageUrn = mediaId.replace('urn:li:digitalmediaAsset:', 'urn:li:image:');
|
|
194
192
|
body.content = [{
|
|
195
193
|
entity: {
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
type: 'IMAGE'
|
|
194
|
+
image: imageUrn
|
|
195
|
+
}
|
|
199
196
|
}];
|
|
200
197
|
}
|
|
201
|
-
let query = `${
|
|
198
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(inReplyToId)}/comments`;
|
|
202
199
|
|
|
203
200
|
// data-listener -> linkedin_api.client sendComment
|
|
204
201
|
let response;
|
|
@@ -474,7 +471,7 @@ async function getSocialStats(externalId, token, logger) {
|
|
|
474
471
|
async function likedByUser(token, externalId, authorExternalId, logger) {
|
|
475
472
|
let result;
|
|
476
473
|
try {
|
|
477
|
-
result = await _superagent.default.get(`${
|
|
474
|
+
result = await _superagent.default.get(`${LINKEDIN_API_REST}/reactions/(actor:${fixedEncodeURIComponent(authorExternalId)},entity:${fixedEncodeURIComponent(externalId)})`).set({
|
|
478
475
|
Authorization: `Bearer ${token}`,
|
|
479
476
|
'X-RestLi-Protocol-Version': LINKEDIN_API_VERSION,
|
|
480
477
|
'LinkedIn-Version': LINKEDIN_VERSION
|
|
@@ -10,7 +10,7 @@ export async function like(token, externalId, socialAccountId, logger) {
|
|
|
10
10
|
actor: socialAccountId,
|
|
11
11
|
object: externalId
|
|
12
12
|
};
|
|
13
|
-
let query = `${
|
|
13
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(externalId)}/likes`;
|
|
14
14
|
try {
|
|
15
15
|
loggerDebug(logger, `Linkedin trying to Like `, {
|
|
16
16
|
query,
|
|
@@ -37,7 +37,7 @@ export async function unlike(token, externalId, socialAccountId, logger) {
|
|
|
37
37
|
actor: socialAccountId,
|
|
38
38
|
object: externalId
|
|
39
39
|
};
|
|
40
|
-
let query = `${
|
|
40
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(externalId)}/likes/${fixedEncodeURIComponent(payload.actor)}?actor=${fixedEncodeURIComponent(payload.actor)}`;
|
|
41
41
|
try {
|
|
42
42
|
loggerDebug(logger, `Linkedin trying Delete Previous Like `, {
|
|
43
43
|
query,
|
|
@@ -61,7 +61,7 @@ export async function deleteMessage(token, externalId, sourceId, inReplyToId, lo
|
|
|
61
61
|
const [, comment] = externalId.split(',');
|
|
62
62
|
const commentId = comment.split(')')[0];
|
|
63
63
|
let response;
|
|
64
|
-
const query = `${
|
|
64
|
+
const query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(inReplyToId)}/comments/${commentId}?actor=${fixedEncodeURIComponent(sourceId)}`;
|
|
65
65
|
try {
|
|
66
66
|
loggerDebug(logger, `Linkedin trying Delete `, {
|
|
67
67
|
query
|
|
@@ -128,11 +128,6 @@ export async function privateMessage(token, messageText, inReplyToId, sourceId,
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
async function publish(token, discussionType, mediaId, inReplyToId, socialAccountId, messageText, logger) {
|
|
131
|
-
// for now this is needed to make the urns from the images api work until the docs are updated to reflect how to use these new ids.
|
|
132
|
-
if (mediaId) {
|
|
133
|
-
mediaId = mediaId.replace('urn:li:image:', 'urn:li:digitalmediaAsset:');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
131
|
// Extract mentions from the messageText
|
|
137
132
|
// https://learn.microsoft.com/en-us/linkedin/compliance/integrations/shares/ugc-post-api?tabs=http#memberattributedentity
|
|
138
133
|
const mentionRegex = /<span class="highlight-mention" data-mention-id="([^"]+)"[^>]*>([^<]+)<\/span>/g;
|
|
@@ -160,6 +155,8 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
160
155
|
}
|
|
161
156
|
let body = {
|
|
162
157
|
actor: socialAccountId,
|
|
158
|
+
object: inReplyToId,
|
|
159
|
+
// Required field for REST API
|
|
163
160
|
message: {
|
|
164
161
|
attributes: attributes,
|
|
165
162
|
text: textWithoutMentions || '' // Replace mention spans with the mention text
|
|
@@ -169,14 +166,14 @@ async function publish(token, discussionType, mediaId, inReplyToId, socialAccoun
|
|
|
169
166
|
body.parentComment = inReplyToId;
|
|
170
167
|
}
|
|
171
168
|
if (mediaId) {
|
|
169
|
+
const imageUrn = mediaId.replace('urn:li:digitalmediaAsset:', 'urn:li:image:');
|
|
172
170
|
body.content = [{
|
|
173
171
|
entity: {
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
type: 'IMAGE'
|
|
172
|
+
image: imageUrn
|
|
173
|
+
}
|
|
177
174
|
}];
|
|
178
175
|
}
|
|
179
|
-
let query = `${
|
|
176
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(inReplyToId)}/comments`;
|
|
180
177
|
|
|
181
178
|
// data-listener -> linkedin_api.client sendComment
|
|
182
179
|
let response;
|
|
@@ -452,7 +449,7 @@ export async function getSocialStats(externalId, token, logger) {
|
|
|
452
449
|
export async function likedByUser(token, externalId, authorExternalId, logger) {
|
|
453
450
|
let result;
|
|
454
451
|
try {
|
|
455
|
-
result = await superagent.get(`${
|
|
452
|
+
result = await superagent.get(`${LINKEDIN_API_REST}/reactions/(actor:${fixedEncodeURIComponent(authorExternalId)},entity:${fixedEncodeURIComponent(externalId)})`).set({
|
|
456
453
|
Authorization: `Bearer ${token}`,
|
|
457
454
|
'X-RestLi-Protocol-Version': LINKEDIN_API_VERSION,
|
|
458
455
|
'LinkedIn-Version': LINKEDIN_VERSION
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meltwater/conversations-api-services",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
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",
|
|
@@ -10,7 +10,7 @@ const LINKEDIN_VERSION = "202411";
|
|
|
10
10
|
export async function like(token, externalId, socialAccountId, logger) {
|
|
11
11
|
let response;
|
|
12
12
|
let payload = { actor: socialAccountId, object: externalId };
|
|
13
|
-
let query = `${
|
|
13
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(externalId)}/likes`
|
|
14
14
|
|
|
15
15
|
try {
|
|
16
16
|
loggerDebug(logger,`Linkedin trying to Like `, {
|
|
@@ -42,7 +42,7 @@ export async function like(token, externalId, socialAccountId, logger) {
|
|
|
42
42
|
export async function unlike(token, externalId, socialAccountId, logger) {
|
|
43
43
|
let response;
|
|
44
44
|
let payload = { actor: socialAccountId, object: externalId };
|
|
45
|
-
let query = `${
|
|
45
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(
|
|
46
46
|
externalId
|
|
47
47
|
)}/likes/${fixedEncodeURIComponent(
|
|
48
48
|
payload.actor
|
|
@@ -78,7 +78,7 @@ export async function deleteMessage(token, externalId, sourceId, inReplyToId, lo
|
|
|
78
78
|
const commentId = comment.split(')')[0];
|
|
79
79
|
|
|
80
80
|
let response;
|
|
81
|
-
const query = `${
|
|
81
|
+
const query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(
|
|
82
82
|
inReplyToId
|
|
83
83
|
)}/comments/${commentId}?actor=${fixedEncodeURIComponent(sourceId)}`;
|
|
84
84
|
|
|
@@ -172,14 +172,6 @@ export async function privateMessage(token, messageText, inReplyToId, sourceId,
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
async function publish(token,discussionType, mediaId,inReplyToId,socialAccountId, messageText, logger) {
|
|
175
|
-
// for now this is needed to make the urns from the images api work until the docs are updated to reflect how to use these new ids.
|
|
176
|
-
if (mediaId) {
|
|
177
|
-
mediaId = mediaId.replace(
|
|
178
|
-
'urn:li:image:',
|
|
179
|
-
'urn:li:digitalmediaAsset:'
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
175
|
// Extract mentions from the messageText
|
|
184
176
|
// https://learn.microsoft.com/en-us/linkedin/compliance/integrations/shares/ugc-post-api?tabs=http#memberattributedentity
|
|
185
177
|
const mentionRegex = /<span class="highlight-mention" data-mention-id="([^"]+)"[^>]*>([^<]+)<\/span>/g;
|
|
@@ -207,6 +199,7 @@ async function publish(token,discussionType, mediaId,inReplyToId,socialAccountId
|
|
|
207
199
|
|
|
208
200
|
let body = {
|
|
209
201
|
actor: socialAccountId,
|
|
202
|
+
object: inReplyToId, // Required field for REST API
|
|
210
203
|
message: {
|
|
211
204
|
attributes: attributes,
|
|
212
205
|
text: textWithoutMentions || '' // Replace mention spans with the mention text
|
|
@@ -215,18 +208,19 @@ async function publish(token,discussionType, mediaId,inReplyToId,socialAccountId
|
|
|
215
208
|
if (discussionType === 're') {
|
|
216
209
|
body.parentComment = inReplyToId;
|
|
217
210
|
}
|
|
211
|
+
|
|
218
212
|
if (mediaId) {
|
|
213
|
+
const imageUrn = mediaId.replace('urn:li:digitalmediaAsset:', 'urn:li:image:');
|
|
219
214
|
body.content = [
|
|
220
215
|
{
|
|
221
216
|
entity: {
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
},
|
|
217
|
+
image: imageUrn
|
|
218
|
+
}
|
|
219
|
+
}
|
|
226
220
|
];
|
|
227
221
|
}
|
|
228
222
|
|
|
229
|
-
let query = `${
|
|
223
|
+
let query = `${LINKEDIN_API_REST}/socialActions/${fixedEncodeURIComponent(inReplyToId)}/comments`;
|
|
230
224
|
|
|
231
225
|
// data-listener -> linkedin_api.client sendComment
|
|
232
226
|
let response;
|
|
@@ -619,7 +613,7 @@ export async function likedByUser(
|
|
|
619
613
|
try {
|
|
620
614
|
result = await superagent
|
|
621
615
|
.get(
|
|
622
|
-
`${
|
|
616
|
+
`${LINKEDIN_API_REST}/reactions/(actor:${fixedEncodeURIComponent(
|
|
623
617
|
authorExternalId
|
|
624
618
|
)},entity:${fixedEncodeURIComponent(externalId)})`
|
|
625
619
|
)
|