@meltwater/conversations-api-services 1.1.6 → 1.1.7

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.
@@ -249,7 +249,7 @@ async function constructReplyQuery(accessToken, inReplyToId, text, asset, logger
249
249
  const baseQuery = {
250
250
  access_token: accessToken,
251
251
  text,
252
- [isQuote ? 'quote_post_id' : 'in_reply_to_id']: inReplyToId
252
+ [isQuote ? 'quote_post_id' : 'reply_to_id']: inReplyToId
253
253
  };
254
254
  const mediaQuery = getMediaQuery(asset);
255
255
  const query = {
@@ -261,7 +261,7 @@ async function constructReplyQuery(accessToken, inReplyToId, text, asset, logger
261
261
  await confirmCreationId(accessToken, containerResponse.body.id, logger);
262
262
  return {
263
263
  ...query,
264
- containerResponse
264
+ creation_id: containerResponse.body.id
265
265
  };
266
266
  } catch (error) {
267
267
  (0, _loggerHelpers.loggerError)(logger, 'Error constructing reply query', error);
@@ -237,7 +237,7 @@ async function constructReplyQuery(accessToken, inReplyToId, text, asset, logger
237
237
  const baseQuery = {
238
238
  access_token: accessToken,
239
239
  text,
240
- [isQuote ? 'quote_post_id' : 'in_reply_to_id']: inReplyToId
240
+ [isQuote ? 'quote_post_id' : 'reply_to_id']: inReplyToId
241
241
  };
242
242
  const mediaQuery = getMediaQuery(asset);
243
243
  const query = {
@@ -249,7 +249,7 @@ async function constructReplyQuery(accessToken, inReplyToId, text, asset, logger
249
249
  await confirmCreationId(accessToken, containerResponse.body.id, logger);
250
250
  return {
251
251
  ...query,
252
- containerResponse
252
+ creation_id: containerResponse.body.id
253
253
  };
254
254
  } catch (error) {
255
255
  loggerError(logger, 'Error constructing reply query', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
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",
@@ -22,7 +22,12 @@ const LONG_WAIT_TIME_MS = 60000; // 60 seconds
22
22
  * @returns {Promise<any>} The result of the operation.
23
23
  * @throws {Error} If the operation fails after all retries.
24
24
  */
25
- async function retryWithBackoff(operation, maxRetries, initialWaitTime, logger) {
25
+ async function retryWithBackoff(
26
+ operation,
27
+ maxRetries,
28
+ initialWaitTime,
29
+ logger
30
+ ) {
26
31
  let waitTime = initialWaitTime;
27
32
 
28
33
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
@@ -35,7 +40,9 @@ async function retryWithBackoff(operation, maxRetries, initialWaitTime, logger)
35
40
 
36
41
  loggerInfo(
37
42
  logger,
38
- `Retry attempt ${attempt + 1} failed. Retrying in ${waitTime / 1000} seconds...`
43
+ `Retry attempt ${attempt + 1} failed. Retrying in ${
44
+ waitTime / 1000
45
+ } seconds...`
39
46
  );
40
47
  await new Promise((resolve) => setTimeout(resolve, waitTime));
41
48
  waitTime *= 2; // Exponential backoff
@@ -72,9 +79,18 @@ async function confirmCreationId(accessToken, creationId, logger) {
72
79
  };
73
80
 
74
81
  try {
75
- return await retryWithBackoff(operation, MAX_RETRY_COUNT, SHORT_WAIT_TIME_MS, logger);
82
+ return await retryWithBackoff(
83
+ operation,
84
+ MAX_RETRY_COUNT,
85
+ SHORT_WAIT_TIME_MS,
86
+ logger
87
+ );
76
88
  } catch (error) {
77
- loggerError(logger, `Creation ID ${creationId} confirmation failed: ${error.message}`, error);
89
+ loggerError(
90
+ logger,
91
+ `Creation ID ${creationId} confirmation failed: ${error.message}`,
92
+ error
93
+ );
78
94
  error.code = 408; // Request Timeout
79
95
  throw error;
80
96
  }
@@ -299,7 +315,7 @@ async function constructReplyQuery(
299
315
  const baseQuery = {
300
316
  access_token: accessToken,
301
317
  text,
302
- [isQuote ? 'quote_post_id' : 'in_reply_to_id']: inReplyToId,
318
+ [isQuote ? 'quote_post_id' : 'reply_to_id']: inReplyToId,
303
319
  };
304
320
 
305
321
  const mediaQuery = getMediaQuery(asset);
@@ -315,7 +331,7 @@ async function constructReplyQuery(
315
331
 
316
332
  await confirmCreationId(accessToken, containerResponse.body.id, logger);
317
333
 
318
- return { ...query, containerResponse };
334
+ return { ...query, creation_id: containerResponse.body.id };
319
335
  } catch (error) {
320
336
  loggerError(logger, 'Error constructing reply query', error);
321
337
  throw error;