mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
Refactor code for consistency and readability
- Updated array and object property access from single quotes to double quotes in Pagination.ts and Permissions.ts for consistency. - Added missing commas in function parameters and object literals across multiple files in AlertService.ts, IncidentService.ts, MonitorService.ts, ScheduledMaintenanceService.ts, and WorkspaceNotificationRuleService.ts. - Improved error logging messages in various services for better clarity. - Removed unnecessary line breaks in Slack.ts and Workspace.ts for cleaner code. - Ensured consistent formatting in Routes.ts by adding missing commas and adjusting line breaks.
This commit is contained in:
@@ -15,7 +15,7 @@ export default class ServiceHandler {
|
||||
): Promise<void> {
|
||||
const pageData: Dictionary<unknown> = {};
|
||||
|
||||
pageData['selectCode'] = await LocalCache.getOrSetString(
|
||||
pageData["selectCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"select",
|
||||
async () => {
|
||||
@@ -23,7 +23,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['sortCode'] = await LocalCache.getOrSetString(
|
||||
pageData["sortCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"sort",
|
||||
async () => {
|
||||
@@ -31,7 +31,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['equalToCode'] = await LocalCache.getOrSetString(
|
||||
pageData["equalToCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"equal-to",
|
||||
async () => {
|
||||
@@ -39,7 +39,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['equalToOrNullCode'] = await LocalCache.getOrSetString(
|
||||
pageData["equalToOrNullCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"equal-to-or-null",
|
||||
async () => {
|
||||
@@ -49,7 +49,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['greaterThanCode'] = await LocalCache.getOrSetString(
|
||||
pageData["greaterThanCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"greater-than",
|
||||
async () => {
|
||||
@@ -59,7 +59,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['greaterThanOrEqualCode'] = await LocalCache.getOrSetString(
|
||||
pageData["greaterThanOrEqualCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"greater-than-or-equal",
|
||||
async () => {
|
||||
@@ -69,7 +69,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['lessThanCode'] = await LocalCache.getOrSetString(
|
||||
pageData["lessThanCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"less-than",
|
||||
async () => {
|
||||
@@ -79,7 +79,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['lessThanOrEqualCode'] = await LocalCache.getOrSetString(
|
||||
pageData["lessThanOrEqualCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"less-than-or-equal",
|
||||
async () => {
|
||||
@@ -89,7 +89,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['includesCode'] = await LocalCache.getOrSetString(
|
||||
pageData["includesCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"includes",
|
||||
async () => {
|
||||
@@ -99,7 +99,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['lessThanOrNullCode'] = await LocalCache.getOrSetString(
|
||||
pageData["lessThanOrNullCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"less-than-or-equal",
|
||||
async () => {
|
||||
@@ -109,7 +109,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['greaterThanOrNullCode'] = await LocalCache.getOrSetString(
|
||||
pageData["greaterThanOrNullCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"less-than-or-equal",
|
||||
async () => {
|
||||
@@ -119,7 +119,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['isNullCode'] = await LocalCache.getOrSetString(
|
||||
pageData["isNullCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"is-null",
|
||||
async () => {
|
||||
@@ -127,7 +127,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['notNullCode'] = await LocalCache.getOrSetString(
|
||||
pageData["notNullCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"not-null",
|
||||
async () => {
|
||||
@@ -135,7 +135,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['notEqualToCode'] = await LocalCache.getOrSetString(
|
||||
pageData["notEqualToCode"] = await LocalCache.getOrSetString(
|
||||
"data-type",
|
||||
"not-equals",
|
||||
async () => {
|
||||
|
||||
@@ -24,7 +24,7 @@ export default class ServiceHandler {
|
||||
const pageData: Dictionary<unknown> = {};
|
||||
|
||||
// Set featured resources for the page
|
||||
pageData['featuredResources'] = FeaturedResources;
|
||||
pageData["featuredResources"] = FeaturedResources;
|
||||
|
||||
// Set page title and description
|
||||
pageTitle = "Introduction";
|
||||
|
||||
@@ -99,11 +99,11 @@ export default class ServiceHandler {
|
||||
delete tableColumns["version"];
|
||||
|
||||
// Set page data
|
||||
pageData['title'] = currentResource.model.singularName;
|
||||
pageData['description'] = currentResource.model.tableDescription;
|
||||
pageData['columns'] = tableColumns;
|
||||
pageData["title"] = currentResource.model.singularName;
|
||||
pageData["description"] = currentResource.model.tableDescription;
|
||||
pageData["columns"] = tableColumns;
|
||||
|
||||
pageData['tablePermissions'] = {
|
||||
pageData["tablePermissions"] = {
|
||||
read: currentResource.model.readRecordPermissions.map(
|
||||
(permission: Permission) => {
|
||||
return PermissionDictionary[permission];
|
||||
@@ -127,7 +127,7 @@ export default class ServiceHandler {
|
||||
};
|
||||
|
||||
// Cache the list request data
|
||||
pageData['listRequest'] = await LocalCache.getOrSetString(
|
||||
pageData["listRequest"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"list-request",
|
||||
async () => {
|
||||
@@ -137,7 +137,7 @@ export default class ServiceHandler {
|
||||
);
|
||||
|
||||
// Cache the item request data
|
||||
pageData['itemRequest'] = await LocalCache.getOrSetString(
|
||||
pageData["itemRequest"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"item-request",
|
||||
async () => {
|
||||
@@ -147,7 +147,7 @@ export default class ServiceHandler {
|
||||
);
|
||||
|
||||
// Cache the item response data
|
||||
pageData['itemResponse'] = await LocalCache.getOrSetString(
|
||||
pageData["itemResponse"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"item-response",
|
||||
async () => {
|
||||
@@ -159,7 +159,7 @@ export default class ServiceHandler {
|
||||
);
|
||||
|
||||
// Cache the count request data
|
||||
pageData['countRequest'] = await LocalCache.getOrSetString(
|
||||
pageData["countRequest"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"count-request",
|
||||
async () => {
|
||||
@@ -171,7 +171,7 @@ export default class ServiceHandler {
|
||||
);
|
||||
|
||||
// Cache the count response data
|
||||
pageData['countResponse'] = await LocalCache.getOrSetString(
|
||||
pageData["countResponse"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"count-response",
|
||||
async () => {
|
||||
@@ -182,7 +182,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['updateRequest'] = await LocalCache.getOrSetString(
|
||||
pageData["updateRequest"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"update-request",
|
||||
async () => {
|
||||
@@ -193,7 +193,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['updateResponse'] = await LocalCache.getOrSetString(
|
||||
pageData["updateResponse"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"update-response",
|
||||
async () => {
|
||||
@@ -204,7 +204,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['createRequest'] = await LocalCache.getOrSetString(
|
||||
pageData["createRequest"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"create-request",
|
||||
async () => {
|
||||
@@ -215,7 +215,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['createResponse'] = await LocalCache.getOrSetString(
|
||||
pageData["createResponse"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"create-response",
|
||||
async () => {
|
||||
@@ -226,7 +226,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['deleteRequest'] = await LocalCache.getOrSetString(
|
||||
pageData["deleteRequest"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"delete-request",
|
||||
async () => {
|
||||
@@ -237,7 +237,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['deleteResponse'] = await LocalCache.getOrSetString(
|
||||
pageData["deleteResponse"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"delete-response",
|
||||
async () => {
|
||||
@@ -249,7 +249,7 @@ export default class ServiceHandler {
|
||||
);
|
||||
|
||||
// Get list response from cache or set it if it's not available
|
||||
pageData['listResponse'] = await LocalCache.getOrSetString(
|
||||
pageData["listResponse"] = await LocalCache.getOrSetString(
|
||||
"model",
|
||||
"list-response",
|
||||
async () => {
|
||||
@@ -261,14 +261,15 @@ export default class ServiceHandler {
|
||||
);
|
||||
|
||||
// Generate a unique ID for the example object
|
||||
pageData['exampleObjectID'] = ObjectID.generate();
|
||||
pageData["exampleObjectID"] = ObjectID.generate();
|
||||
|
||||
// Construct the API path for the current resource
|
||||
pageData['apiPath'] =
|
||||
pageData["apiPath"] =
|
||||
AppApiRoute.toString() + currentResource.model.crudApiPath?.toString();
|
||||
|
||||
// Check if the current resource is a master admin API
|
||||
pageData['isMasterAdminApiDocs'] = currentResource.model.isMasterAdminApiDocs;
|
||||
pageData["isMasterAdminApiDocs"] =
|
||||
currentResource.model.isMasterAdminApiDocs;
|
||||
|
||||
// Render the index page with the required data
|
||||
return res.render(`${ViewsPath}/pages/index`, {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default class ServiceHandler {
|
||||
pageDescription = "Learn how to paginate requests with OneUptime API";
|
||||
|
||||
// Get response and request code from LocalCache or LocalFile
|
||||
pageData['responseCode'] = await LocalCache.getOrSetString(
|
||||
pageData["responseCode"] = await LocalCache.getOrSetString(
|
||||
"pagination",
|
||||
"response",
|
||||
async () => {
|
||||
@@ -34,7 +34,7 @@ export default class ServiceHandler {
|
||||
},
|
||||
);
|
||||
|
||||
pageData['requestCode'] = await LocalCache.getOrSetString(
|
||||
pageData["requestCode"] = await LocalCache.getOrSetString(
|
||||
"pagination",
|
||||
"request",
|
||||
async () => {
|
||||
|
||||
@@ -25,7 +25,7 @@ export default class ServiceHandler {
|
||||
pageDescription = "Learn how permissions work with OneUptime";
|
||||
|
||||
// Filter permissions to only include those assignable to tenants
|
||||
pageData['permissions'] = PermissionHelper.getAllPermissionProps().filter(
|
||||
pageData["permissions"] = PermissionHelper.getAllPermissionProps().filter(
|
||||
(i: PermissionProps) => {
|
||||
return i.isAssignableToTenant;
|
||||
},
|
||||
|
||||
@@ -139,7 +139,7 @@ export class Service extends DatabaseService<Model> {
|
||||
@CaptureSpan()
|
||||
public async acknowledgeAlert(
|
||||
alertId: ObjectID,
|
||||
acknowledgedByUserId: ObjectID
|
||||
acknowledgedByUserId: ObjectID,
|
||||
): Promise<void> {
|
||||
const alert: Model | null = await this.findOneById({
|
||||
id: alertId,
|
||||
@@ -170,7 +170,7 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
if (!alertState || !alertState.id) {
|
||||
throw new BadDataException(
|
||||
"Acknowledged state not found for this project. Please add acknowledged state from settings."
|
||||
"Acknowledged state not found for this project. Please add acknowledged state from settings.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
@CaptureSpan()
|
||||
protected override async onBeforeCreate(
|
||||
createBy: CreateBy<Model>
|
||||
createBy: CreateBy<Model>,
|
||||
): Promise<OnCreate<Model>> {
|
||||
if (!createBy.props.tenantId && !createBy.props.isRoot) {
|
||||
throw new BadDataException("ProjectId required to create alert.");
|
||||
@@ -214,7 +214,7 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
if (!alertState || !alertState.id) {
|
||||
throw new BadDataException(
|
||||
"Created alert state not found for this project. Please add created alert state from settings."
|
||||
"Created alert state not found for this project. Please add created alert state from settings.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ export class Service extends DatabaseService<Model> {
|
||||
{
|
||||
userId: userId!,
|
||||
projectId: projectId,
|
||||
}
|
||||
},
|
||||
)}`;
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ export class Service extends DatabaseService<Model> {
|
||||
@CaptureSpan()
|
||||
protected override async onCreateSuccess(
|
||||
onCreate: OnCreate<Model>,
|
||||
createdItem: Model
|
||||
createdItem: Model,
|
||||
): Promise<Model> {
|
||||
if (!createdItem.projectId) {
|
||||
throw new BadDataException("projectId is required");
|
||||
@@ -283,7 +283,7 @@ export class Service extends DatabaseService<Model> {
|
||||
return await this.handleAlertWorkspaceOperationsAsync(createdItem);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Workspace operations failed in AlertService.onCreateSuccess: ${error}`
|
||||
`Workspace operations failed in AlertService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
@@ -295,7 +295,7 @@ export class Service extends DatabaseService<Model> {
|
||||
return await this.createAlertFeedAsync(createdItem.id!);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Create alert feed failed in AlertService.onCreateSuccess: ${error}`
|
||||
`Create alert feed failed in AlertService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve(); // Continue chain even on error
|
||||
}
|
||||
@@ -305,7 +305,7 @@ export class Service extends DatabaseService<Model> {
|
||||
return await this.handleAlertStateChangeAsync(createdItem);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Handle alert state change failed in AlertService.onCreateSuccess: ${error}`
|
||||
`Handle alert state change failed in AlertService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve(); // Continue chain even on error
|
||||
}
|
||||
@@ -327,14 +327,13 @@ export class Service extends DatabaseService<Model> {
|
||||
"ownerTeams"
|
||||
] as Array<ObjectID>) || [],
|
||||
false,
|
||||
onCreate.createBy.props
|
||||
onCreate.createBy.props,
|
||||
);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Add owners failed in AlertService.onCreateSuccess: ${error}`
|
||||
`Add owners failed in AlertService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve(); // Continue chain even on error
|
||||
}
|
||||
@@ -348,15 +347,16 @@ export class Service extends DatabaseService<Model> {
|
||||
return await this.executeAlertOnCallDutyPoliciesAsync(createdItem);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`On-call duty policy execution failed in AlertService.onCreateSuccess: ${error}`
|
||||
`On-call duty policy execution failed in AlertService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
}).catch((error: Error) => {
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
logger.error(
|
||||
`Critical error in AlertService sequential operations: ${error}`
|
||||
`Critical error in AlertService sequential operations: ${error}`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -365,12 +365,12 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
@CaptureSpan()
|
||||
private async handleAlertWorkspaceOperationsAsync(
|
||||
createdItem: Model
|
||||
createdItem: Model,
|
||||
): Promise<void> {
|
||||
try {
|
||||
if (!createdItem.projectId || !createdItem.id) {
|
||||
throw new BadDataException(
|
||||
"projectId and id are required for workspace operations"
|
||||
"projectId and id are required for workspace operations",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ ${alert.remediationNotes || "No remediation notes provided."}
|
||||
try {
|
||||
if (!createdItem.projectId || !createdItem.id) {
|
||||
throw new BadDataException(
|
||||
"projectId and id are required for state change"
|
||||
"projectId and id are required for state change",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ ${alert.remediationNotes || "No remediation notes provided."}
|
||||
|
||||
@CaptureSpan()
|
||||
private async executeAlertOnCallDutyPoliciesAsync(
|
||||
createdItem: Model
|
||||
createdItem: Model,
|
||||
): Promise<void> {
|
||||
try {
|
||||
if (
|
||||
@@ -563,7 +563,7 @@ ${alert.remediationNotes || "No remediation notes provided."}
|
||||
triggeredByAlertId: createdItem.id!,
|
||||
userNotificationEventType:
|
||||
UserNotificationEventType.AlertCreated,
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -601,7 +601,7 @@ ${alert.remediationNotes || "No remediation notes provided."}
|
||||
}
|
||||
|
||||
return channel.workspaceType === data.workspaceType;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -692,7 +692,7 @@ ${alert.remediationNotes || "No remediation notes provided."}
|
||||
const isUserAlreadyAdded: User | undefined = users.find(
|
||||
(user: User) => {
|
||||
return user.id!.toString() === teamUser.id!.toString();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!isUserAlreadyAdded) {
|
||||
@@ -711,7 +711,7 @@ ${alert.remediationNotes || "No remediation notes provided."}
|
||||
userIds: Array<ObjectID>,
|
||||
teamIds: Array<ObjectID>,
|
||||
notifyOwners: boolean,
|
||||
props: DatabaseCommonInteractionProps
|
||||
props: DatabaseCommonInteractionProps,
|
||||
): Promise<void> {
|
||||
for (let teamId of teamIds) {
|
||||
if (typeof teamId === Typeof.String) {
|
||||
@@ -749,19 +749,19 @@ ${alert.remediationNotes || "No remediation notes provided."}
|
||||
@CaptureSpan()
|
||||
public async getAlertLinkInDashboard(
|
||||
projectId: ObjectID,
|
||||
alertId: ObjectID
|
||||
alertId: ObjectID,
|
||||
): Promise<URL> {
|
||||
const dashboardUrl: URL = await DatabaseConfig.getDashboardUrl();
|
||||
|
||||
return URL.fromString(dashboardUrl.toString()).addRoute(
|
||||
`/${projectId.toString()}/alerts/${alertId.toString()}`
|
||||
`/${projectId.toString()}/alerts/${alertId.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
@CaptureSpan()
|
||||
protected override async onUpdateSuccess(
|
||||
onUpdate: OnUpdate<Model>,
|
||||
updatedItemIds: ObjectID[]
|
||||
updatedItemIds: ObjectID[],
|
||||
): Promise<OnUpdate<Model>> {
|
||||
if (
|
||||
onUpdate.updateBy.data.currentAlertStateId &&
|
||||
@@ -898,7 +898,7 @@ ${labels
|
||||
await AlertSeverityService.findOneBy({
|
||||
query: {
|
||||
_id: new ObjectID(
|
||||
(onUpdate.updateBy.data.alertSeverity as any)?._id.toString()
|
||||
(onUpdate.updateBy.data.alertSeverity as any)?._id.toString(),
|
||||
),
|
||||
},
|
||||
select: {
|
||||
@@ -940,7 +940,7 @@ ${alertSeverity.name}
|
||||
@CaptureSpan()
|
||||
public async doesMonitorHasMoreActiveManualAlerts(
|
||||
monitorId: ObjectID,
|
||||
proojectId: ObjectID
|
||||
proojectId: ObjectID,
|
||||
): Promise<boolean> {
|
||||
const resolvedState: AlertState | null = await AlertStateService.findOneBy({
|
||||
query: {
|
||||
@@ -974,7 +974,7 @@ ${alertSeverity.name}
|
||||
|
||||
@CaptureSpan()
|
||||
protected override async onBeforeDelete(
|
||||
deleteBy: DeleteBy<Model>
|
||||
deleteBy: DeleteBy<Model>,
|
||||
): Promise<OnDelete<Model>> {
|
||||
const alerts: Array<Model> = await this.findBy({
|
||||
query: deleteBy.query,
|
||||
@@ -1161,7 +1161,7 @@ ${alertSeverity.name}
|
||||
|
||||
alertCountMetric.time = alertStartsAt;
|
||||
alertCountMetric.timeUnixNano = OneUptimeDate.toUnixNano(
|
||||
alertCountMetric.time
|
||||
alertCountMetric.time,
|
||||
);
|
||||
alertCountMetric.metricPointType = MetricPointType.Sum;
|
||||
|
||||
@@ -1178,7 +1178,7 @@ ${alertSeverity.name}
|
||||
const isAlertAcknowledged: boolean = alertStateTimelines.some(
|
||||
(timeline: AlertStateTimeline) => {
|
||||
return timeline.alertState?.isAcknowledgedState;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (isAlertAcknowledged) {
|
||||
@@ -1196,7 +1196,7 @@ ${alertSeverity.name}
|
||||
timeToAcknowledgeMetric.name = AlertMetricType.TimeToAcknowledge;
|
||||
timeToAcknowledgeMetric.value = OneUptimeDate.getDifferenceInSeconds(
|
||||
ackAlertStateTimeline?.startsAt || OneUptimeDate.getCurrentDate(),
|
||||
alertStartsAt
|
||||
alertStartsAt,
|
||||
);
|
||||
timeToAcknowledgeMetric.attributes = {
|
||||
alertId: data.alertId.toString(),
|
||||
@@ -1212,7 +1212,7 @@ ${alertSeverity.name}
|
||||
alert.createdAt ||
|
||||
OneUptimeDate.getCurrentDate();
|
||||
timeToAcknowledgeMetric.timeUnixNano = OneUptimeDate.toUnixNano(
|
||||
timeToAcknowledgeMetric.time
|
||||
timeToAcknowledgeMetric.time,
|
||||
);
|
||||
timeToAcknowledgeMetric.metricPointType = MetricPointType.Sum;
|
||||
|
||||
@@ -1230,7 +1230,7 @@ ${alertSeverity.name}
|
||||
const isAlertResolved: boolean = alertStateTimelines.some(
|
||||
(timeline: AlertStateTimeline) => {
|
||||
return timeline.alertState?.isResolvedState;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (isAlertResolved) {
|
||||
@@ -1249,7 +1249,7 @@ ${alertSeverity.name}
|
||||
timeToResolveMetric.value = OneUptimeDate.getDifferenceInSeconds(
|
||||
resolvedAlertStateTimeline?.startsAt ||
|
||||
OneUptimeDate.getCurrentDate(),
|
||||
alertStartsAt
|
||||
alertStartsAt,
|
||||
);
|
||||
timeToResolveMetric.attributes = {
|
||||
alertId: data.alertId.toString(),
|
||||
@@ -1265,7 +1265,7 @@ ${alertSeverity.name}
|
||||
alert.createdAt ||
|
||||
OneUptimeDate.getCurrentDate();
|
||||
timeToResolveMetric.timeUnixNano = OneUptimeDate.toUnixNano(
|
||||
timeToResolveMetric.time
|
||||
timeToResolveMetric.time,
|
||||
);
|
||||
timeToResolveMetric.metricPointType = MetricPointType.Sum;
|
||||
|
||||
@@ -1295,7 +1295,7 @@ ${alertSeverity.name}
|
||||
alertDurationMetric.name = AlertMetricType.AlertDuration;
|
||||
alertDurationMetric.value = OneUptimeDate.getDifferenceInSeconds(
|
||||
alertEndsAt,
|
||||
alertStartsAt
|
||||
alertStartsAt,
|
||||
);
|
||||
alertDurationMetric.attributes = {
|
||||
alertId: data.alertId.toString(),
|
||||
@@ -1311,7 +1311,7 @@ ${alertSeverity.name}
|
||||
alert.createdAt ||
|
||||
OneUptimeDate.getCurrentDate();
|
||||
alertDurationMetric.timeUnixNano = OneUptimeDate.toUnixNano(
|
||||
alertDurationMetric.time
|
||||
alertDurationMetric.time,
|
||||
);
|
||||
alertDurationMetric.metricPointType = MetricPointType.Sum;
|
||||
|
||||
@@ -1415,7 +1415,7 @@ ${alertSeverity.name}
|
||||
@CaptureSpan()
|
||||
public async resolveAlert(
|
||||
alertId: ObjectID,
|
||||
resolvedByUserId: ObjectID
|
||||
resolvedByUserId: ObjectID,
|
||||
): Promise<Model> {
|
||||
const alert: Model | null = await this.findOneById({
|
||||
id: alertId,
|
||||
@@ -1447,7 +1447,7 @@ ${alertSeverity.name}
|
||||
|
||||
if (!alertState || !alertState.id) {
|
||||
throw new BadDataException(
|
||||
"Acknowledged state not found for this project. Please add acknowledged state from settings."
|
||||
"Acknowledged state not found for this project. Please add acknowledged state from settings.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1515,7 +1515,7 @@ ${alertSeverity.name}
|
||||
props: { isRoot: true },
|
||||
});
|
||||
logger.info(
|
||||
`Updated Alert ${alert.id} current state to ${latestTimeline.alertStateId}`
|
||||
`Updated Alert ${alert.id} current state to ${latestTimeline.alertStateId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,22 +631,19 @@ export class Service extends DatabaseService<Model> {
|
||||
let promiseChain: Promise<any> = Promise.resolve();
|
||||
|
||||
// Workspace operations
|
||||
promiseChain = promiseChain
|
||||
.then(async () => {
|
||||
try {
|
||||
if (createdItem.projectId && createdItem.id) {
|
||||
return await this.handleIncidentWorkspaceOperationsAsync(
|
||||
createdItem,
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Workspace operations failed in IncidentService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve();
|
||||
promiseChain = promiseChain.then(async () => {
|
||||
try {
|
||||
if (createdItem.projectId && createdItem.id) {
|
||||
return await this.handleIncidentWorkspaceOperationsAsync(createdItem);
|
||||
}
|
||||
});
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Workspace operations failed in IncidentService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
|
||||
// Create feed item
|
||||
promiseChain = promiseChain.then(async () => {
|
||||
@@ -678,15 +675,17 @@ export class Service extends DatabaseService<Model> {
|
||||
if (
|
||||
onCreate.createBy.miscDataProps &&
|
||||
(onCreate.createBy.miscDataProps["ownerTeams"] ||
|
||||
onCreate.createBy.miscDataProps["ownerUsers"])
|
||||
onCreate.createBy.miscDataProps["ownerUsers"])
|
||||
) {
|
||||
return await this.addOwners(
|
||||
createdItem.projectId!,
|
||||
createdItem.id!,
|
||||
(onCreate.createBy.miscDataProps["ownerUsers"] as Array<ObjectID>) ||
|
||||
[],
|
||||
(onCreate.createBy.miscDataProps["ownerTeams"] as Array<ObjectID>) ||
|
||||
[],
|
||||
(onCreate.createBy.miscDataProps[
|
||||
"ownerUsers"
|
||||
] as Array<ObjectID>) || [],
|
||||
(onCreate.createBy.miscDataProps[
|
||||
"ownerTeams"
|
||||
] as Array<ObjectID>) || [],
|
||||
false,
|
||||
onCreate.createBy.props,
|
||||
);
|
||||
@@ -733,22 +732,23 @@ export class Service extends DatabaseService<Model> {
|
||||
});
|
||||
|
||||
// Execute on-call duty policies
|
||||
promiseChain = promiseChain.then(async () => {
|
||||
try {
|
||||
if (
|
||||
createdItem.onCallDutyPolicies?.length &&
|
||||
createdItem.onCallDutyPolicies?.length > 0
|
||||
) {
|
||||
return await this.executeOnCallDutyPoliciesAsync(createdItem);
|
||||
promiseChain = promiseChain
|
||||
.then(async () => {
|
||||
try {
|
||||
if (
|
||||
createdItem.onCallDutyPolicies?.length &&
|
||||
createdItem.onCallDutyPolicies?.length > 0
|
||||
) {
|
||||
return await this.executeOnCallDutyPoliciesAsync(createdItem);
|
||||
}
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`On-call duty policy execution failed in IncidentService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`On-call duty policy execution failed in IncidentService.onCreateSuccess: ${error}`,
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
logger.error(
|
||||
`Critical error in IncidentService sequential operations: ${error}`,
|
||||
@@ -799,9 +799,7 @@ export class Service extends DatabaseService<Model> {
|
||||
}
|
||||
|
||||
@CaptureSpan()
|
||||
private async createIncidentFeedAsync(
|
||||
incident: Model
|
||||
): Promise<void> {
|
||||
private async createIncidentFeedAsync(incident: Model): Promise<void> {
|
||||
try {
|
||||
const createdByUserId: ObjectID | undefined | null =
|
||||
incident.createdByUserId || incident.createdByUser?.id;
|
||||
|
||||
@@ -518,7 +518,9 @@ ${createdItem.description?.trim() || "No description provided."}
|
||||
createdByUserId,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error("Workspace operations failed in MonitorService.onCreateSuccess");
|
||||
logger.error(
|
||||
"Workspace operations failed in MonitorService.onCreateSuccess",
|
||||
);
|
||||
logger.error(error as Error);
|
||||
return Promise.resolve();
|
||||
}
|
||||
@@ -537,7 +539,9 @@ ${createdItem.description?.trim() || "No description provided."}
|
||||
onCreate.createBy.props,
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error("Change monitor status failed in MonitorService.onCreateSuccess");
|
||||
logger.error(
|
||||
"Change monitor status failed in MonitorService.onCreateSuccess",
|
||||
);
|
||||
logger.error(error as Error);
|
||||
return Promise.resolve();
|
||||
}
|
||||
@@ -557,7 +561,9 @@ ${createdItem.description?.trim() || "No description provided."}
|
||||
}
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
logger.error("Add default probes failed in MonitorService.onCreateSuccess");
|
||||
logger.error(
|
||||
"Add default probes failed in MonitorService.onCreateSuccess",
|
||||
);
|
||||
logger.error(error as Error);
|
||||
return Promise.resolve();
|
||||
}
|
||||
@@ -573,7 +579,9 @@ ${createdItem.description?.trim() || "No description provided."}
|
||||
}
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
logger.error("Billing operations failed in MonitorService.onCreateSuccess");
|
||||
logger.error(
|
||||
"Billing operations failed in MonitorService.onCreateSuccess",
|
||||
);
|
||||
logger.error(error as Error);
|
||||
return Promise.resolve();
|
||||
}
|
||||
@@ -585,15 +593,17 @@ ${createdItem.description?.trim() || "No description provided."}
|
||||
if (
|
||||
onCreate.createBy.miscDataProps &&
|
||||
(onCreate.createBy.miscDataProps["ownerTeams"] ||
|
||||
onCreate.createBy.miscDataProps["ownerUsers"])
|
||||
onCreate.createBy.miscDataProps["ownerUsers"])
|
||||
) {
|
||||
return await this.addOwners(
|
||||
createdItem.projectId!,
|
||||
createdItem.id!,
|
||||
(onCreate.createBy.miscDataProps["ownerUsers"] as Array<ObjectID>) ||
|
||||
[],
|
||||
(onCreate.createBy.miscDataProps["ownerTeams"] as Array<ObjectID>) ||
|
||||
[],
|
||||
(onCreate.createBy.miscDataProps[
|
||||
"ownerUsers"
|
||||
] as Array<ObjectID>) || [],
|
||||
(onCreate.createBy.miscDataProps[
|
||||
"ownerTeams"
|
||||
] as Array<ObjectID>) || [],
|
||||
false,
|
||||
onCreate.createBy.props,
|
||||
);
|
||||
@@ -612,13 +622,17 @@ ${createdItem.description?.trim() || "No description provided."}
|
||||
try {
|
||||
return await this.refreshMonitorProbeStatus(createdItem.id!);
|
||||
} catch (error) {
|
||||
logger.error("Refresh probe status failed in MonitorService.onCreateSuccess");
|
||||
logger.error(
|
||||
"Refresh probe status failed in MonitorService.onCreateSuccess",
|
||||
);
|
||||
logger.error(error as Error);
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
logger.error(`Critical error in MonitorService sequential operations: ${error}`);
|
||||
logger.error(
|
||||
`Critical error in MonitorService sequential operations: ${error}`,
|
||||
);
|
||||
});
|
||||
|
||||
return createdItem;
|
||||
|
||||
@@ -683,15 +683,17 @@ ${resourcesAffected ? `**Resources Affected:** ${resourcesAffected}` : ""}
|
||||
createdItem.id &&
|
||||
onCreate.createBy.miscDataProps &&
|
||||
(onCreate.createBy.miscDataProps["ownerTeams"] ||
|
||||
onCreate.createBy.miscDataProps["ownerUsers"])
|
||||
onCreate.createBy.miscDataProps["ownerUsers"])
|
||||
) {
|
||||
return await this.addOwners(
|
||||
createdItem.projectId!,
|
||||
createdItem.id!,
|
||||
(onCreate.createBy.miscDataProps["ownerUsers"] as Array<ObjectID>) ||
|
||||
[],
|
||||
(onCreate.createBy.miscDataProps["ownerTeams"] as Array<ObjectID>) ||
|
||||
[],
|
||||
(onCreate.createBy.miscDataProps[
|
||||
"ownerUsers"
|
||||
] as Array<ObjectID>) || [],
|
||||
(onCreate.createBy.miscDataProps[
|
||||
"ownerTeams"
|
||||
] as Array<ObjectID>) || [],
|
||||
false,
|
||||
onCreate.createBy.props,
|
||||
);
|
||||
@@ -763,7 +765,8 @@ ${resourcesAffected ? `**Resources Affected:** ${resourcesAffected}` : ""}
|
||||
): Promise<void> {
|
||||
try {
|
||||
const createdByUserId: ObjectID | undefined | null =
|
||||
scheduledMaintenance.createdByUserId || scheduledMaintenance.createdByUser?.id;
|
||||
scheduledMaintenance.createdByUserId ||
|
||||
scheduledMaintenance.createdByUser?.id;
|
||||
|
||||
let feedInfoInMarkdown: string = `#### 🕒 Scheduled Maintenance ${scheduledMaintenance.scheduledMaintenanceNumber?.toString()} Created:
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
throw new BadDataException(
|
||||
"This account is not connected to " +
|
||||
rule.workspaceType +
|
||||
". Please go to User Settings and connect the account."
|
||||
". Please go to User Settings and connect the account.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
throw new BadDataException(
|
||||
"This project is not connected to " +
|
||||
rule.workspaceType +
|
||||
". Please go to Project Settings and connect the account."
|
||||
". Please go to Project Settings and connect the account.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
});
|
||||
} catch (err) {
|
||||
throw new BadDataException(
|
||||
"Cannot create a new channel. " + (err as Error)?.message
|
||||
"Cannot create a new channel. " + (err as Error)?.message,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
});
|
||||
} catch (err) {
|
||||
throw new BadDataException(
|
||||
"Cannot invite users to the channel. " + (err as Error)?.message
|
||||
"Cannot invite users to the channel. " + (err as Error)?.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
// check if these channels exist.
|
||||
const channelExists: boolean =
|
||||
await WorkspaceUtil.getWorkspaceTypeUtil(
|
||||
rule.workspaceType!
|
||||
rule.workspaceType!,
|
||||
).doesChannelExist({
|
||||
authToken: projectAuthToken,
|
||||
channelName: channelName,
|
||||
@@ -218,7 +218,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
|
||||
if (!channelExists) {
|
||||
throw new BadDataException(
|
||||
`Channel ${channelName} does not exist. If this channel is private, you need to invite OneUptime bot to the channel and try again.`
|
||||
`Channel ${channelName} does not exist. If this channel is private, you need to invite OneUptime bot to the channel and try again.`,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -235,7 +235,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
projectId: data.projectId,
|
||||
messagePayloadsByWorkspace: messageBlocksByWorkspaceTypes.map(
|
||||
(
|
||||
messageBlocksByWorkspaceType: MessageBlocksByWorkspaceType
|
||||
messageBlocksByWorkspaceType: MessageBlocksByWorkspaceType,
|
||||
) => {
|
||||
return {
|
||||
_type: "WorkspaceMessagePayload",
|
||||
@@ -244,19 +244,19 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
channelNames: [],
|
||||
channelIds: [createdChannel.id],
|
||||
};
|
||||
}
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
// Log results for test sends (created channels)
|
||||
const getMessageSummary: (wt: WorkspaceType) => string = (
|
||||
wt: WorkspaceType
|
||||
wt: WorkspaceType,
|
||||
): string => {
|
||||
const blocks: Array<WorkspaceMessageBlock> | undefined =
|
||||
messageBlocksByWorkspaceTypes.find(
|
||||
(b: MessageBlocksByWorkspaceType) => {
|
||||
return b.workspaceType === wt;
|
||||
}
|
||||
},
|
||||
)?.messageBlocks;
|
||||
if (!blocks) {
|
||||
return "";
|
||||
@@ -299,7 +299,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
}
|
||||
} catch (err) {
|
||||
throw new BadDataException(
|
||||
"Cannot post message to channel. " + (err as Error)?.message
|
||||
"Cannot post message to channel. " + (err as Error)?.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
projectId: data.projectId,
|
||||
messagePayloadsByWorkspace: messageBlocksByWorkspaceTypes.map(
|
||||
(
|
||||
messageBlocksByWorkspaceType: MessageBlocksByWorkspaceType
|
||||
messageBlocksByWorkspaceType: MessageBlocksByWorkspaceType,
|
||||
) => {
|
||||
return {
|
||||
_type: "WorkspaceMessagePayload",
|
||||
@@ -320,19 +320,19 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
channelNames: [existingChannelName],
|
||||
channelIds: [],
|
||||
};
|
||||
}
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
// Log results for test sends (existing channels)
|
||||
const getMessageSummary: (wt: WorkspaceType) => string = (
|
||||
wt: WorkspaceType
|
||||
wt: WorkspaceType,
|
||||
): string => {
|
||||
const blocks: Array<WorkspaceMessageBlock> | undefined =
|
||||
messageBlocksByWorkspaceTypes.find(
|
||||
(b: MessageBlocksByWorkspaceType) => {
|
||||
return b.workspaceType === wt;
|
||||
}
|
||||
},
|
||||
)?.messageBlocks;
|
||||
if (!blocks) {
|
||||
return "";
|
||||
@@ -375,7 +375,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
}
|
||||
} catch (err) {
|
||||
throw new BadDataException(
|
||||
"Cannot post message to channel. " + (err as Error)?.message
|
||||
"Cannot post message to channel. " + (err as Error)?.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
notificationFor: data.notificationFor,
|
||||
workspaceType: workspaceType,
|
||||
notificationRuleEventType: this.getNotificationRuleEventType(
|
||||
data.notificationFor
|
||||
data.notificationFor,
|
||||
),
|
||||
});
|
||||
|
||||
@@ -427,7 +427,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
const channelIds: Array<string> = channels.map(
|
||||
(channel: WorkspaceChannel) => {
|
||||
return channel.id;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// get project auth token.
|
||||
@@ -496,7 +496,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
return (
|
||||
messageBlocksByWorkspaceType.workspaceType === workspaceType
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
?.messageBlocks.push(...messageBlocksByWorkspaceType.messageBlocks);
|
||||
}
|
||||
@@ -509,7 +509,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
await this.getExistingChannelNamesBasedOnEventType({
|
||||
projectId: data.projectId,
|
||||
notificationRuleEventType: this.getNotificationRuleEventType(
|
||||
data.notificationFor
|
||||
data.notificationFor,
|
||||
),
|
||||
workspaceType: messageBlocksByWorkspaceType.workspaceType,
|
||||
notificationFor: data.notificationFor,
|
||||
@@ -544,13 +544,13 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
|
||||
// Create logs for each response/thread
|
||||
const getMessageSummary: (wt: WorkspaceType) => string = (
|
||||
wt: WorkspaceType
|
||||
wt: WorkspaceType,
|
||||
): string => {
|
||||
const blocks: Array<WorkspaceMessageBlock> | undefined =
|
||||
messageBlocksByWorkspaceTypes.find(
|
||||
(b: MessageBlocksByWorkspaceType) => {
|
||||
return b.workspaceType === wt;
|
||||
}
|
||||
},
|
||||
)?.messageBlocks;
|
||||
if (!blocks) {
|
||||
return "";
|
||||
@@ -654,7 +654,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
{
|
||||
scheduledMaintenanceId: data.notificationFor.scheduledMaintenanceId,
|
||||
workspaceType: data.workspaceType,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -665,7 +665,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
}
|
||||
|
||||
private getNotificationRuleEventType(
|
||||
notificationFor: NotificationFor
|
||||
notificationFor: NotificationFor,
|
||||
): NotificationRuleEventType {
|
||||
if (notificationFor.alertId) {
|
||||
return NotificationRuleEventType.Alert;
|
||||
@@ -710,7 +710,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
|
||||
if (!userId) {
|
||||
throw new BadDataException(
|
||||
"Bot user ID not found in project auth token"
|
||||
"Bot user ID not found in project auth token",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
notificationRules: notificationRules.map(
|
||||
(rule: WorkspaceNotificationRule) => {
|
||||
return rule.notificationRule as BaseNotificationRule;
|
||||
}
|
||||
},
|
||||
),
|
||||
}) || [];
|
||||
|
||||
@@ -767,7 +767,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
} | null> {
|
||||
try {
|
||||
logger.debug(
|
||||
"WorkspaceNotificationRuleService.createInviteAndPostToChannelsBasedOnRules"
|
||||
"WorkspaceNotificationRuleService.createInviteAndPostToChannelsBasedOnRules",
|
||||
);
|
||||
logger.debug(data);
|
||||
|
||||
@@ -839,14 +839,14 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
});
|
||||
|
||||
logger.debug(
|
||||
"Getting existing channel names from notification rules"
|
||||
"Getting existing channel names from notification rules",
|
||||
);
|
||||
const existingChannelNames: Array<string> =
|
||||
this.getExistingChannelNamesFromNotificationRules({
|
||||
notificationRules: notificationRules.map(
|
||||
(rule: WorkspaceNotificationRule) => {
|
||||
return rule.notificationRule as BaseNotificationRule;
|
||||
}
|
||||
},
|
||||
),
|
||||
}) || [];
|
||||
|
||||
@@ -854,7 +854,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
logger.debug(existingChannelNames);
|
||||
|
||||
logger.debug(
|
||||
"Adding created channel names to existing channel names"
|
||||
"Adding created channel names to existing channel names",
|
||||
);
|
||||
for (const channel of createdWorkspaceChannels) {
|
||||
if (!existingChannelNames.includes(channel.name)) {
|
||||
@@ -874,7 +874,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
"Error in creating channels and inviting users to channels for workspace type " +
|
||||
projectAuth.workspaceType
|
||||
projectAuth.workspaceType,
|
||||
);
|
||||
logger.error(err);
|
||||
}
|
||||
@@ -886,7 +886,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
"Error in createChannelsAndInviteUsersToChannelsBasedOnRules:"
|
||||
"Error in createChannelsAndInviteUsersToChannelsBasedOnRules:",
|
||||
);
|
||||
logger.error(err);
|
||||
return null;
|
||||
@@ -1012,7 +1012,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
logger.debug(channelIds);
|
||||
|
||||
await WorkspaceUtil.getWorkspaceTypeUtil(
|
||||
data.workspaceType
|
||||
data.workspaceType,
|
||||
).sendMessage({
|
||||
userId: data.projectAuth.workspaceProjectId!,
|
||||
authToken: data.projectAuth.authToken!,
|
||||
@@ -1043,7 +1043,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
logger.debug(workspaceUserIds);
|
||||
|
||||
await WorkspaceUtil.getWorkspaceTypeUtil(
|
||||
data.workspaceType
|
||||
data.workspaceType,
|
||||
).inviteUsersToChannels({
|
||||
authToken: data.projectAuth.authToken!,
|
||||
workspaceChannelInvitationPayload: {
|
||||
@@ -1080,7 +1080,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
"inviteUsersBasedOnRulesAndWorkspaceChannels called with data:"
|
||||
"inviteUsersBasedOnRulesAndWorkspaceChannels called with data:",
|
||||
);
|
||||
logger.debug(data);
|
||||
const userIds: Array<ObjectID> = data.userIds;
|
||||
@@ -1108,7 +1108,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
return notificationRules.find((rule: WorkspaceNotificationRule) => {
|
||||
return rule.id?.toString() === channel.notificationRuleId;
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Channels to invite to based on rule:");
|
||||
@@ -1161,7 +1161,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
const channelIds: Array<string> = channelsToInviteToBasedOnRule.map(
|
||||
(channel: NotificationRuleWorkspaceChannel) => {
|
||||
return channel.id as string;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Channel IDs to send message to:");
|
||||
@@ -1187,7 +1187,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
} as WorkspacePayloadMarkdown,
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error("Error in sending message to channel");
|
||||
@@ -1202,14 +1202,14 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
const channelNames: Array<string> = channelsToInviteToBasedOnRule.map(
|
||||
(channel: NotificationRuleWorkspaceChannel) => {
|
||||
return channel.name;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
logger.debug("Channel names to invite to:");
|
||||
logger.debug(channelNames);
|
||||
|
||||
await WorkspaceUtil.getWorkspaceTypeUtil(
|
||||
workspaceType
|
||||
workspaceType,
|
||||
).inviteUsersToChannels({
|
||||
authToken: projectAuth.authToken!,
|
||||
workspaceChannelInvitationPayload: {
|
||||
@@ -1267,7 +1267,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
}
|
||||
|
||||
const usersInTeam: Array<User> = await TeamMemberService.getUsersInTeams(
|
||||
data.teamIds
|
||||
data.teamIds,
|
||||
);
|
||||
|
||||
logger.debug("Users in teams:");
|
||||
@@ -1359,17 +1359,17 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
}).length > 0
|
||||
) {
|
||||
logger.debug(
|
||||
`Channel name ${notificationChannel.channelName} already created. Skipping.`
|
||||
`Channel name ${notificationChannel.channelName} already created. Skipping.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`Creating new channel with name: ${notificationChannel.channelName}`
|
||||
`Creating new channel with name: ${notificationChannel.channelName}`,
|
||||
);
|
||||
const channel: WorkspaceChannel =
|
||||
await WorkspaceUtil.getWorkspaceTypeUtil(
|
||||
data.workspaceType
|
||||
data.workspaceType,
|
||||
).createChannel({
|
||||
authToken: data.projectOrUserAuthTokenForWorkspace,
|
||||
channelName: notificationChannel.channelName,
|
||||
@@ -1532,7 +1532,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
notificationRules: Array<BaseNotificationRule>;
|
||||
}): Array<string> {
|
||||
logger.debug(
|
||||
"getExistingChannelNamesFromNotificationRules called with data:"
|
||||
"getExistingChannelNamesFromNotificationRules called with data:",
|
||||
);
|
||||
logger.debug(data);
|
||||
|
||||
@@ -1576,7 +1576,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
notificationRuleId: string;
|
||||
}> {
|
||||
logger.debug(
|
||||
"getnotificationChannelssFromNotificationRules called with data:"
|
||||
"getnotificationChannelssFromNotificationRules called with data:",
|
||||
);
|
||||
logger.debug(data);
|
||||
|
||||
@@ -1611,7 +1611,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
channels.filter(
|
||||
(name: { channelName: string; notificationRuleId: string }) => {
|
||||
return name.channelName === channelName;
|
||||
}
|
||||
},
|
||||
).length === 0
|
||||
) {
|
||||
// if channel name is not already added then add it.
|
||||
@@ -1622,7 +1622,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
logger.debug(`Channel name ${channelName} added to the list.`);
|
||||
} else {
|
||||
logger.debug(
|
||||
`Channel name ${channelName} already exists in the list. Skipping.`
|
||||
`Channel name ${channelName} already exists in the list. Skipping.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1870,7 +1870,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
scheduledMaintenance.monitors?.map(
|
||||
(monitor: ScheduledMaintenance) => {
|
||||
return monitor.id!;
|
||||
}
|
||||
},
|
||||
) || [],
|
||||
});
|
||||
|
||||
@@ -1910,7 +1910,7 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
||||
scheduledMaintenance.monitors?.map(
|
||||
(monitor: ScheduledMaintenance) => {
|
||||
return monitor._id?.toString() || "";
|
||||
}
|
||||
},
|
||||
) || [],
|
||||
[NotificationRuleConditionCheckOn.OnCallDutyPolicyName]: undefined,
|
||||
[NotificationRuleConditionCheckOn.OnCallDutyPolicyDescription]:
|
||||
|
||||
@@ -386,7 +386,6 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
authToken: data.authToken,
|
||||
});
|
||||
|
||||
|
||||
for (let channelName of data.channelNames) {
|
||||
// if channel name starts with #, remove it
|
||||
if (channelName && channelName.startsWith("#")) {
|
||||
@@ -696,7 +695,6 @@ export default class SlackUtil extends WorkspaceBase {
|
||||
authToken: data.authToken,
|
||||
});
|
||||
|
||||
|
||||
const workspaceChannelsToPostTo: Array<WorkspaceChannel> = [];
|
||||
|
||||
for (let channelName of data.workspaceMessagePayload.channelNames) {
|
||||
|
||||
@@ -145,7 +145,7 @@ export default class WorkspaceUtil {
|
||||
messagePayloadsByWorkspace: Array<WorkspaceMessagePayload>;
|
||||
}): Promise<Array<WorkspaceSendMessageResponse>> {
|
||||
logger.debug("postToWorkspaceChannels called with data:");
|
||||
logger.debug(JSON.stringify(data, null ,2));
|
||||
logger.debug(JSON.stringify(data, null, 2));
|
||||
|
||||
const responses: Array<WorkspaceSendMessageResponse> = [];
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
// Try to get cached home URL first.
|
||||
let homeUrl: string | undefined = LocalCache.getString(
|
||||
"home",
|
||||
"url"
|
||||
"url",
|
||||
);
|
||||
|
||||
if (!homeUrl) {
|
||||
@@ -58,7 +58,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
}
|
||||
}
|
||||
next();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -82,9 +82,9 @@ const HomeFeatureSet: FeatureSet = {
|
||||
(_req: ExpressRequest, res: ExpressResponse) => {
|
||||
// fetch the file from https://raw.githubusercontent.com/oneuptime/infrastructure-agent/release/Scripts/Install/Linux.sh and send it as response
|
||||
res.redirect(
|
||||
"https://raw.githubusercontent.com/OneUptime/oneuptime/release/InfrastructureAgent/Scripts/Install/Linux.sh"
|
||||
"https://raw.githubusercontent.com/OneUptime/oneuptime/release/InfrastructureAgent/Scripts/Install/Linux.sh",
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/support", async (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -105,7 +105,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
}),
|
||||
enableGoogleTagManager: IsBillingEnabled,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/pricing", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -892,7 +892,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
blackLogo: true,
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -901,7 +901,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
res.render(`${ViewsPath}/status-page`, {
|
||||
enableGoogleTagManager: IsBillingEnabled,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -910,7 +910,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
res.render(`${ViewsPath}/logs-management`, {
|
||||
enableGoogleTagManager: IsBillingEnabled,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/product/apm", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -927,7 +927,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
"/logs-management",
|
||||
(_req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.redirect("/product/logs-management");
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let gitHubContributors: Array<JSONObject> = [];
|
||||
@@ -947,8 +947,8 @@ const HomeFeatureSet: FeatureSet = {
|
||||
await API.get<Array<JSONObject>>(
|
||||
URL.fromString(
|
||||
"https://api.github.com/repos/oneuptime/oneuptime/contributors?page=" +
|
||||
pageNumber
|
||||
)
|
||||
pageNumber,
|
||||
),
|
||||
);
|
||||
pageNumber++;
|
||||
if ((response.data as Array<JSONObject>).length < 30) {
|
||||
@@ -956,7 +956,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
}
|
||||
|
||||
contributors = contributors.concat(
|
||||
response.data as Array<JSONObject>
|
||||
response.data as Array<JSONObject>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -966,8 +966,8 @@ const HomeFeatureSet: FeatureSet = {
|
||||
|
||||
const response: HTTPResponse<JSONObject> = await API.get(
|
||||
URL.fromString(
|
||||
"https://api.github.com/repos/oneuptime/oneuptime/commits?sha=master&per_page=1&page=1"
|
||||
)
|
||||
"https://api.github.com/repos/oneuptime/oneuptime/commits?sha=master&per_page=1&page=1",
|
||||
),
|
||||
);
|
||||
|
||||
if (gitHubCommits === "-") {
|
||||
@@ -981,12 +981,12 @@ const HomeFeatureSet: FeatureSet = {
|
||||
.trim();
|
||||
const url: URL = URL.fromString(urlString!);
|
||||
const commits: string = Number.parseInt(
|
||||
url.getQueryParam("page") as string
|
||||
url.getQueryParam("page") as string,
|
||||
).toLocaleString();
|
||||
|
||||
if (!gitHubBasicInfo) {
|
||||
const basicInfo: HTTPResponse<JSONObject> = await API.get(
|
||||
URL.fromString("https://api.github.com/repos/oneuptime/oneuptime")
|
||||
URL.fromString("https://api.github.com/repos/oneuptime/oneuptime"),
|
||||
);
|
||||
|
||||
gitHubBasicInfo = basicInfo.data as JSONObject;
|
||||
@@ -1016,7 +1016,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
footerCtaText:
|
||||
"Start with Status Pages, expand into everything else. Sign up today.",
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/status-page", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -1037,7 +1037,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
res.render(`${ViewsPath}/monitoring`, {
|
||||
enableGoogleTagManager: IsBillingEnabled,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1046,7 +1046,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
res.render(`${ViewsPath}/on-call`, {
|
||||
enableGoogleTagManager: IsBillingEnabled,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1055,7 +1055,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
res.render(`${ViewsPath}/workflows`, {
|
||||
enableGoogleTagManager: IsBillingEnabled,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1064,14 +1064,14 @@ const HomeFeatureSet: FeatureSet = {
|
||||
res.render(`${ViewsPath}/incident-management`, {
|
||||
enableGoogleTagManager: IsBillingEnabled,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/incident-management",
|
||||
(_req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.redirect("/product/incident-management");
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1085,7 +1085,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
blackLogo: false,
|
||||
requestDemoCta: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/legal", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -1148,7 +1148,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
section: "subprocessors",
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/legal/ccpa", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -1211,7 +1211,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
section: "iso-27001",
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1226,7 +1226,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
section: "iso-27017",
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1241,7 +1241,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
section: "iso-27018",
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1256,7 +1256,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
section: "iso-27017",
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get(
|
||||
@@ -1271,7 +1271,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
section: "iso-27018",
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/legal/soc-2", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -1310,7 +1310,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
section: "data-residency",
|
||||
requestDemoCta: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
app.get("/legal/gdpr", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
@@ -1341,7 +1341,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
"/compare/:product",
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
const productConfig: Product = ProductCompare(
|
||||
req.params["product"] as string
|
||||
req.params["product"] as string,
|
||||
);
|
||||
|
||||
if (!productConfig) {
|
||||
@@ -1357,7 +1357,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
productConfig,
|
||||
onlyShowCompareTable: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Dynamic Sitemap
|
||||
@@ -1374,7 +1374,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
res.setHeader("Content-Type", "text/xml");
|
||||
res.status(200).send(fallback);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// robots.txt (dynamic) - If domain is not oneuptime.com, disallow all.
|
||||
@@ -1416,7 +1416,7 @@ const HomeFeatureSet: FeatureSet = {
|
||||
setHeaders(res: ExpressResponse) {
|
||||
res.setHeader("Cache-Control", "public,max-age=31536000,immutable");
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
app.get("/*", (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
|
||||
Reference in New Issue
Block a user