Skip to content

[feat]: add schedule report log persistence#42

Draft
not-meet wants to merge 2 commits into
RocketChat:feature/automated-schedule-reportsfrom
not-meet:feat/schedule-persistence
Draft

[feat]: add schedule report log persistence#42
not-meet wants to merge 2 commits into
RocketChat:feature/automated-schedule-reportsfrom
not-meet:feat/schedule-persistence

Conversation

@not-meet

@not-meet not-meet commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds the persistence layer for the scheduled spam-report feature: storing
the active schedule, in-progress setup drafts, and the flag/admin-action
logs the daily report will summarize.

Changes

4 persistence layers were added

AdminActionLogStore

  • Logs admin moderation actions (e.g. warn/mute/ban) against a user, writing to two parallel records: a per-day bucket (antispam-action-day:{date}) capped at MAX_DAILY_ACTIONS with a truncated flag, and a rolling per-user "recent actions" list capped at MAX_RECENT_ACTIONS (FIFO via shift()).
  • Exposes reads by user (getByUser), by single day (getActionsForDay), and aggregated across a date range (getActionsSince, built on daysBetween).
  • Both fetch paths filter out malformed/legacy records (r.action !== undefined) as a lightweight schema guard.

FlagLogStore

  • Logs individual spam-flag events, aggregating them into a per-user, per-day DailyFlagSummary (flag count, trigger/action tallies, room list capped at MAX_ROOMS_PER_SUMMARY) rather than storing raw events per day.
  • Separately maintains a rolling "recent events" list per user (MAX_RECENT_EVENTS, FIFO), similar to the admin action store.
  • Provides day-level (getDailySummariesForDay) and range-level (getDailySummariesSince) reads, again using daysBetween to fan out across day-keyed associations.

ScheduleDraftStorage

  • Persists an in-progress scheduling draft per admin user (keyed by user + fixed antispam-schedule-draft scope) while they're stepping through the setup modal.
  • Supports two draft stages via a discriminated union (confirm with the draft payload, or delete for a pending removal), plus standard save / get / clear.
  • No history or capping logic — it's a single overwritable slot per admin.

ScheduleStore

  • Holds the single active daily-report schedule (global MISC association, not per-user), including lastReportSentAt used by ScheduledReporter to determine the report window.
  • markSent does a read-modify-write to bump lastReportSentAt without disturbing other fields.
  • replace/clear round out basic CRUD for enabling/disabling or reconfiguring the schedule.

@not-meet
not-meet force-pushed the feat/schedule-persistence branch from 3bba9b9 to 5468ccb Compare July 18, 2026 21:35
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.

1 participant