Skip to content

fix(notifications): readable cleanup candidate alerts, no duplicate sends - #488

Merged
jessielw merged 2 commits into
jessielw:devfrom
edmunek:telegram-notifications
Oct 28, 2026
Merged

jessielw merged 2 commits into
jessielw:devfrom
edmunek:telegram-notifications

Conversation

@edmunek

@edmunek edmunek commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Cleanup candidate notifications were hard to read on chat transports, Telegram in particular. This fixes the underlying data issues rather than just the formatting, so Discord and email benefit too.

What was wrong

  • Episodes showed as "Season N". build_cleanup_notification_context never loaded the Episode row and hard coded episode_number: None, so three episodes of one show rendered as three identical "Show · Season 1" lines.
  • Raw library UUIDs in reasons. library.id conditions rendered as Library matches any <uuid> (<uuid>). That condition only scopes the rule; it is not why the item matched.
  • Duplicate messages. notify_admins, notify_users and notify_all_users did not deduplicate destinations, so two accounts pointing at the same chat got every event twice.
  • Literal hyphens on Telegram. Apprise sends Telegram legacy Markdown, which has no list syntax, so - arrived as plain text.

Changes

  • Load episodes and show them as codes, compressing runs: S01E05-E07, S01E10, S02E01.
  • Group candidates per title (one line per show, combined size, biggest first). max_items now counts titles instead of raw rows.
  • Drop scope only conditions (library.id) from reasons. A group shows each rule once without per episode measured values; a single candidate keeps the value, e.g. Days since watched > 7 (8).
  • File names only appear in the top_n_with_reasons detail level.
  • For tgram:// URLs, list markers become bullet glyphs outside code fences.
  • Fan out sends each event once per destination URL.

Before / after (Telegram)

Before:

New Cleanup Candidates Found
2 new cleanup candidates · 2.5 GB reclaimable

- Ted Lasso (2020) · Season 2 · 1.3 GB - Tag tv series episodes (S02E01): Library matches any b539bda9-dab5-47ca-80c1-7444cfdd5228 (b539bda9-dab5-47ca-80c1-7444cfdd5228), Days since watched > 7 (8)
- Ted Lasso (2020) · Season 1 · 1.2 GB - Tag tv series episodes (S01E10): Library matches any b539bda9-dab5-47ca-80c1-7444cfdd5228 (b539bda9-dab5-47ca-80c1-7444cfdd5228), Days since watched > 7 (8)

After:

New Cleanup Candidates Found
2 new cleanup candidates · 2.6 GB reclaimable

• Ted Lasso (2020) · S02E02-E03 · 2.6 GB
    ◦ Days since watched > 7

Tests

New tests in tests/test_notification_formatting.py and tests/test_notification_delivery.py cover episode codes, reason filtering, Telegram bullets, destination dedupe and the episode lookup in the context builder. The dedupe and episode tests fail on current main. Full suite passes (2151 tests). Running it on my own instance (0.6.4, Telegram) since 27 Oct.

edmunek and others added 2 commits October 28, 2026 10:02
…ends

Cleanup candidate notifications were hard to read on chat transports such
as Telegram:

- Episode candidates rendered as "Season 1" because the context never
  loaded the episode, so three episodes of one show looked like three
  identical lines. Episodes are now loaded and shown as codes, and
  consecutive episodes compress into ranges (S01E05-E07).
- Candidates are grouped per title, so one show is one line with its
  combined size. max_items now counts titles rather than raw rows.
- Reasons no longer include library scoping conditions, which rendered as
  raw server UUIDs twice per line. A group shows each rule once without
  per-episode measured values; a single candidate keeps the value.
- File names only appear in the "with reasons" detail level.
- Telegram receives legacy Markdown, which has no list syntax, so "- "
  arrived as a literal hyphen. Bullets become glyphs for tgram:// URLs.

Fan-out to several users (notify_admins, notify_users, notify_all_users)
now sends each event once per destination URL, so two accounts pointing
at the same chat no longer receive every message twice.
@jessielw
jessielw changed the base branch from main to dev October 28, 2026 15:53
@jessielw

Copy link
Copy Markdown
Owner

Hello, thanks for the PR. With a minor fix and correcting the target branch it looks great :)

@jessielw
jessielw merged commit 687e7cf into jessielw:dev Oct 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants