CI / test (push) Successful in 2m34s
- Filtres avancés: drop, set_priority, add_tag avec wildcard * (filter_outgoing.v) - Notifications structurées: click_url + actions (ntfy.v + sources/event.v) - Webhook sortant: Slack, Discord, JSON (filter_outgoing.v) - Fichier d'état: persistance poll_state + silence_until (filter_outgoing.v) - Config: sections filters, outgoing, state (config.v) - Tests: 9 nouveaux tests unitaires (filter_outgoing_test.v) - Docs: ROADMAP Phase 5 4/8, version 0.5.0
124 lines
3.4 KiB
V
124 lines
3.4 KiB
V
module sources
|
|
|
|
pub struct Event {
|
|
pub mut:
|
|
source string
|
|
name string
|
|
topic string
|
|
priority int
|
|
tags []string
|
|
message string
|
|
raw string
|
|
click_url string // v0.5: URL opened when notification is clicked
|
|
actions []Action // v0.5: Ntfy action buttons
|
|
}
|
|
|
|
pub fn (e Event) clone() Event {
|
|
return Event{
|
|
source: e.source
|
|
name: e.name
|
|
topic: e.topic
|
|
priority: e.priority
|
|
tags: e.tags.clone()
|
|
message: e.message
|
|
raw: e.raw
|
|
click_url: e.click_url
|
|
actions: e.actions.clone()
|
|
}
|
|
}
|
|
|
|
pub struct Action {
|
|
pub:
|
|
action string // view, broadcast, http
|
|
label string
|
|
url string
|
|
clear bool // whether to dismiss notification after action
|
|
}
|
|
|
|
pub struct GiteaSource {
|
|
pub mut:
|
|
name string @[json: 'name']
|
|
webhook_path string @[json: 'webhook_path']
|
|
topic string @[json: 'topic']
|
|
template string @[json: 'template']
|
|
priority_map map[string]int @[json: 'priority_map']
|
|
tags []string @[json: 'tags']
|
|
repo string @[json: 'repo']
|
|
}
|
|
|
|
pub struct UptimeKumaState {
|
|
pub mut:
|
|
priority int @[json: 'priority']
|
|
tags []string @[json: 'tags']
|
|
}
|
|
|
|
pub struct UptimeKumaSource {
|
|
pub mut:
|
|
name string @[json: 'name']
|
|
webhook_path string @[json: 'webhook_path']
|
|
topic string @[json: 'topic']
|
|
template string @[json: 'template']
|
|
priority_map map[string]int @[json: 'priority_map']
|
|
tags []string @[json: 'tags']
|
|
state_map map[string]UptimeKumaState @[json: 'state_map']
|
|
}
|
|
|
|
pub struct DockerSource {
|
|
pub mut:
|
|
name string @[json: 'name']
|
|
topic string @[json: 'topic']
|
|
template string @[json: 'template']
|
|
priority_map map[string]int @[json: 'priority_map']
|
|
tags []string @[json: 'tags']
|
|
hosts []string @[json: 'hosts']
|
|
events []string @[json: 'events']
|
|
}
|
|
|
|
pub struct HttpCheck {
|
|
pub mut:
|
|
url string @[json: 'url']
|
|
topic string @[json: 'topic']
|
|
priority int @[json: 'priority']
|
|
expect_status int @[json: 'expect_status']
|
|
timeout int @[json: 'timeout']
|
|
template string @[json: 'template']
|
|
}
|
|
|
|
pub struct HttpPollSource {
|
|
pub mut:
|
|
name string @[json: 'name']
|
|
interval int @[json: 'interval']
|
|
checks []HttpCheck @[json: 'checks']
|
|
}
|
|
|
|
pub struct CronSource {
|
|
pub mut:
|
|
name string @[json: 'name']
|
|
webhook_path string @[json: 'webhook_path']
|
|
topic string @[json: 'topic']
|
|
template string @[json: 'template']
|
|
priority_map map[string]int @[json: 'priority_map']
|
|
tags []string @[json: 'tags']
|
|
}
|
|
|
|
pub struct GenericSource {
|
|
pub mut:
|
|
name string @[json: 'name']
|
|
webhook_path string @[json: 'webhook_path']
|
|
topic string @[json: 'topic']
|
|
template string @[json: 'template']
|
|
priority_map map[string]int @[json: 'priority_map']
|
|
tags []string @[json: 'tags']
|
|
}
|
|
|
|
// render_source_template applies variable substitution to a template string.
|
|
// Placeholders are {varname}. Shared by all source transformers in this module.
|
|
pub fn render_source_template(template string, vars map[string]string) string {
|
|
mut result := template.clone()
|
|
for key, value in vars {
|
|
placeholder := '{${key}}'
|
|
result = result.replace(placeholder, value)
|
|
}
|
|
return result
|
|
}
|