mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix sso docs
This commit is contained in:
14
.vscode/launch.json
vendored
14
.vscode/launch.json
vendored
@@ -41,6 +41,20 @@
|
||||
"restart": true,
|
||||
"autoAttachChildProcesses": true
|
||||
},
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"localRoot": "${workspaceFolder}/ApiReference",
|
||||
"name": "API Reference: Debug with Docker",
|
||||
"port": 9178,
|
||||
"remoteRoot": "/usr/src/app",
|
||||
"request": "attach",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "node",
|
||||
"restart": true,
|
||||
"autoAttachChildProcesses": true
|
||||
},
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"localRoot": "${workspaceFolder}/LinkShortner",
|
||||
|
||||
@@ -47,6 +47,8 @@ export default class ServiceHandler {
|
||||
|
||||
page = 'model';
|
||||
|
||||
debugger;
|
||||
|
||||
const tableColumns: any = getTableColumns(currentResource.model);
|
||||
|
||||
for (const key in tableColumns) {
|
||||
|
||||
@@ -500,6 +500,14 @@ export class PermissionHelper {
|
||||
isAssignableToTenant: true,
|
||||
isAccessControlPermission: false,
|
||||
},
|
||||
{
|
||||
permission: Permission.ProjectUser,
|
||||
title: 'Project User',
|
||||
description:
|
||||
'User of this project.',
|
||||
isAssignableToTenant: true,
|
||||
isAccessControlPermission: false,
|
||||
},
|
||||
{
|
||||
permission: Permission.CurrentUser,
|
||||
title: 'Logged in User',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import PostgresDatabase from '../Infrastructure/PostgresDatabase';
|
||||
import Model from 'Model/Models/UserNotificationLog';
|
||||
import DatabaseService, { OnCreate } from './DatabaseService';
|
||||
import DatabaseService, { OnCreate, OnUpdate } from './DatabaseService';
|
||||
import UserNotificationRule from 'Model/Models/UserNotificationRule';
|
||||
import UserNotificationRuleService from './UserNotificationRuleService';
|
||||
import { LIMIT_PER_PROJECT } from 'Common/Types/Database/LimitMax';
|
||||
@@ -9,9 +9,12 @@ import UserNotificationEventType from 'Common/Types/UserNotification/UserNotific
|
||||
import BadDataException from 'Common/Types/Exception/BadDataException';
|
||||
import CreateBy from '../Types/Database/CreateBy';
|
||||
import UserNotificationExecutionStatus from 'Common/Types/UserNotification/UserNotificationExecutionStatus';
|
||||
import IncidentSeverity from 'Model/Models/IncidentSeverity';
|
||||
import IncidentService from './IncidentService';
|
||||
import Incident from 'Model/Models/Incident';
|
||||
import PositiveNumber from 'Common/Types/PositiveNumber';
|
||||
import ObjectID from 'Common/Types/ObjectID';
|
||||
import OnCallDutyPolicyExecutionLogTimelineService from './OnCallDutyPolicyExecutionLogTimelineService';
|
||||
import OnCallDutyExecutionLogTimelineStatus from 'Common/Types/OnCallDutyPolicy/OnCalDutyExecutionLogTimelineStatus';
|
||||
|
||||
export class Service extends DatabaseService<Model> {
|
||||
public constructor(postgresDatabase?: PostgresDatabase) {
|
||||
@@ -29,6 +32,62 @@ export class Service extends DatabaseService<Model> {
|
||||
};
|
||||
}
|
||||
|
||||
protected override async onUpdateSuccess(onUpdate: OnUpdate<Model>, _updatedItemIds: ObjectID[]): Promise<OnUpdate<Model>> {
|
||||
if (onUpdate.updateBy.data.status) {
|
||||
//update the correspomnding oncallTimeline.
|
||||
const items = await this.findBy({
|
||||
query: onUpdate.updateBy.query,
|
||||
select: {
|
||||
onCallDutyPolicyExecutionLogTimelineId: true,
|
||||
},
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
|
||||
let status: OnCallDutyExecutionLogTimelineStatus | undefined = undefined;
|
||||
|
||||
switch (onUpdate.updateBy.data.status) {
|
||||
case UserNotificationExecutionStatus.Completed:
|
||||
status = OnCallDutyExecutionLogTimelineStatus.NotificationSent;
|
||||
break;
|
||||
case UserNotificationExecutionStatus.Error:
|
||||
status = OnCallDutyExecutionLogTimelineStatus.Error;
|
||||
break;
|
||||
case UserNotificationExecutionStatus.Running:
|
||||
status = OnCallDutyExecutionLogTimelineStatus.Running;
|
||||
break;
|
||||
case UserNotificationExecutionStatus.Scheduled:
|
||||
status = OnCallDutyExecutionLogTimelineStatus.Started;
|
||||
break;
|
||||
case UserNotificationExecutionStatus.Started:
|
||||
status = OnCallDutyExecutionLogTimelineStatus.Started;
|
||||
break;
|
||||
default:
|
||||
throw new BadDataException('Invalid status');
|
||||
}
|
||||
|
||||
|
||||
for (const item of items) {
|
||||
await OnCallDutyPolicyExecutionLogTimelineService.updateOneById({
|
||||
id: item.onCallDutyPolicyExecutionLogTimelineId!,
|
||||
data: {
|
||||
status: status!,
|
||||
statusMessage: onUpdate.updateBy.data.statusMessage!,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return onUpdate;
|
||||
}
|
||||
|
||||
protected override async onCreateSuccess(
|
||||
_onCreate: OnCreate<Model>,
|
||||
createdItem: Model
|
||||
@@ -60,6 +119,39 @@ export class Service extends DatabaseService<Model> {
|
||||
});
|
||||
|
||||
|
||||
// Check if there are any rules .
|
||||
const ruleCount: PositiveNumber = await UserNotificationRuleService.countBy({
|
||||
query: {
|
||||
userId: createdItem.userId!,
|
||||
projectId: createdItem.projectId!,
|
||||
ruleType: notificationRuleType,
|
||||
incidentSeverityId: incident?.incidentSeverityId!,
|
||||
},
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (ruleCount.toNumber() === 0) {
|
||||
// update this item to be processed.
|
||||
await this.updateOneById({
|
||||
id: createdItem.id!,
|
||||
data: {
|
||||
status: UserNotificationExecutionStatus.Error, // now the worker will pick this up and complete this or mark this as failed.
|
||||
statusMessage: 'No notification rules found.'
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return createdItem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// find immediate notification rule and alert the user.
|
||||
const immediateNotificationRule: Array<UserNotificationRule> =
|
||||
|
||||
@@ -45,7 +45,6 @@ import EnableDocumentation from 'Common/Types/Model/EnableDocumentation';
|
||||
Permission.ProjectUser,
|
||||
Permission.Public,
|
||||
Permission.ProjectAdmin,
|
||||
Permission.ProjectUser,
|
||||
Permission.CanReadStatusPageSSO,
|
||||
],
|
||||
delete: [
|
||||
@@ -82,8 +81,6 @@ export default class StatusPageSSO extends BaseModel {
|
||||
Permission.ProjectAdmin,
|
||||
Permission.ProjectUser,
|
||||
Permission.Public,
|
||||
Permission.ProjectUser,
|
||||
Permission.Public,
|
||||
Permission.CanReadStatusPageSSO,
|
||||
],
|
||||
update: [],
|
||||
@@ -122,8 +119,6 @@ export default class StatusPageSSO extends BaseModel {
|
||||
Permission.ProjectUser,
|
||||
Permission.Public,
|
||||
Permission.CanReadStatusPageSSO,
|
||||
Permission.ProjectUser,
|
||||
Permission.Public,
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@@ -222,8 +217,6 @@ export default class StatusPageSSO extends BaseModel {
|
||||
Permission.ProjectUser,
|
||||
Permission.Public,
|
||||
Permission.CanReadStatusPageSSO,
|
||||
Permission.ProjectUser,
|
||||
Permission.Public,
|
||||
],
|
||||
update: [
|
||||
Permission.ProjectOwner,
|
||||
|
||||
@@ -62,10 +62,10 @@ import './Jobs/StatusPageOwners/SendAnnouncementCreatedEmail';
|
||||
import RunDatabaseMigrations from './Utils/DataMigration';
|
||||
|
||||
// On Call Duty Policy Executions.
|
||||
import './Jobs/OnCallDutyPolicyExecution/ExecuteOnCallDutyPolicy';
|
||||
import './Jobs/OnCallDutyPolicyExecutionLog/ExecutePendingExecutions';
|
||||
|
||||
// User Notifications Log
|
||||
import './Jobs/UserNotificationsLog/UpdateUserNotificationsLog';
|
||||
import './Jobs/UserNotificationLog/ExecutePendingExecutions';
|
||||
|
||||
const APP_NAME: string = 'workers';
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import OneUptimeDate from 'Common/Types/Date';
|
||||
import QueryHelper from 'CommonServer/Types/Database/QueryHelper';
|
||||
import LIMIT_MAX from 'Common/Types/Database/LimitMax';
|
||||
import logger from 'CommonServer/Utils/Logger';
|
||||
import { Service as BillingInvoiceServiceType } from 'CommonServer/Services/BillingInvoiceService';
|
||||
|
||||
RunCron(
|
||||
'HardDelete:HardDeleteItemsInDatabase',
|
||||
@@ -14,6 +15,12 @@ RunCron(
|
||||
async () => {
|
||||
for (const service of Services) {
|
||||
if (service instanceof DatabaseService) {
|
||||
|
||||
if (service instanceof BillingInvoiceServiceType) {
|
||||
// skip invoice service because invoices should not be deleted.
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// Retain data for 30 days for accidental deletion, and then hard delete.
|
||||
await service.hardDeleteBy({
|
||||
|
||||
Reference in New Issue
Block a user