[task-340] [int]
This commit is contained in:
parent
358f33b18a
commit
1ade4dec2a
345
source/conf.ts
345
source/conf.ts
|
@ -24,6 +24,24 @@ along with »munin«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace _munin.conf
|
namespace _munin.conf
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_reminder_raw = {
|
||||||
|
frequency : (
|
||||||
|
"hourly"
|
||||||
|
|
|
||||||
|
"daily"
|
||||||
|
|
|
||||||
|
"weekly"
|
||||||
|
|
|
||||||
|
"monthly"
|
||||||
|
);
|
||||||
|
offset : int;
|
||||||
|
from : int;
|
||||||
|
to : int;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
type type_conf_v1 = {
|
type type_conf_v1 = {
|
||||||
|
@ -236,7 +254,71 @@ namespace _munin.conf
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export type type_conf = type_conf_v4;
|
type type_conf_v5 = {
|
||||||
|
sources : Array<
|
||||||
|
(
|
||||||
|
{
|
||||||
|
kind : "ical_feed";
|
||||||
|
data : {
|
||||||
|
url : string;
|
||||||
|
filtration : {
|
||||||
|
category_whitelist : (null | Array<string>);
|
||||||
|
category_blacklist : (null | Array<string>);
|
||||||
|
title_whitelist : (null | Array<string>);
|
||||||
|
title_blacklist : (null | Array<string>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
>;
|
||||||
|
targets : Array<
|
||||||
|
(
|
||||||
|
{
|
||||||
|
kind : "email";
|
||||||
|
data : {
|
||||||
|
smtp_host : string;
|
||||||
|
smtp_port : int;
|
||||||
|
smtp_username : string;
|
||||||
|
smtp_password : string;
|
||||||
|
sender : string;
|
||||||
|
receivers : Array<string>;
|
||||||
|
hide_tags : boolean;
|
||||||
|
/**
|
||||||
|
* in hours
|
||||||
|
*/
|
||||||
|
reminders : Array<type_reminder_raw>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
|
kind : "telegram_bot";
|
||||||
|
data : {
|
||||||
|
bot_token : string;
|
||||||
|
chat_id : int;
|
||||||
|
hide_tags : boolean;
|
||||||
|
/**
|
||||||
|
* in hours
|
||||||
|
*/
|
||||||
|
reminders : Array<type_reminder_raw>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
>;
|
||||||
|
settings : {
|
||||||
|
interval : float;
|
||||||
|
};
|
||||||
|
labels : {
|
||||||
|
head : string;
|
||||||
|
title : string;
|
||||||
|
time : string;
|
||||||
|
location : string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export type type_conf = type_conf_v5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -396,6 +478,65 @@ namespace _munin.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function convert_from_v4(
|
||||||
|
conf_v4 : type_conf_v4
|
||||||
|
) : type_conf_v5
|
||||||
|
{
|
||||||
|
const map_reminder = hours => ({
|
||||||
|
"frequency": "hourly",
|
||||||
|
"offset": 0,
|
||||||
|
"from": hours,
|
||||||
|
"to": (hours + 1),
|
||||||
|
} as type_reminder_raw);
|
||||||
|
return {
|
||||||
|
"sources": conf_v4.sources,
|
||||||
|
"targets": conf_v4.targets.map(
|
||||||
|
target => {
|
||||||
|
switch (target.kind) {
|
||||||
|
case "email": {
|
||||||
|
return {
|
||||||
|
"kind": "email",
|
||||||
|
"data": {
|
||||||
|
"smtp_host": target.data.smtp_host,
|
||||||
|
"smtp_port": target.data.smtp_port,
|
||||||
|
"smtp_username": target.data.smtp_username,
|
||||||
|
"smtp_password": target.data.smtp_password,
|
||||||
|
"sender": target.data.sender,
|
||||||
|
"receivers": target.data.receivers,
|
||||||
|
"hide_tags": target.data.hide_tags,
|
||||||
|
"reminders": target.data.reminders.map(map_reminder),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "telegram_bot": {
|
||||||
|
return {
|
||||||
|
"kind": "telegram_bot",
|
||||||
|
"data": {
|
||||||
|
"bot_token": target.data.bot_token,
|
||||||
|
"chat_id": target.data.chat_id,
|
||||||
|
"hide_tags": target.data.hide_tags,
|
||||||
|
"reminders": target.data.reminders.map(map_reminder),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
// return target;
|
||||||
|
throw (new Error("unhandled target kind: " + String(target)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
"settings": conf_v4.settings,
|
||||||
|
"labels": conf_v4.labels,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
function schema_source_kalender_digital(
|
function schema_source_kalender_digital(
|
||||||
|
@ -546,6 +687,136 @@ namespace _munin.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function schema_sources(
|
||||||
|
version : string
|
||||||
|
) : lib_plankton.conf.type_schema
|
||||||
|
{
|
||||||
|
switch (version) {
|
||||||
|
case "1": {
|
||||||
|
return {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"nullable": false,
|
||||||
|
"anyOf": [
|
||||||
|
schema_source_kalender_digital(version),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
case "2": {
|
||||||
|
return {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"nullable": false,
|
||||||
|
"anyOf": [
|
||||||
|
schema_source_ical_feed(version),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function schema_reminder(
|
||||||
|
version : string
|
||||||
|
) : lib_plankton.conf.type_schema
|
||||||
|
{
|
||||||
|
switch (version)
|
||||||
|
{
|
||||||
|
case "1":
|
||||||
|
case "2":
|
||||||
|
case "3":
|
||||||
|
case "4":
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"type": "integer",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case "5":
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"frequency": {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"hourly",
|
||||||
|
"daily",
|
||||||
|
"weekly",
|
||||||
|
"monthly",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"offset": {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "integer",
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"from": {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"to": {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"frequency",
|
||||||
|
"from",
|
||||||
|
"to",
|
||||||
|
]
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function default_reminder(
|
||||||
|
version : string
|
||||||
|
) : any
|
||||||
|
{
|
||||||
|
switch (version)
|
||||||
|
{
|
||||||
|
case "1":
|
||||||
|
case "2":
|
||||||
|
case "3":
|
||||||
|
case "4":
|
||||||
|
{
|
||||||
|
return [24];
|
||||||
|
}
|
||||||
|
case "5":
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"frequency": "hourly",
|
||||||
|
"from": 24,
|
||||||
|
"to": 25
|
||||||
|
}
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
function schema_target_email(
|
function schema_target_email(
|
||||||
|
@ -602,11 +873,8 @@ namespace _munin.conf
|
||||||
"reminders": {
|
"reminders": {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": schema_reminder(version),
|
||||||
"nullable": false,
|
"default": default_reminder(version),
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"default": [24.0],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -628,44 +896,6 @@ namespace _munin.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function schema_sources(
|
|
||||||
version : string
|
|
||||||
) : lib_plankton.conf.type_schema
|
|
||||||
{
|
|
||||||
switch (version) {
|
|
||||||
case "1": {
|
|
||||||
return {
|
|
||||||
"nullable": false,
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"nullable": false,
|
|
||||||
"anyOf": [
|
|
||||||
schema_source_kalender_digital(version),
|
|
||||||
],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
case "2": {
|
|
||||||
return {
|
|
||||||
"nullable": false,
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"nullable": false,
|
|
||||||
"anyOf": [
|
|
||||||
schema_source_ical_feed(version),
|
|
||||||
],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
function schema_target_telegram_bot(
|
function schema_target_telegram_bot(
|
||||||
|
@ -701,11 +931,8 @@ namespace _munin.conf
|
||||||
"reminders": {
|
"reminders": {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": schema_reminder(version),
|
||||||
"nullable": false,
|
"default": default_reminder(version),
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"default": [24.0],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -737,13 +964,18 @@ namespace _munin.conf
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"anyOf": (() => {
|
"anyOf": (() => {
|
||||||
switch (version) {
|
switch (version) {
|
||||||
default: {
|
case "1":
|
||||||
|
case "2":
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
schema_target_telegram_bot(version),
|
schema_target_telegram_bot(version),
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "3": {
|
case "4":
|
||||||
|
case "5":
|
||||||
|
default:
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
schema_target_email(version),
|
schema_target_email(version),
|
||||||
schema_target_telegram_bot(version),
|
schema_target_telegram_bot(version),
|
||||||
|
@ -824,7 +1056,7 @@ namespace _munin.conf
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export function schema(
|
export function schema(
|
||||||
version : string = "4"
|
version : string = "5"
|
||||||
) : lib_plankton.conf.type_schema
|
) : lib_plankton.conf.type_schema
|
||||||
{
|
{
|
||||||
switch (version) {
|
switch (version) {
|
||||||
|
@ -852,7 +1084,9 @@ namespace _munin.conf
|
||||||
}
|
}
|
||||||
case "2":
|
case "2":
|
||||||
case "3":
|
case "3":
|
||||||
case "4": {
|
case "4":
|
||||||
|
case "5":
|
||||||
|
{
|
||||||
return {
|
return {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -887,7 +1121,8 @@ namespace _munin.conf
|
||||||
"1": {"target": "2", "function": convert_from_v1},
|
"1": {"target": "2", "function": convert_from_v1},
|
||||||
"2": {"target": "3", "function": convert_from_v2},
|
"2": {"target": "3", "function": convert_from_v2},
|
||||||
"3": {"target": "4", "function": convert_from_v3},
|
"3": {"target": "4", "function": convert_from_v3},
|
||||||
"4": null,
|
"4": {"target": "5", "function": convert_from_v4},
|
||||||
|
"5": null,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -925,7 +1160,7 @@ namespace _munin.conf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return (conf_raw.content as type_conf_v4);
|
return (conf_raw.content as type_conf_v5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
194
source/logic.ts
194
source/logic.ts
|
@ -21,45 +21,6 @@ along with »munin«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace _munin.logic
|
namespace _munin.logic
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Tests schreiben
|
|
||||||
*/
|
|
||||||
function shall_remind(
|
|
||||||
event : _munin.type_event,
|
|
||||||
reminder : type_reminder,
|
|
||||||
{
|
|
||||||
"pit": pit = lib_plankton.pit.now(),
|
|
||||||
"interval": interval = 1,
|
|
||||||
} : {
|
|
||||||
pit ?: lib_plankton.pit.type_pit;
|
|
||||||
interval ?: int;
|
|
||||||
} = {
|
|
||||||
}
|
|
||||||
) : boolean
|
|
||||||
{
|
|
||||||
const window_from : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
|
||||||
pit,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
const window_to : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
|
||||||
pit,
|
|
||||||
interval
|
|
||||||
);
|
|
||||||
const event_begin : lib_plankton.pit.type_pit = lib_plankton.pit.from_datetime(
|
|
||||||
event.begin
|
|
||||||
);
|
|
||||||
const reminder_time : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
|
||||||
event_begin,
|
|
||||||
(-reminder)
|
|
||||||
);
|
|
||||||
return lib_plankton.pit.is_between(
|
|
||||||
reminder_time,
|
|
||||||
window_from,
|
|
||||||
window_to
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
function frequency_anchor(
|
function frequency_anchor(
|
||||||
|
@ -90,7 +51,7 @@ namespace _munin.logic
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export function reminder_due(
|
export function reminder_due(
|
||||||
reminder : type_reminder_new,
|
reminder : type_reminder,
|
||||||
{
|
{
|
||||||
"pit": pit = lib_plankton.pit.now(),
|
"pit": pit = lib_plankton.pit.now(),
|
||||||
"interval": interval = 1,
|
"interval": interval = 1,
|
||||||
|
@ -105,35 +66,46 @@ namespace _munin.logic
|
||||||
reminder.frequency,
|
reminder.frequency,
|
||||||
{"pit": pit}
|
{"pit": pit}
|
||||||
);
|
);
|
||||||
// 0 ≤ ((p - a(p)) - o) < i
|
const window_from : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
||||||
const x : float = (
|
anchor,
|
||||||
(
|
(reminder.offset + 0)
|
||||||
(
|
|
||||||
lib_plankton.pit.to_unix_timestamp(pit)
|
|
||||||
-
|
|
||||||
lib_plankton.pit.to_unix_timestamp(anchor)
|
|
||||||
)
|
|
||||||
/
|
|
||||||
(60 * 60)
|
|
||||||
)
|
|
||||||
-
|
|
||||||
reminder.offset
|
|
||||||
);
|
);
|
||||||
return ((0 <= x) && (x < interval));
|
const window_to : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
||||||
|
anchor,
|
||||||
|
(reminder.offset + interval)
|
||||||
|
);
|
||||||
|
const result : boolean = lib_plankton.pit.is_between(
|
||||||
|
pit,
|
||||||
|
window_from,
|
||||||
|
window_to
|
||||||
|
);
|
||||||
|
lib_plankton.log._info(
|
||||||
|
"munin.logic.reminder_due",
|
||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"reminder": reminder,
|
||||||
|
"datetime": lib_plankton.pit.to_datetime(pit),
|
||||||
|
"interval": interval,
|
||||||
|
"anchor": lib_plankton.pit.to_datetime(anchor),
|
||||||
|
"window_from": lib_plankton.pit.to_datetime(window_from),
|
||||||
|
"window_to": lib_plankton.pit.to_datetime(window_to),
|
||||||
|
"result": result,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export function reminder_event_in_window(
|
export function reminder_event_in_window(
|
||||||
reminder : type_reminder_new,
|
reminder : type_reminder,
|
||||||
event : _munin.type_event,
|
event : _munin.type_event,
|
||||||
{
|
{
|
||||||
"pit": pit = lib_plankton.pit.now(),
|
"pit": pit = lib_plankton.pit.now(),
|
||||||
"interval": interval = 1,
|
|
||||||
} : {
|
} : {
|
||||||
pit ?: lib_plankton.pit.type_pit;
|
pit ?: lib_plankton.pit.type_pit;
|
||||||
interval ?: int;
|
|
||||||
} = {
|
} = {
|
||||||
}
|
}
|
||||||
) : boolean
|
) : boolean
|
||||||
|
@ -153,41 +125,26 @@ namespace _munin.logic
|
||||||
const event_begin : lib_plankton.pit.type_pit = lib_plankton.pit.from_datetime(
|
const event_begin : lib_plankton.pit.type_pit = lib_plankton.pit.from_datetime(
|
||||||
event.begin
|
event.begin
|
||||||
);
|
);
|
||||||
return lib_plankton.pit.is_between(
|
const result : boolean = lib_plankton.pit.is_between(
|
||||||
event_begin,
|
event_begin,
|
||||||
window_from,
|
window_from,
|
||||||
window_to
|
window_to
|
||||||
);
|
);
|
||||||
}
|
lib_plankton.log._info(
|
||||||
|
"munin.logic.reminder_event_in_window",
|
||||||
|
{
|
||||||
/**
|
"details": {
|
||||||
*/
|
"reminder": reminder,
|
||||||
function shall_remind_new(
|
"event": event,
|
||||||
reminder : type_reminder_new,
|
"datetime": lib_plankton.pit.to_datetime(pit),
|
||||||
event : _munin.type_event,
|
"anchor": lib_plankton.pit.to_datetime(anchor),
|
||||||
{
|
"window_from": lib_plankton.pit.to_datetime(window_from),
|
||||||
"pit": pit = lib_plankton.pit.now(),
|
"window_to": lib_plankton.pit.to_datetime(window_to),
|
||||||
"interval": interval = 1,
|
"result": result,
|
||||||
} : {
|
}
|
||||||
pit ?: lib_plankton.pit.type_pit;
|
}
|
||||||
interval ?: int;
|
|
||||||
} = {
|
|
||||||
}
|
|
||||||
) : boolean
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
reminder_due(
|
|
||||||
reminder,
|
|
||||||
{"pit": pit, "interval": interval}
|
|
||||||
)
|
|
||||||
&&
|
|
||||||
reminder_event_in_window(
|
|
||||||
reminder,
|
|
||||||
event,
|
|
||||||
{"pit": pit, "interval": interval}
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,17 +168,30 @@ namespace _munin.logic
|
||||||
.reduce((x, y) => x.concat(y), [])
|
.reduce((x, y) => x.concat(y), [])
|
||||||
);
|
);
|
||||||
for (const target of targets) {
|
for (const target of targets) {
|
||||||
for (const reminder_hours of target.reminders) {
|
for (const reminder of target.reminders) {
|
||||||
for (const event of events) {
|
const due : boolean = reminder_due(
|
||||||
const remind : boolean = shall_remind(
|
reminder,
|
||||||
event,
|
{
|
||||||
reminder_hours,
|
"pit": now,
|
||||||
{
|
"interval": conf.settings.interval,
|
||||||
"pit": now,
|
}
|
||||||
"interval": conf.settings.interval,
|
);
|
||||||
}
|
if (! due)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const events_matching : Array<_munin.type_event> = events.filter(
|
||||||
|
event => reminder_event_in_window(
|
||||||
|
reminder,
|
||||||
|
event,
|
||||||
|
{
|
||||||
|
"pit": now,
|
||||||
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if (! remind) {
|
if (events_matching.length <= 0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -229,7 +199,7 @@ namespace _munin.logic
|
||||||
"munin.remind.do",
|
"munin.remind.do",
|
||||||
{
|
{
|
||||||
"details": {
|
"details": {
|
||||||
"event": event,
|
"events": events,
|
||||||
"target": target.show(),
|
"target": target.show(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,18 +208,24 @@ namespace _munin.logic
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
/**
|
||||||
await target.send(conf.labels, event);
|
* @todo bundle?
|
||||||
}
|
*/
|
||||||
catch (error) {
|
for (const event of events_matching)
|
||||||
lib_plankton.log.error(
|
{
|
||||||
"munin.remind.error",
|
try {
|
||||||
{
|
await target.send(conf.labels, event);
|
||||||
"details": {
|
}
|
||||||
"message": String(error),
|
catch (error) {
|
||||||
|
lib_plankton.log.error(
|
||||||
|
"munin.remind.error",
|
||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"message": String(error),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,8 +158,9 @@ namespace _munin
|
||||||
"data": {
|
"data": {
|
||||||
"target": "stdout",
|
"target": "stdout",
|
||||||
"format": {
|
"format": {
|
||||||
"kind": "human_readable",
|
"kind": "jsonl",
|
||||||
"data": {
|
"data": {
|
||||||
|
"structured": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,7 @@ namespace _munin.targets.email
|
||||||
sender : string;
|
sender : string;
|
||||||
receivers : Array<string>;
|
receivers : Array<string>;
|
||||||
hide_tags : boolean;
|
hide_tags : boolean;
|
||||||
/**
|
reminders : Array<_munin.type_reminder>;
|
||||||
* in hours
|
|
||||||
*/
|
|
||||||
reminders : Array<int>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace _munin.targets.telegram_bot
|
||||||
bot_token : string;
|
bot_token : string;
|
||||||
chat_id : int;
|
chat_id : int;
|
||||||
hide_tags : boolean;
|
hide_tags : boolean;
|
||||||
reminders : Array<int>;
|
reminders : Array<_munin.type_reminder>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,6 @@ namespace _munin.test
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pit": datetime_to_pit(testcase.input.datetime),
|
"pit": datetime_to_pit(testcase.input.datetime),
|
||||||
"interval": testcase.input.interval,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -67,15 +67,8 @@ namespace _munin
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo rename
|
* @todo rename
|
||||||
* @todo extend
|
|
||||||
*/
|
*/
|
||||||
export type type_reminder = int;
|
export type type_reminder = {
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo rename
|
|
||||||
*/
|
|
||||||
export type type_reminder_new = {
|
|
||||||
frequency : enum_frequency;
|
frequency : enum_frequency;
|
||||||
offset : int;
|
offset : int;
|
||||||
from : int;
|
from : int;
|
||||||
|
|
Loading…
Reference in a new issue