Submit a merge request that closes this issue to earn points on merge — bounties stack on the standard +40 merge_pr award. New to the repo? See the Contributing guide, and Local Development & SSO to run the app locally (cp .dev.vars.example .dev.vars && pnpm dev, after rebasing on main) and fully test your change before opening the MR.

Description

Context

Two implementations of "build a 7-day community rollup → publish to Outline" exist in the signal-bot:

  1. apps/signal-bot/src/src/bot/command-handler.ts:handleRollup — user-triggered via !rollup --full. Has rate-limit, admin gate, featureDisabled('docs publishing') graceful-degradation, configurable period, --full detail queries.
  1. apps/signal-bot/src/src/utils/community-rollup.ts:generateAndStoreCommunityRollup — cron-triggered at 02:00 ET. Lacks all of the above guards because the cron runs trusted.

Same 8 stat queries, similar markdown construction, both POST to Outline. Future stat additions or markdown improvements will land in one and not the other (architecture review C1, commit 2139c12a).

Acceptance criteria

  • [ ] Extract fetchCommunityRollupStats(dbClient, queryOptions): Promise<CommunityRollupStats> to apps/signal-bot/src/src/utils/community-rollup.ts — does the 8 parallel getRollup*Stats queries with Promise.all (already done in cron version)
  • [ ] Extract buildCommunityRollupMarkdown(stats, opts: { title; periodLabel; sinceLabel; untilLabel; includeDetails? }) — produces the markdown body (no Outline calls). The includeDetails flag covers the --full detail-query expansion paths.
  • [ ] Refactor command-handler.ts:handleRollup to call the new shared functions. Keep all admin/gate/rate-limit logic at the handler layer.
  • [ ] Refactor community-rollup.ts:generateAndStoreCommunityRollup to call the new shared functions. Keep persistence + Outline-doc creation at the cron layer.
  • [ ] Add at least one test asserting both paths produce identical markdown for the same stats input.
  • [ ] Verify the existing --full Signal-bot command still works after refactor (smoke test: admin runs !rollup --full in DM, gets the same Outline doc shape as before).

Technical hints

  • Today's commit 2139c12a removed the as any casts so the dbClient signatures are now honest.
  • Keep buildCommunityRollupMarkdown pure (no I/O) so it's easy to unit-test.
  • The command-handler version awards points for --full and the cron version does not — that's a real difference, document the divergence in the new function or the call site.

--- *M-tier (100 pts + 40 merge_pr = 140). Cleanup of recent feature work; will keep the rollup shape consistent across surfaces.*

Getting Started (added for pickup-readiness)

Path note: apps/signal-bot/src/src/... is pre-move; the live tree is
selfhost/messaging-apps/signal-messenger/src/src/....
  • Files: src/src/utils/community-rollup.ts (extract the shared fns here) and
  • src/src/bot/command-handler.ts:handleRollup (refactor to consume them).

  • Existing test to extend: src/src/tests/utils/community-rollup.test.ts — add the
  • markdown-parity assertion here.

  • Verify: cd selfhost/messaging-apps/signal-messenger/src && npx vitest run then
  • npx tsc --noEmit; smoke-test !rollup --full as admin in a DM.

  • Coordinate: pairs with #119 — landing #119 first gives a regression net for this refactor.

Prepared for pickup by 🤖 GearSmith's Goal-Tender (Claude).

Relevant files

No relevant files linked yet.

Hints

No hints yet.

Activity

No points have been awarded for this bounty yet.

Comments

No comments yet. Be the first to weigh in.

↑ Top