mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 14:49:07 +00:00
Refactor ProbeMonitorResponse and TelemetryIngest middleware
This commit is contained in:
parent
15f5cd540c
commit
f03f4c67eb
@ -913,20 +913,36 @@ export default class ProbeMonitorResponseService {
|
||||
return null; // if true then return null.
|
||||
}
|
||||
|
||||
if (input.monitor.monitorType === MonitorType.Server) {
|
||||
if (input.monitor.monitorType === MonitorType.Server && (input.dataToProcess as ServerMonitorResponse).onlyCheckRequestReceivedAt) {
|
||||
|
||||
const lastCheckTime: Date = (
|
||||
input.dataToProcess as ServerMonitorResponse
|
||||
).requestReceivedAt;
|
||||
|
||||
const differenceInMinutes: number =
|
||||
OneUptimeDate.getDifferenceInMinutes(
|
||||
lastCheckTime,
|
||||
OneUptimeDate.getCurrentDate()
|
||||
);
|
||||
|
||||
|
||||
const offlineIfNotCheckedInMinutes: number = 2;
|
||||
|
||||
if (
|
||||
input.criteriaFilter.checkOn === CheckOn.IsOnline &&
|
||||
input.criteriaFilter.filterType === FilterType.True
|
||||
input.criteriaFilter.filterType === FilterType.True && differenceInMinutes <= offlineIfNotCheckedInMinutes
|
||||
) {
|
||||
|
||||
if ((input.dataToProcess as ProbeMonitorResponse).isOnline) {
|
||||
return 'Monitor is online.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
input.criteriaFilter.checkOn === CheckOn.IsOnline &&
|
||||
input.criteriaFilter.filterType === FilterType.False
|
||||
input.criteriaFilter.filterType === FilterType.False && differenceInMinutes > offlineIfNotCheckedInMinutes
|
||||
) {
|
||||
if (!(input.dataToProcess as ProbeMonitorResponse).isOnline) {
|
||||
return 'Monitor is offline.';
|
||||
|
@ -50,6 +50,7 @@ export default class TelemetryIngest {
|
||||
'service-token',
|
||||
serviceTokenInHeader as string
|
||||
);
|
||||
|
||||
const serviceProjectId: string | null = await GlobalCache.getString(
|
||||
'service-project-id',
|
||||
serviceTokenInHeader as string
|
||||
|
Loading…
Reference in New Issue
Block a user