mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix: add retry logic with exponential backoff to Slack API requests
This commit is contained in:
@@ -60,6 +60,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for getting user info:");
|
||||
@@ -122,6 +126,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/json",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
if (result instanceof HTTPErrorResponse) {
|
||||
@@ -202,6 +210,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for archiving channel:");
|
||||
@@ -245,6 +257,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for joining channel:");
|
||||
@@ -301,6 +317,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for inviting user:");
|
||||
@@ -449,6 +469,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for getting channel info:");
|
||||
@@ -519,6 +543,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for getting all channels:");
|
||||
@@ -779,6 +807,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/json",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for sending message:");
|
||||
@@ -853,6 +885,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for creating channel:");
|
||||
@@ -1233,6 +1269,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
if (response instanceof HTTPErrorResponse) {
|
||||
@@ -1297,6 +1337,10 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
Authorization: `Bearer ${data.authToken}`,
|
||||
["Content-Type"]: "application/x-www-form-urlencoded",
|
||||
},
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for getting channel members:");
|
||||
@@ -1373,17 +1417,25 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
logger.debug(data);
|
||||
|
||||
const apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null =
|
||||
await API.post(data.url, {
|
||||
blocks: [
|
||||
{
|
||||
type: "section",
|
||||
text: {
|
||||
type: "mrkdwn",
|
||||
text: `${data.text}`,
|
||||
await API.post(
|
||||
data.url,
|
||||
{
|
||||
blocks: [
|
||||
{
|
||||
type: "section",
|
||||
text: {
|
||||
type: "mrkdwn",
|
||||
text: `${data.text}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
],
|
||||
},
|
||||
undefined,
|
||||
{
|
||||
retries: 3,
|
||||
exponentialBackoff: true,
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Response from Slack API for sending message via webhook:");
|
||||
logger.debug(apiResult);
|
||||
|
||||
Reference in New Issue
Block a user