Skip to content

feat(slack): persist the current reaction count in D1 - #49

Draft
brennenho wants to merge 1 commit into
brennen/demo-mainfrom
brennen/demo-ctc-45
Draft

brennenho wants to merge 1 commit into
brennen/demo-mainfrom
brennen/demo-ctc-45

Conversation

@brennenho

Copy link
Copy Markdown
Contributor

Summary

Store the current reaction count for one configured Slack channel and emoji in D1. A retry can arrive after someone removes or re-adds a reaction. The writer applies changes in Slack event-time order so the count stays accurate.

Implements CTC-45.

Changes

  • CTC-44 can call applySlackReactionEvent(event) from @/server/data/slack-reactions with the inner event after verifying the Slack signature. Pass through event_ts, the reacting user, and the message reference. The writer ignores unrelated events and stores only reaction identifiers and timing.
  • CTC-46 can call getSlackReactionCount() on the server. It requires a club session, returns zero for an empty configured count, and reports missing configuration as unavailable.
  • Set SLACK_REACTION_CHANNEL_ID and SLACK_REACTION_EMOJI in the server environment. Use the Slack channel ID and emoji name without surrounding colons.
  • Apply migration 0003_slack_reaction_versions.sql. It stores one latest event time per reaction key. D1 updates this record and the existing active reaction table in one transaction.

Testing

  • Ran pnpm check. Formatting, lint, type checking, and all 102 tests passed, including six new local D1 tests.
  • Applied all three migrations to a fresh local Wrangler D1 database. Called the production storage helpers with fixture events and a stubbed signed-in session. A matching add, duplicate add, and unrelated emoji left one active reaction.
  • Restarted the local D1 emulator in a second process and read the persisted count of one. Removed the reaction and replayed the older add. The final count was zero.
  • Live Slack delivery and dashboard rendering are covered by CTC-44 and CTC-46.

@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown

CTC-45

@github-actions

Copy link
Copy Markdown

Preview deployment

Open preview ↗

Last deployed 2026-11-19T04:20:07Z

Commit Workflow
ec22797 Run #76 · attempt 1

Fallback preview

This branch was successfully deployed

1 active deployment
pr-49 — ec227971 Deployed Nov 19, 2026 by github-actions[bot]
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