feat(push): support realtime message data in batch-publish channel items#358
feat(push): support realtime message data in batch-publish channel items#358
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR adds support for an optional Changes
Review Notes
|
|
I'm not running copilot on this since it did all the job in the closed PR. |
There was a problem hiding this comment.
Summary
| File | Status | Issues |
|---|---|---|
src/commands/push/batch-publish.ts |
✅ OK | — |
test/unit/commands/push/batch-publish.test.ts |
✅ OK | — |
The implementation is correct. A few things I checked specifically:
Error handling inside .map() — this.fail() is called inside the channelItems.map() callback for the extras.push validation check. This is safe: fail() throws an oclif error, it propagates through .map() to the outer catch, and the outer catch's this.fail() re-throws it immediately (guarded by if (error instanceof Error && "oclif" in error) throw error). No double output. This pattern is explicitly supported by the base class.
Validation is pre-request — channelBatchSpecs is fully computed (and validated) before any HTTP call is made, so a failing item prevents the channel POST from being sent at all. The test confirms this.
Round-trip JSON.stringify(entry.message) — entry.message is already a parsed JS value (from the outer JSON.parse), so stringifying then parsing again inside prepareMessageFromInput is a round-trip. Works correctly for all input shapes (string, object, array, primitive).
Test coverage — all the interesting cases are exercised: string message, name+data extraction, name-only (remaining fields → data), non-push extras merging, extras.push rejection, recipient-item stripping, and no-message baseline. No --duration in test calls, no auth flags, no it.skip.
Ready to merge.
There was a problem hiding this comment.
Pull request overview
Adds support for including an optional realtime message (name/data/extras) on channel-based items in push:batch-publish, publishing it via /messages alongside the push payload in extras.push, while keeping recipient-based items routed to /push/batch/publish (and ignoring message there).
Changes:
- Accept optional
messagefield on channel items and convert it to an Ably message shape viaprepareMessageFromInput(JSON.stringify(...)). - Merge user
message.extraswith CLI-ownedextras.push, and fail ifmessage.extras.pushis provided. - Add unit tests covering string/object message shapes, extras merging, collision failure, and recipient-item sanitization/warning.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/commands/push/batch-publish.ts |
Implements message support for channel-routed batch items; sanitizes recipient items by stripping message and warning. |
test/unit/commands/push/batch-publish.test.ts |
Adds unit coverage for message parsing/merging behavior and error cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7f3d242 to
b1ed7f5
Compare
|
this fixes the flaky e2e test #360 |
b1ed7f5 to
032c036
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
032c036 to
72a01c5
Compare
Summary
Supersedes #355.
"message"field whose value is published as the realtime message alongside the push notification inextras.pushprepareMessageFromInputfrommessage.ts(viaJSON.stringify) — no new utility neededmessagefield follows the same shape as--messageinpush publish(fix(push publish): parse --message as a full Ably message shape #352):nameanddataare extracted; if onlynameis present, remaining fields becomedataExample
[ { "channels": ["my-channel"], "payload": {"notification": {"title": "Hello", "body": "World"}}, "message": {"name": "alert", "data": "Server down"} } ]Test plan
pnpm test:unitpasses (21 tests in batch-publish, covering string message, object with name+data, object with name-only, no message)pnpm exec eslint .clean🤖 Generated with Claude Code