2.1 KiB
2.1 KiB
017 — Alert definitions & settings persistence
Summary
Foundation for the alerting feature: a persisted AlertRule model plus CRUD,
following the shape Settings already uses for CssEntry/Profiles
(008) — one process-wide list, saved to disk on every
mutation.
An AlertRule has:
- A condition (see 018 for the types and how they're evaluated) — for this ticket, just store it as an opaque, already parsed/validated value; don't implement evaluation here.
- A sink: for now, only
Ntfy { topic: String, server: Option<String> }(serverdefaults tohttps://ntfy.shwhen absent) — modeled as an enum so additional sinks can be added later without reshapingAlertRule. - Bookkeeping:
id,name,enabled: bool.
Scope
AlertRulestruct (or similar) in a newsrc/alerts.rs,Vec<AlertRule>added toSettings(src/settings.rs), persisted the same waycss_entries/profilesalready are.- CRUD methods on
Settings(create/update/delete/list), mirroringimport_css/remove_css's pattern: mutate in memory, thenself.save(...). - HTTP endpoints in
src/api.rsfor CRUD, matching the existing settings endpoints' conventions (routes, status codes, error JSON shape). - Id generation: reuse the approach in
generate_imported_css_id(hash name+content+timestamp) rather than adding auuiddependency.
Acceptance criteria
- Alert rules round-trip through
save/loadlike the rest ofSettings(seeround_trips_through_save_and_loadfor the existing pattern to extend). - CRUD endpoints create, list, update, and delete rules, and reject unknown
ids the same way
CssError::NotFounddoes today. - No evaluation or delivery logic lives here — this ticket only stores rules.