Skip to content

feat(reviews): per-user review opt-out with /reviews command - #110

Merged
asiniscalchi merged 5 commits into
mainfrom
feat/per-user-reviews
Sep 1, 2026
Merged

feat(reviews): per-user review opt-out with /reviews command#110
asiniscalchi merged 5 commits into
mainfrom
feat/per-user-reviews

Conversation

@a-mandala

Copy link
Copy Markdown
Collaborator

Summary

Each user can now turn their own review delivery on or off, without touching other tenants or the deployment:

  • /reviews shows the current state, /reviews on / /reviews off toggles it, and the command is listed in /help
  • Default is ON for every user: preferences live in a new singleton review_preferences table (migration 0016) in each tenant's own SQLite database, where an absent row means enabled — so no backfill is needed for existing or new users
  • The daily and weekly delivery workers check the preference when selecting targets: an opted-out user gets no review generated or delivered, while on-demand /day_review and /week_review remain available
  • The existing global env flags (FROID_DAILY_REVIEW_DELIVERY_ENABLED, FROID_WEEK_REVIEW_WORKER_ENABLED) keep working as master switches layered above the per-user preference

Test Plan

  • 11 new tests covering all layers: repository defaults/round-trip and idempotency, migration default-state, JournalService command handling, Telegram parsing (incl. @bot suffix and /help listing), and worker tests asserting an opted-out user receives zero attempted deliveries and no generated review record
  • Full suite: 602 passed, 0 failed; cargo fmt --check clean; clippy clean except one pre-existing lint on main (chunks_exact in src/journal/embedding/types.rs), untouched by this branch

Adds a singleton review_preferences table to the per-tenant migration
set and a ReviewPreferenceRepository to read/write it. Absence of a
row means reviews are enabled, so the default is ON for every user
without requiring a backfill.
Wires ReviewPreferenceRepository into JournalService and adds
JournalCommand::ReviewsStatus/ReviewsSet/ReviewsUsage so a user can
check or change their opt-out state through the per-tenant journal
service, independent of the Telegram adapter.
Parses "/reviews", "/reviews on", and "/reviews off" into the
corresponding JournalCommand and lists the command in /help,
alongside the other bot commands.
…-out

Threads ReviewPreferenceRepository through DailyReviewDelivery and
WeeklyReviewDelivery so their targets() returns no conversations (and
triggers no generation) for a tenant who has turned reviews off,
without touching the on-demand /day_review and /week_review commands.
Wires the repository through app.rs's per-tenant worker construction
and documents the /reviews command and its relationship to the
existing global enable flags in the README.
CI runs clippy with warnings denied; chunks_exact with a constant
chunk size fails there. Switch to as_chunks::<4>() which removes
the try_into().unwrap().
@asiniscalchi
asiniscalchi merged commit a0f79de into main Sep 1, 2026
3 checks passed
@asiniscalchi
asiniscalchi deleted the feat/per-user-reviews branch September 1, 2026 16:22
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