@meltwater/conversations-api-services 1.0.2 → 1.0.4

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.2",
3
+ "version": "1.0.4",
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",
@@ -394,7 +394,7 @@ export class FacebookApiClient {
394
394
  const {
395
395
  documentId,
396
396
  appData: { hidden: hiddenOnNative },
397
- metaData: { externalId: externalId },
397
+ metaData: { externalId },
398
398
  systemData: {
399
399
  connectionsCredential: credentialId,
400
400
  policies: { storage: { privateTo: companyId } = {} } = {},
@@ -1,5 +1,5 @@
1
- import superagentfrom from 'superagent';
2
- import configurationfrom from '../../lib/configuration.js';
1
+ import superagent from 'superagent';
2
+ import configuration from '../../lib/configuration.js';
3
3
  // import { DOCUMENT_STATUS } from '@data-access/mongo/query.helpers.js';
4
4
  // import { messagesRepository } from '@data-access/mongo/repository/messages.js';
5
5
  // import PushRepositoryfrom from '@data-access/redis/repository/push.repository.js';
@@ -82,7 +82,12 @@ export class LinkedInApiClient {
82
82
 
83
83
  this.logger.info(
84
84
  `Native Linkedin API Like Comment Response for documentId ${documentId}`,
85
- { response, likedByUser }
85
+ {
86
+ ok: response.ok,
87
+ status: response.status,
88
+ message: JSON.parse(response.text),
89
+ likedByUser,
90
+ }
86
91
  );
87
92
  } catch (err) {
88
93
  this.logger.error(documentId + ' - exception details', {
@@ -104,21 +109,27 @@ export class LinkedInApiClient {
104
109
  },
105
110
  metaData: {
106
111
  externalId,
107
- inReplyTo: { id: inReplyToId},
112
+ source: { id: actorURN },
113
+ inReplyTo: { id: inReplyToId },
108
114
  },
109
115
  } = document;
110
116
 
117
+ const [, comment] = externalId.split(',');
118
+ const commentId = comment.split(')')[0];
119
+
111
120
  let response;
112
121
  let query = `${configuration.get(
113
- 'LINKEDIN_API'
114
- )}/socialActions/${fixedEncodeURIComponent(inReplyToId)}/comments/${fixedEncodeURIComponent(externalId)}`;
122
+ 'LINKEDIN_API'
123
+ )}/socialActions/${fixedEncodeURIComponent(
124
+ inReplyToId
125
+ )}/comments/${commentId}?actor=${fixedEncodeURIComponent(actorURN)}`;
115
126
 
116
127
  try {
117
128
  let credential = await this.tokenService.getByCredentialId(
118
129
  credentialId,
119
130
  companyId
120
131
  );
121
-
132
+
122
133
  this.logger.debug(`${documentId} - trying Delete `, {
123
134
  query,
124
135
  });
@@ -130,17 +141,25 @@ export class LinkedInApiClient {
130
141
  'X-RestLi-Protocol-Version': configuration.get(
131
142
  'LINKEDIN_API_VERSION'
132
143
  ),
133
- 'LinkedIn-Version': '202401',
144
+ 'LinkedIn-Version': '202305',
134
145
  });
135
146
 
136
147
  this.logger.info(
137
148
  `Native Linkedin API Delete Comment Response for documentId ${documentId}`,
138
- { response }
149
+ { status: response.status, ok: response.ok }
139
150
  );
140
151
  } catch (err) {
141
- this.logger.error(documentId + ' - exception details', {
142
- err,
143
- });
152
+ if (err && err.response && err.response.text) {
153
+ this.logger.error(
154
+ `Call to linkedin api with documentId ${documentId} failed`,
155
+ { message: JSON.parse(err.response.text) }
156
+ );
157
+ } else {
158
+ this.logger.error(
159
+ `Call to linkedin api with documentId ${documentId} failed`,
160
+ err
161
+ );
162
+ }
144
163
  throw err;
145
164
  }
146
165
  return response;