refactor(shared): collapse channel class wrappers into closures#39
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📊 Coverage Report
🤖 Generated by CI · thresholds enforced via vitest |
Before: two parallel channel abstractions — raw send functions in `src/channels/` and thin `TelegramChannel / LineChannel / EmailChannel` classes in `src/push/channels/` that only delegated to those functions. Admin `forceNotifyAll` used raw functions; the push pipeline used classes. Now: `NotificationChannel` is a function type `(identifier, msg) => Promise<SendResult>`, and `createChannelRegistry()` builds closures inline with access to tokens and the email-template render. The class layer (interface, telegram, line, email, ~90 LOC + 3 test files) is removed. `push.logic.ts` calls `channel(id, msg)` directly instead of `channel.send(id, msg)`. No behavior change — `createChannelRegistry` still returns the same registry shape, the email path still renders the React Email template, and the per-channel test file `registry.test.ts` is expanded to cover the closure wiring for all three channels. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e015cf6 to
66723d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eliminates the dual channel abstraction identified by the review — two parallel layers where only raw functions and closures were needed.
NotificationChannelis now a function type(identifier, msg) => Promise<SendResult>.createChannelRegistry()builds closures inline that capture tokens + render the email template.src/push/channels/{telegram,line,email}.ts+interface.ts(~90 LOC).telegram.test.ts,email.test.ts,line-channel.test.ts(tested the deleted classes).registry.test.tsexpanded to cover the closure wiring for all three channels.No runtime behavior change — registry shape, email rendering, circuit-breaker logic all identical.
Test plan
🤖 Generated with Claude Code