mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor: Update import statements for TimezoneUtil in multiple files
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
{{> DetailBoxField title="Incident Title:" text=incidentTitle }}
|
||||
{{> DetailBoxField title="Current State: " text=currentState }}
|
||||
{{> DetailBoxField title="Resources Affected: " text=resourcesAffected }}
|
||||
{{> DetailBoxField title="Incident Created At: " text="" }}
|
||||
{{> DetailBoxField title="" text=createdAt }}
|
||||
{{> DetailBoxField title="Incident Declared At: " text="" }}
|
||||
{{> DetailBoxField title="" text=declaredAt }}
|
||||
{{> DetailBoxField title="Severity: " text=incidentSeverity }}
|
||||
{{> DetailBoxField title="Root Cause: " text="" }}
|
||||
{{> DetailBoxField title="" text=rootCause }}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
{{> DetailBoxStart this }}
|
||||
{{> DetailBoxField title=announcementTitle text="" }}
|
||||
{{> DetailBoxField title="" text=announcementDescription }}
|
||||
{{> DetailBoxField title="Posted At: " text="" }}
|
||||
{{> DetailBoxField title="" text=showAnnouncementAt }}
|
||||
{{> DetailBoxEnd this }}
|
||||
|
||||
{{> InfoBlock info=(concat "This is an automated email sent to you because you are subscribed to " statusPageName) }}
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
{{> DetailBoxField title=incidentTitle text="" }}
|
||||
{{> DetailBoxField title="Resources Affected: " text=resourcesAffected }}
|
||||
{{> DetailBoxField title="Severity: " text=incidentSeverity }}
|
||||
{{> DetailBoxField title="Created At: " text="" }}
|
||||
{{> DetailBoxField title="" text=createdAt }}
|
||||
{{> DetailBoxField title="Description: " text="" }}
|
||||
{{> DetailBoxField title="" text=incidentDescription }}
|
||||
{{> DetailBoxEnd this }}
|
||||
|
||||
@@ -63,9 +63,12 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const statusPages: Array<StatusPage> = await StatusPageSubscriberService.getStatusPagesToSendNotification(announcement.statusPages.map((sp: StatusPage) => {
|
||||
return sp.id!;
|
||||
}));
|
||||
const statusPages: Array<StatusPage> =
|
||||
await StatusPageSubscriberService.getStatusPagesToSendNotification(
|
||||
announcement.statusPages.map((sp: StatusPage) => {
|
||||
return sp.id!;
|
||||
}),
|
||||
);
|
||||
|
||||
await StatusPageAnnouncementService.updateOneById({
|
||||
id: announcement.id!,
|
||||
@@ -79,9 +82,7 @@ RunCron(
|
||||
});
|
||||
|
||||
for (const statuspage of statusPages) {
|
||||
|
||||
try {
|
||||
|
||||
if (!statuspage.id) {
|
||||
continue;
|
||||
}
|
||||
@@ -95,18 +96,15 @@ RunCron(
|
||||
},
|
||||
);
|
||||
|
||||
const statusPageURL: string = await StatusPageService.getStatusPageURL(
|
||||
statuspage.id,
|
||||
);
|
||||
const statusPageURL: string =
|
||||
await StatusPageService.getStatusPageURL(statuspage.id);
|
||||
const statusPageName: string =
|
||||
statuspage.pageTitle || statuspage.name || "Status Page";
|
||||
|
||||
// Send email to Email subscribers.
|
||||
|
||||
for (const subscriber of subscribers) {
|
||||
|
||||
try {
|
||||
|
||||
if (!subscriber._id) {
|
||||
continue;
|
||||
}
|
||||
@@ -134,9 +132,10 @@ RunCron(
|
||||
// send sms here.
|
||||
SmsService.sendSms(sms, {
|
||||
projectId: statuspage.projectId,
|
||||
customTwilioConfig: ProjectCallSMSConfigService.toTwilioConfig(
|
||||
statuspage.callSmsConfig,
|
||||
),
|
||||
customTwilioConfig:
|
||||
ProjectCallSMSConfigService.toTwilioConfig(
|
||||
statuspage.callSmsConfig,
|
||||
),
|
||||
}).catch((err: Error) => {
|
||||
logger.error(err);
|
||||
});
|
||||
@@ -148,21 +147,16 @@ RunCron(
|
||||
MailService.sendMail(
|
||||
{
|
||||
toEmail: subscriber.subscriberEmail,
|
||||
templateType: EmailTemplateType.SubscriberAnnouncementCreated,
|
||||
templateType:
|
||||
EmailTemplateType.SubscriberAnnouncementCreated,
|
||||
vars: {
|
||||
statusPageName: statusPageName,
|
||||
statusPageUrl: statusPageURL,
|
||||
showAnnouncementAt: OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones(
|
||||
{
|
||||
date: announcement.showAnnouncementAt!,
|
||||
timezones: statuspage.subscriberTimezones || [],
|
||||
},
|
||||
),
|
||||
logoUrl: statuspage.logoFileId
|
||||
? new URL(httpProtocol, host)
|
||||
.addRoute(FileRoute)
|
||||
.addRoute("/image/" + statuspage.logoFileId)
|
||||
.toString()
|
||||
.addRoute(FileRoute)
|
||||
.addRoute("/image/" + statuspage.logoFileId)
|
||||
.toString()
|
||||
: "",
|
||||
isPublicStatusPage: statuspage.isPublicStatusPage
|
||||
? "true"
|
||||
|
||||
@@ -78,9 +78,6 @@ RunCron(
|
||||
|
||||
// get status page resources from monitors.
|
||||
|
||||
|
||||
const incidentIdentifiedDate: Date = await IncidentService.getIncidentIdentifiedDate(incident.id!);
|
||||
|
||||
const statusPageResources: Array<StatusPageResource> =
|
||||
await StatusPageResourceService.findBy({
|
||||
query: {
|
||||
@@ -131,7 +128,6 @@ RunCron(
|
||||
);
|
||||
|
||||
for (const statuspage of statusPages) {
|
||||
|
||||
try {
|
||||
if (!statuspage.id) {
|
||||
continue;
|
||||
@@ -146,9 +142,8 @@ RunCron(
|
||||
},
|
||||
);
|
||||
|
||||
const statusPageURL: string = await StatusPageService.getStatusPageURL(
|
||||
statuspage.id,
|
||||
);
|
||||
const statusPageURL: string =
|
||||
await StatusPageService.getStatusPageURL(statuspage.id);
|
||||
const statusPageName: string =
|
||||
statuspage.pageTitle || statuspage.name || "Status Page";
|
||||
|
||||
@@ -162,9 +157,7 @@ RunCron(
|
||||
.join(", ") || "None";
|
||||
|
||||
for (const subscriber of subscribers) {
|
||||
|
||||
try {
|
||||
|
||||
if (!subscriber._id) {
|
||||
continue;
|
||||
}
|
||||
@@ -172,7 +165,8 @@ RunCron(
|
||||
const shouldNotifySubscriber: boolean =
|
||||
StatusPageSubscriberService.shouldSendNotification({
|
||||
subscriber: subscriber,
|
||||
statusPageResources: statusPageToResources[statuspage._id!] || [],
|
||||
statusPageResources:
|
||||
statusPageToResources[statuspage._id!] || [],
|
||||
statusPage: statuspage,
|
||||
});
|
||||
|
||||
@@ -187,11 +181,8 @@ RunCron(
|
||||
).toString();
|
||||
|
||||
if (subscriber.subscriberEmail) {
|
||||
|
||||
// send email here.
|
||||
|
||||
|
||||
|
||||
MailService.sendMail(
|
||||
{
|
||||
toEmail: subscriber.subscriberEmail,
|
||||
@@ -201,21 +192,16 @@ RunCron(
|
||||
statusPageUrl: statusPageURL,
|
||||
logoUrl: statuspage.logoFileId
|
||||
? new URL(httpProtocol, host)
|
||||
.addRoute(FileRoute)
|
||||
.addRoute("/image/" + statuspage.logoFileId)
|
||||
.toString()
|
||||
.addRoute(FileRoute)
|
||||
.addRoute("/image/" + statuspage.logoFileId)
|
||||
.toString()
|
||||
: "",
|
||||
isPublicStatusPage: statuspage.isPublicStatusPage
|
||||
? "true"
|
||||
: "false",
|
||||
resourcesAffected: resourcesAffectedString,
|
||||
createdAt: OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones(
|
||||
{
|
||||
date: incidentIdentifiedDate,
|
||||
timezones: statuspage.subscriberTimezones || [],
|
||||
},
|
||||
),
|
||||
incidentSeverity: incident.incidentSeverity?.name || " - ",
|
||||
incidentSeverity:
|
||||
incident.incidentSeverity?.name || " - ",
|
||||
incidentTitle: incident.title || "",
|
||||
incidentDescription: await Markdown.convertToHTML(
|
||||
incident.description || "",
|
||||
@@ -243,8 +229,9 @@ RunCron(
|
||||
|
||||
Title: ${incident.title || ""}
|
||||
|
||||
Severity: ${incident.incidentSeverity?.name || " - "
|
||||
}
|
||||
Severity: ${
|
||||
incident.incidentSeverity?.name || " - "
|
||||
}
|
||||
|
||||
Resources Affected: ${resourcesAffectedString}
|
||||
|
||||
@@ -258,9 +245,10 @@ RunCron(
|
||||
// send sms here.
|
||||
SmsService.sendSms(sms, {
|
||||
projectId: statuspage.projectId,
|
||||
customTwilioConfig: ProjectCallSMSConfigService.toTwilioConfig(
|
||||
statuspage.callSmsConfig,
|
||||
),
|
||||
customTwilioConfig:
|
||||
ProjectCallSMSConfigService.toTwilioConfig(
|
||||
statuspage.callSmsConfig,
|
||||
),
|
||||
}).catch((err: Error) => {
|
||||
logger.error(err);
|
||||
});
|
||||
|
||||
@@ -52,6 +52,9 @@ RunCron(
|
||||
});
|
||||
|
||||
for (const incident of incidents) {
|
||||
const incidentIdentifiedDate: Date =
|
||||
await IncidentService.getIncidentIdentifiedDate(incident.id!);
|
||||
|
||||
await IncidentService.updateOneById({
|
||||
id: incident.id!,
|
||||
data: {
|
||||
@@ -79,9 +82,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
for (const user of owners) {
|
||||
|
||||
const vars: Dictionary<string> = {
|
||||
incidentTitle: incident.title!,
|
||||
projectName: incident.project!.name!,
|
||||
@@ -97,8 +98,8 @@ RunCron(
|
||||
})
|
||||
.join(", ") || "None",
|
||||
incidentSeverity: incident.incidentSeverity!.name!,
|
||||
createdAt: OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
|
||||
date: incident.createdAt!,
|
||||
declaredAt: OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
|
||||
date: incidentIdentifiedDate,
|
||||
timezones: user.timezone ? [user.timezone] : [],
|
||||
}),
|
||||
rootCause:
|
||||
@@ -110,10 +111,10 @@ RunCron(
|
||||
)
|
||||
).toString(),
|
||||
};
|
||||
|
||||
|
||||
if (doesResourceHasOwners === true) {
|
||||
vars["isOwner"] = "true";
|
||||
}
|
||||
}
|
||||
|
||||
const emailMessage: EmailEnvelope = {
|
||||
templateType: EmailTemplateType.IncidentOwnerResourceCreated,
|
||||
|
||||
@@ -38,6 +38,7 @@ RunCron(
|
||||
select: {
|
||||
_id: true,
|
||||
createdAt: true,
|
||||
startsAt: true,
|
||||
projectId: true,
|
||||
project: {
|
||||
name: true,
|
||||
@@ -101,7 +102,7 @@ RunCron(
|
||||
),
|
||||
stateChangedAt:
|
||||
OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
|
||||
date: scheduledMaintenanceStateTimeline.createdAt!,
|
||||
date: scheduledMaintenanceStateTimeline.startsAt!,
|
||||
timezones: user.timezone ? [user.timezone] : [],
|
||||
}),
|
||||
scheduledMaintenanceViewLink: (
|
||||
|
||||
@@ -1012,10 +1012,10 @@ export default class OneUptimeDate {
|
||||
}
|
||||
|
||||
public static getZoneAbbrByTimezone(timezone: Timezone): string {
|
||||
let zoneAbbr = moment.tz(timezone).zoneAbbr();
|
||||
let zoneAbbr: string = moment.tz(timezone).zoneAbbr();
|
||||
|
||||
if(zoneAbbr.startsWith('+') || zoneAbbr.startsWith('-')) {
|
||||
zoneAbbr = 'GMT' + zoneAbbr;
|
||||
if (zoneAbbr.startsWith("+") || zoneAbbr.startsWith("-")) {
|
||||
zoneAbbr = "GMT" + zoneAbbr;
|
||||
}
|
||||
|
||||
return zoneAbbr;
|
||||
@@ -1059,7 +1059,7 @@ export default class OneUptimeDate {
|
||||
return moment(date["value"]).toDate();
|
||||
}
|
||||
|
||||
throw new BadDataException("Invalid date: "+date.toString());
|
||||
throw new BadDataException("Invalid date: " + date.toString());
|
||||
}
|
||||
|
||||
public static asDateForDatabaseQuery(date: string | Date): string {
|
||||
|
||||
@@ -269,22 +269,22 @@ export class Service extends DatabaseService<Model> {
|
||||
return createdItem;
|
||||
}
|
||||
|
||||
|
||||
public async getIncidentIdentifiedDate(incidentId: ObjectID): Promise<Date> {
|
||||
const timeline: IncidentStateTimeline | null = await IncidentStateTimelineService.findOneBy({
|
||||
query: {
|
||||
incidentId: incidentId,
|
||||
},
|
||||
select: {
|
||||
startsAt: true,
|
||||
},
|
||||
sort: {
|
||||
startsAt: SortOrder.Ascending,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
const timeline: IncidentStateTimeline | null =
|
||||
await IncidentStateTimelineService.findOneBy({
|
||||
query: {
|
||||
incidentId: incidentId,
|
||||
},
|
||||
select: {
|
||||
startsAt: true,
|
||||
},
|
||||
sort: {
|
||||
startsAt: SortOrder.Ascending,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!timeline || !timeline.startsAt) {
|
||||
throw new BadDataException("Incident identified date not found.");
|
||||
|
||||
@@ -177,10 +177,9 @@ router.get(
|
||||
count: monitorProbesCount.toNumber(),
|
||||
nextPingAt: firstMonitorToBeFetched?.nextPingAt,
|
||||
friendlyNextPingAt: firstMonitorToBeFetched?.nextPingAt
|
||||
? OneUptimeDate.getDateAsFormattedStringInMultipleTimezones(
|
||||
{date: firstMonitorToBeFetched?.nextPingAt
|
||||
},
|
||||
)
|
||||
? OneUptimeDate.getDateAsFormattedStringInMultipleTimezones({
|
||||
date: firstMonitorToBeFetched?.nextPingAt,
|
||||
})
|
||||
: "",
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user