mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix compile err
This commit is contained in:
@@ -23,14 +23,11 @@ enum PermissionNamespace {
|
||||
}
|
||||
|
||||
export class AccessTokenService extends BaseService {
|
||||
|
||||
public constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public async refreshUserAllPermissions(
|
||||
userId: ObjectID
|
||||
): Promise<void> {
|
||||
public async refreshUserAllPermissions(userId: ObjectID): Promise<void> {
|
||||
await this.refreshUserGlobalAccessPermission(userId);
|
||||
|
||||
// query for all projects user belongs to.
|
||||
@@ -60,10 +57,7 @@ export class AccessTokenService extends BaseService {
|
||||
);
|
||||
|
||||
for (const projectId of projectIds) {
|
||||
await this.refreshUserTenantAccessPermission(
|
||||
userId,
|
||||
projectId
|
||||
);
|
||||
await this.refreshUserTenantAccessPermission(userId, projectId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,9 +198,7 @@ export class AccessTokenService extends BaseService {
|
||||
);
|
||||
|
||||
if (!json) {
|
||||
return await this.refreshUserGlobalAccessPermission(
|
||||
userId
|
||||
);
|
||||
return await this.refreshUserGlobalAccessPermission(userId);
|
||||
}
|
||||
|
||||
const accessPermission: UserGlobalAccessPermission =
|
||||
@@ -323,4 +315,4 @@ export class AccessTokenService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
export default new AccessTokenService();
|
||||
export default new AccessTokenService();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
export default class BaseService {
|
||||
public constructor() {
|
||||
|
||||
}
|
||||
public constructor() {}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import PostgresDatabase from '../Infrastructure/PostgresDatabase';
|
||||
import Model from 'Model/Models/BillingInvoice';
|
||||
import DatabaseService, { OnDelete, OnFind } from './DatabaseService';
|
||||
import DatabaseService, { OnFind } from './DatabaseService';
|
||||
import FindBy from '../Types/Database/FindBy';
|
||||
import ProjectService from './ProjectService';
|
||||
import BadDataException from 'Common/Types/Exception/BadDataException';
|
||||
import Project from 'Model/Models/Project';
|
||||
import BillingService, { Invoice } from './BillingService';
|
||||
import DeleteBy from '../Types/Database/DeleteBy';
|
||||
import URL from 'Common/Types/API/URL';
|
||||
import { LIMIT_PER_PROJECT } from 'Common/Types/Database/LimitMax';
|
||||
|
||||
export class Service extends DatabaseService<Model> {
|
||||
public constructor(postgresDatabase?: PostgresDatabase) {
|
||||
super(Model, postgresDatabase);
|
||||
this.setDoNotAllowDelete(true);
|
||||
}
|
||||
|
||||
protected override async onBeforeFind(
|
||||
@@ -87,12 +87,6 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
return { findBy, carryForward: invoices };
|
||||
}
|
||||
|
||||
protected override async onBeforeDelete(
|
||||
_deleteBy: DeleteBy<Model>
|
||||
): Promise<OnDelete<Model>> {
|
||||
throw new BadDataException('Invoice should not be deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
export default new Service();
|
||||
|
||||
@@ -30,7 +30,6 @@ export interface Invoice {
|
||||
}
|
||||
|
||||
export class BillingService extends BaseService {
|
||||
|
||||
public constructor() {
|
||||
super();
|
||||
}
|
||||
@@ -40,10 +39,7 @@ export class BillingService extends BaseService {
|
||||
});
|
||||
|
||||
// returns billing id of the customer.
|
||||
public async createCustomer(
|
||||
name: string,
|
||||
id: ObjectID
|
||||
): Promise<string> {
|
||||
public async createCustomer(name: string, id: ObjectID): Promise<string> {
|
||||
if (!this.isBillingEnabled()) {
|
||||
throw new BadDataException(
|
||||
'Billing is not enabled for this server.'
|
||||
@@ -352,9 +348,7 @@ export class BillingService extends BaseService {
|
||||
await this.stripe.paymentMethods.detach(paymentMethodId);
|
||||
}
|
||||
|
||||
public async hasPaymentMethods(
|
||||
customerId: string
|
||||
): Promise<boolean> {
|
||||
public async hasPaymentMethods(customerId: string): Promise<boolean> {
|
||||
if ((await this.getPaymentMethods(customerId)).length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -435,9 +429,7 @@ export class BillingService extends BaseService {
|
||||
return paymenMethods;
|
||||
}
|
||||
|
||||
public async getSetupIntentSecret(
|
||||
customerId: string
|
||||
): Promise<string> {
|
||||
public async getSetupIntentSecret(customerId: string): Promise<string> {
|
||||
const setupIntent: Stripe.Response<Stripe.SetupIntent> =
|
||||
await this.stripe.setupIntents.create({
|
||||
customer: customerId,
|
||||
@@ -452,9 +444,7 @@ export class BillingService extends BaseService {
|
||||
return setupIntent.client_secret;
|
||||
}
|
||||
|
||||
public async cancelSubscription(
|
||||
subscriptionId: string
|
||||
): Promise<void> {
|
||||
public async cancelSubscription(subscriptionId: string): Promise<void> {
|
||||
if (!this.isBillingEnabled()) {
|
||||
throw new BadDataException(
|
||||
'Billing is not enabled for this server.'
|
||||
@@ -491,9 +481,7 @@ export class BillingService extends BaseService {
|
||||
return subscription;
|
||||
}
|
||||
|
||||
public async getInvoices(
|
||||
customerId: string
|
||||
): Promise<Array<Invoice>> {
|
||||
public async getInvoices(customerId: string): Promise<Array<Invoice>> {
|
||||
const invoices: Stripe.ApiList<Stripe.Invoice> =
|
||||
await this.stripe.invoices.list({
|
||||
customer: customerId,
|
||||
@@ -546,9 +534,7 @@ export class BillingService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
public async voidInvoice(
|
||||
invoiceId: string
|
||||
): Promise<Stripe.Invoice> {
|
||||
public async voidInvoice(invoiceId: string): Promise<Stripe.Invoice> {
|
||||
const invoice: Stripe.Invoice = await this.stripe.invoices.voidInvoice(
|
||||
invoiceId
|
||||
);
|
||||
@@ -589,5 +575,4 @@ export class BillingService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default new BillingService();
|
||||
export default new BillingService();
|
||||
|
||||
@@ -16,7 +16,7 @@ export class CallService extends BaseService {
|
||||
public constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public async makeCall(
|
||||
callRequest: CallRequest,
|
||||
options: {
|
||||
@@ -49,5 +49,4 @@ export class CallService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default new CallService();
|
||||
export default new CallService();
|
||||
|
||||
@@ -96,6 +96,8 @@ class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
|
||||
this._hardDeleteItemsOlderThanDays = v;
|
||||
}
|
||||
|
||||
public doNotAllowDelete: boolean = false;
|
||||
|
||||
public constructor(
|
||||
modelType: { new (): TBaseModel },
|
||||
postgresDatabase?: PostgresDatabase
|
||||
@@ -110,6 +112,10 @@ class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
public setDoNotAllowDelete(doNotAllowDelete: boolean): void {
|
||||
this.doNotAllowDelete = doNotAllowDelete;
|
||||
}
|
||||
|
||||
public hardDeleteItemsOlderThanInDays(
|
||||
columnName: string,
|
||||
olderThan: number
|
||||
@@ -877,6 +883,10 @@ class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
|
||||
|
||||
private async _deleteBy(deleteBy: DeleteBy<TBaseModel>): Promise<number> {
|
||||
try {
|
||||
if (this.doNotAllowDelete) {
|
||||
throw new BadDataException('Delete not allowed');
|
||||
}
|
||||
|
||||
const onDelete: OnDelete<TBaseModel> = deleteBy.props.ignoreHooks
|
||||
? { deleteBy, carryForward: [] }
|
||||
: await this.onBeforeDelete(deleteBy);
|
||||
|
||||
@@ -112,30 +112,28 @@ import UserOnCallLogService from './UserOnCallLogService';
|
||||
import UserOnCallLogTimelineService from './UserOnCallLogTimelineService';
|
||||
import BaseService from './BaseService';
|
||||
|
||||
|
||||
const services: Array<BaseService> = [
|
||||
|
||||
// Import all services in current folder here.
|
||||
AccessTokenService,
|
||||
// Import all services in current folder here.
|
||||
AccessTokenService,
|
||||
ApiKeyPermissionService,
|
||||
ApiKeyService,
|
||||
|
||||
BillingInvoiceService,
|
||||
BillingInvoiceService,
|
||||
BillingPaymentMethodsService,
|
||||
BillingService,
|
||||
|
||||
CallLogService,
|
||||
CallService,
|
||||
CallService,
|
||||
|
||||
DataMigrationService,
|
||||
DataMigrationService,
|
||||
DomainService,
|
||||
|
||||
EmailLogService,
|
||||
EmailVerificationTokenService,
|
||||
|
||||
FileService,
|
||||
|
||||
GlobalConfigService,
|
||||
|
||||
GlobalConfigService,
|
||||
GreenlockCertificateService,
|
||||
GreenlockChallengeService,
|
||||
|
||||
@@ -151,7 +149,7 @@ const services: Array<BaseService> = [
|
||||
|
||||
LabelService,
|
||||
|
||||
MailService,
|
||||
MailService,
|
||||
MonitorCustomFieldService,
|
||||
MonitorOwnerTeamService,
|
||||
MonitorOwnerUserService,
|
||||
@@ -162,12 +160,12 @@ const services: Array<BaseService> = [
|
||||
|
||||
NotificationService,
|
||||
|
||||
OnCallDutyPolicyCustomFieldService,
|
||||
OnCallDutyPolicyCustomFieldService,
|
||||
OnCallDutyPolicyEscalationRuleService,
|
||||
OnCallDutyPolicyEscalationRuleTeamService,
|
||||
OnCallDutyPolicyEscalationRuleUserService,
|
||||
OnCallDutyPolicyExecutionLogService,
|
||||
OnCallDutyPolicyExecutionLogTimelineService,
|
||||
OnCallDutyPolicyEscalationRuleTeamService,
|
||||
OnCallDutyPolicyEscalationRuleUserService,
|
||||
OnCallDutyPolicyExecutionLogService,
|
||||
OnCallDutyPolicyExecutionLogTimelineService,
|
||||
OnCallDutyPolicyService,
|
||||
|
||||
ProjectService,
|
||||
@@ -178,18 +176,18 @@ const services: Array<BaseService> = [
|
||||
ScheduledMaintenanceCustomFieldService,
|
||||
ScheduledMaintenanceInternalNoteService,
|
||||
ScheduledMaintenanceOwnerTeamService,
|
||||
ScheduledMaintenanceOwnerUserService,
|
||||
ScheduledMaintenanceOwnerUserService,
|
||||
ScheduledMaintenancePublicNoteService,
|
||||
ScheduledMaintenanceService,
|
||||
ScheduledMaintenanceStateService,
|
||||
ScheduledMaintenanceStateTimelineService,
|
||||
|
||||
ShortLinkService,
|
||||
|
||||
ShortLinkService,
|
||||
SmsLogService,
|
||||
SmsService,
|
||||
SmsService,
|
||||
|
||||
StatusPageAnnouncementService,
|
||||
StatusPageCertificateService,
|
||||
StatusPageCertificateService,
|
||||
StatusPageCustomFieldService,
|
||||
StatusPageDomainService,
|
||||
StatusPageFooterLinkService,
|
||||
@@ -200,7 +198,7 @@ const services: Array<BaseService> = [
|
||||
StatusPagePrivateUserService,
|
||||
StatusPageResourceService,
|
||||
StatusPageService,
|
||||
StatusPageSsoService,
|
||||
StatusPageSsoService,
|
||||
StatusPageSubscriberService,
|
||||
|
||||
TeamMemberService,
|
||||
@@ -208,19 +206,17 @@ const services: Array<BaseService> = [
|
||||
TeamService,
|
||||
|
||||
UserService,
|
||||
UserCallService,
|
||||
UserCallService,
|
||||
UserEmailService,
|
||||
UserNotificationRuleService,
|
||||
UserNotificationSettingService,
|
||||
UserOnCallLogService,
|
||||
UserOnCallLogTimelineService,
|
||||
UserNotificationSettingService,
|
||||
UserOnCallLogService,
|
||||
UserOnCallLogTimelineService,
|
||||
UserSmsService,
|
||||
|
||||
WorkflowLogService,
|
||||
WorkflowService,
|
||||
WorkflowVariablesService,
|
||||
|
||||
];
|
||||
|
||||
|
||||
export default services;
|
||||
export default services;
|
||||
|
||||
@@ -60,5 +60,4 @@ export class MailService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default new MailService();
|
||||
export default new MailService();
|
||||
|
||||
@@ -8,11 +8,10 @@ import BadDataException from 'Common/Types/Exception/BadDataException';
|
||||
import BaseService from './BaseService';
|
||||
|
||||
export class NotificationService extends BaseService {
|
||||
|
||||
public constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public async rechargeBalance(
|
||||
projectId: ObjectID,
|
||||
amountInUSD: number
|
||||
@@ -199,4 +198,4 @@ export class NotificationService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
export default new NotificationService();
|
||||
export default new NotificationService();
|
||||
|
||||
@@ -16,7 +16,7 @@ export class SmsService extends BaseService {
|
||||
public constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public async sendSms(
|
||||
sms: SMS,
|
||||
options: {
|
||||
@@ -50,4 +50,4 @@ export class SmsService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
export default new SmsService();
|
||||
export default new SmsService();
|
||||
|
||||
@@ -11,10 +11,8 @@ export class StatusPageCertificateService extends BaseService {
|
||||
public constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public async add(
|
||||
domain: string
|
||||
): Promise<HTTPResponse<EmptyResponseData>> {
|
||||
|
||||
public async add(domain: string): Promise<HTTPResponse<EmptyResponseData>> {
|
||||
const body: JSONObject = {
|
||||
domain: domain,
|
||||
};
|
||||
|
||||
@@ -51,9 +51,8 @@ const Components: Dictionary<ComponentCode> = {
|
||||
};
|
||||
|
||||
for (const baseModelService of Services) {
|
||||
|
||||
if(!baseModelService instanceof DatabaseService){
|
||||
continue;
|
||||
if (!(baseModelService instanceof DatabaseService)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const model: BaseModel = baseModelService.getModel();
|
||||
|
||||
@@ -243,11 +243,11 @@ const Filter: FunctionComponent<ComponentProps> = (
|
||||
)}
|
||||
|
||||
{(column.type === FieldType.Date ||
|
||||
column.type === FieldType.Email ||
|
||||
column.type === FieldType.Phone ||
|
||||
column.type === FieldType.Name ||
|
||||
column.type === FieldType.Port ||
|
||||
column.type === FieldType.URL ||
|
||||
column.type === FieldType.Email ||
|
||||
column.type === FieldType.Phone ||
|
||||
column.type === FieldType.Name ||
|
||||
column.type === FieldType.Port ||
|
||||
column.type === FieldType.URL ||
|
||||
column.type ===
|
||||
FieldType.DateTime ||
|
||||
column.type ===
|
||||
|
||||
@@ -21,7 +21,6 @@ import ConfirmModal from 'CommonUI/src/Components/Modal/ConfirmModal';
|
||||
const EmailLogs: FunctionComponent<PageComponentProps> = (
|
||||
_props: PageComponentProps
|
||||
): ReactElement => {
|
||||
|
||||
const [showViewEmailTextModal, setShowViewEmailTextModal] =
|
||||
useState<boolean>(false);
|
||||
const [EmailText, setEmailText] = useState<string>('');
|
||||
@@ -184,9 +183,7 @@ const EmailLogs: FunctionComponent<PageComponentProps> = (
|
||||
{showViewEmailTextModal && (
|
||||
<ConfirmModal
|
||||
title={EmailModelTitle}
|
||||
description={
|
||||
EmailText
|
||||
}
|
||||
description={EmailText}
|
||||
onSubmit={() => {
|
||||
setShowViewEmailTextModal(false);
|
||||
}}
|
||||
|
||||
@@ -25,7 +25,6 @@ import MailStatus from 'Common/Types/Mail/MailStatus';
|
||||
import EmailLogService from 'CommonServer/Services/EmailLogService';
|
||||
|
||||
export default class MailService {
|
||||
|
||||
public static isSMTPConfigValid(obj: JSONObject): boolean {
|
||||
if (!obj['SMTP_USERNAME']) {
|
||||
logger.error('SMTP_USERNAME env var not found');
|
||||
@@ -40,8 +39,8 @@ export default class MailService {
|
||||
if (!Email.isValid(obj['SMTP_EMAIL'].toString())) {
|
||||
logger.error(
|
||||
'SMTP_EMAIL env var ' +
|
||||
obj['SMTP_EMAIL'] +
|
||||
' is not a valid email'
|
||||
obj['SMTP_EMAIL'] +
|
||||
' is not a valid email'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -215,10 +214,10 @@ export default class MailService {
|
||||
mail: EmailMessage,
|
||||
options?:
|
||||
| {
|
||||
projectId?: ObjectID | undefined;
|
||||
emailServer?: EmailServer | undefined;
|
||||
userOnCallLogTimelineId?: ObjectID | undefined;
|
||||
}
|
||||
projectId?: ObjectID | undefined;
|
||||
emailServer?: EmailServer | undefined;
|
||||
userOnCallLogTimelineId?: ObjectID | undefined;
|
||||
}
|
||||
| undefined
|
||||
): Promise<void> {
|
||||
let emailLog: EmailLog | undefined = undefined;
|
||||
@@ -318,15 +317,15 @@ export default class MailService {
|
||||
);
|
||||
}
|
||||
} catch (err: any) {
|
||||
|
||||
let message: string | undefined = err.message;
|
||||
|
||||
if (message === "Unexpected socket close") {
|
||||
message = "Email failed to send. Unexpected socket close. This could mean various things, such as your SMTP server is unreachble, username and password is incorrect, your SMTP server is not configured to accept connections from this IP address, or TLS/SSL is not configured correctly, or ports are not configured correctly."
|
||||
if (message === 'Unexpected socket close') {
|
||||
message =
|
||||
'Email failed to send. Unexpected socket close. This could mean various things, such as your SMTP server is unreachble, username and password is incorrect, your SMTP server is not configured to accept connections from this IP address, or TLS/SSL is not configured correctly, or ports are not configured correctly.';
|
||||
}
|
||||
|
||||
if (!message) {
|
||||
message = "Email failed to send. Unknown error."
|
||||
message = 'Email failed to send. Unknown error.';
|
||||
}
|
||||
|
||||
logger.error(err);
|
||||
@@ -345,8 +344,7 @@ export default class MailService {
|
||||
|
||||
if (emailLog) {
|
||||
emailLog.status = MailStatus.Error;
|
||||
emailLog.statusMessage =
|
||||
message;
|
||||
emailLog.statusMessage = message;
|
||||
|
||||
await EmailLogService.create({
|
||||
data: emailLog,
|
||||
|
||||
@@ -7,7 +7,6 @@ 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',
|
||||
@@ -15,8 +14,8 @@ RunCron(
|
||||
async () => {
|
||||
for (const service of Services) {
|
||||
if (service instanceof DatabaseService) {
|
||||
if (service instanceof BillingInvoiceServiceType) {
|
||||
// skip invoice service because invoices should not be deleted.
|
||||
if (service.doNotAllowDelete) {
|
||||
// marked as do not delete. skip.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user