diff --git a/Common/Server/API/SlackAPI.ts b/Common/Server/API/SlackAPI.ts index 00cf888db2..cb36c89e80 100644 --- a/Common/Server/API/SlackAPI.ts +++ b/Common/Server/API/SlackAPI.ts @@ -256,6 +256,9 @@ export default class SlackAPI { "/slack/interactive", SlackAuthorization.isAuthorizedSlackRequest, async (req: ExpressRequest, res: ExpressResponse) => { + logger.debug("Slack Interactive Request: "); + logger.debug(JSON.stringify(JSON.parse(req.body.payload), null, 2)); + const authResult: SlackRequest = await SlackAuthAction.isAuthorized({ req: req, }); diff --git a/Common/Server/Services/IncidentService.ts b/Common/Server/Services/IncidentService.ts index f3330cdfc3..d47fa4eeb2 100644 --- a/Common/Server/Services/IncidentService.ts +++ b/Common/Server/Services/IncidentService.ts @@ -342,16 +342,16 @@ export class Service extends DatabaseService { logger.debug( "Mutex acquired - IncidentService.incident-create " + - projectId.toString() + - " at " + - OneUptimeDate.getCurrentDateAsFormattedString(), + projectId.toString() + + " at " + + OneUptimeDate.getCurrentDateAsFormattedString(), ); } catch (err) { logger.debug( "Mutex acquire failed - IncidentService.incident-create " + - projectId.toString() + - " at " + - OneUptimeDate.getCurrentDateAsFormattedString(), + projectId.toString() + + " at " + + OneUptimeDate.getCurrentDateAsFormattedString(), ); logger.error(err); } @@ -429,16 +429,16 @@ export class Service extends DatabaseService { await Semaphore.release(mutex); logger.debug( "Mutex released - IncidentService.incident-create " + - projectId.toString() + - " at " + - OneUptimeDate.getCurrentDateAsFormattedString(), + projectId.toString() + + " at " + + OneUptimeDate.getCurrentDateAsFormattedString(), ); } catch (err) { logger.debug( "Mutex release failed - IncidentService.incident-create " + - projectId.toString() + - " at " + - OneUptimeDate.getCurrentDateAsFormattedString(), + projectId.toString() + + " at " + + OneUptimeDate.getCurrentDateAsFormattedString(), ); logger.error(err); } @@ -447,7 +447,6 @@ export class Service extends DatabaseService { const createdByUserId: ObjectID | undefined | null = createdItem.createdByUserId || createdItem.createdByUser?.id; - // send message to workspaces - slack, teams, etc. const workspaceResult: { channelsCreated: Array; @@ -534,9 +533,9 @@ ${createdItem.remediationNotes || "No remediation notes provided."} createdItem.changeMonitorStatusToId, true, // notifyMonitorOwners createdItem.rootCause || - "Status was changed because incident " + - createdItem.id.toString() + - " was created.", + "Status was changed because incident " + + createdItem.id.toString() + + " was created.", createdItem.createdStateLog, onCreate.createBy.props, ); @@ -560,8 +559,6 @@ ${createdItem.remediationNotes || "No remediation notes provided."} }, }); - - // add owners. if ( @@ -573,9 +570,9 @@ ${createdItem.remediationNotes || "No remediation notes provided."} createdItem.projectId, createdItem.id, (onCreate.createBy.miscDataProps["ownerUsers"] as Array) || - [], + [], (onCreate.createBy.miscDataProps["ownerTeams"] as Array) || - [], + [], false, onCreate.createBy.props, ); @@ -876,10 +873,10 @@ ${onUpdate.updateBy.data.remediationNotes || "No remediation notes provided."} feedInfoInMarkdown += `\n\n**Labels**: ${labels - .map((label: Label) => { - return `- ${label.name}`; - }) - .join("\n")} + .map((label: Label) => { + return `- ${label.name}`; + }) + .join("\n")} `; shouldAddIncidentFeed = true; @@ -1037,7 +1034,7 @@ ${incidentSeverity.name} if ( latestState && latestState.monitorStatusId?.toString() === - resolvedMonitorState.id!.toString() + resolvedMonitorState.id!.toString() ) { // already on this state. Skip. continue; @@ -1150,7 +1147,7 @@ ${incidentSeverity.name} lastIncidentStatusTimeline && lastIncidentStatusTimeline.incidentStateId && lastIncidentStatusTimeline.incidentStateId.toString() === - incidentStateId.toString() + incidentStateId.toString() ) { return; } @@ -1368,7 +1365,7 @@ ${incidentSeverity.name} timeToResolveMetric.description = "Time taken to resolve the incident"; timeToResolveMetric.value = OneUptimeDate.getDifferenceInSeconds( resolvedIncidentStateTimeline?.startsAt || - OneUptimeDate.getCurrentDate(), + OneUptimeDate.getCurrentDate(), incidentStartsAt, ); timeToResolveMetric.unit = "seconds"; diff --git a/Common/Server/Utils/Workspace/Slack/Actions/Auth.ts b/Common/Server/Utils/Workspace/Slack/Actions/Auth.ts index 40a3f45dd9..bdd46ff78f 100644 --- a/Common/Server/Utils/Workspace/Slack/Actions/Auth.ts +++ b/Common/Server/Utils/Workspace/Slack/Actions/Auth.ts @@ -62,6 +62,7 @@ export default class SlackAuthAction { // if there are no actions then return. if (!payload["actions"] || (payload["actions"] as JSONArray).length === 0) { + logger.debug("No actions found in payload. Returning unauthorized."); return { isAuthorized: false, }; @@ -117,6 +118,9 @@ export default class SlackAuthAction { const projectId: ObjectID | undefined = projectAuth.projectId; if (!projectId) { + logger.debug( + "Project ID not found in project auth. Returning unauthorized.", + ); return { isAuthorized: false, }; @@ -162,6 +166,7 @@ export default class SlackAuthAction { }); // clear response. + logger.debug("User auth not found. Returning unauthorized."); return { isAuthorized: false, };