Push a notification when a sync finds new transactions - #784
Open
michaelst wants to merge 1 commit into
Open
Conversation
Direct APNs, no Firebase and no APNs library: Finch already speaks HTTP/2 and joken already signs ES256, so the client is ~50 lines on the Tesla seam the test standards require, where a 410 and its response headers are asserted rather than mocked away. - `PATCH /api/session` registers the device token on the calling API token, so revoking the token stops its pushes. - `SyncMember` collects its inserts and calls `Accounts.notify_user/2` once at the end of the run - one push saying "3 new transactions · $84.21", never fifty. - Every completed sync pushes: silent when there is nothing to say, which is the completion signal `POST /api/banks/:id/sync` has never had. The visible alert is held back on a first connect and on a historical sync, where the count is history rather than news. - A `410 Unregistered` nulls the device token instead of retrying. Anything else is an Oban retry. - Unconfigured is a supported state: with no `.p8` the client refuses to send and nothing else changes. `mix openapi` was writing to ./openapi.json rather than the file CI diffs, because the task takes `--filename` and ignores a positional path. Fixed, and the stray copy deleted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Phase 2b, server half. Device half stacks on this branch.
What
PATCH /api/sessionregisters the APNs device token on the API token the request was made with, so revoking the token stops its pushes. No new table.SyncMembercollects its inserts and callsAccounts.notify_user/2once at the end of the run - "3 new transactions · $84.21", never fifty pushes.content-available: 1) when there is nothing to say, which is the completion signalPOST /api/banks/:id/synchas never had.410 Unregistered/BadDeviceTokennulls the device token; anything else is an Oban retry..p8the client returns{:error, :not_configured}and nothing else changes.No APNs library
pigeon and pushx both hardcode
api.push.apple.comwith no base-URL override, so neither can be driven throughTeslaMock- each would need its own Hammox wrapper and no test would assert the real request. Finch already speaks HTTP/2 (onepools:entry) and joken already signs ES256, so the client is ~50 lines on the seamdocs/tests.mdrequires, and the 410 path is tested against a real response.Deliberate deviation from the plan
The plan says both "suppress on historical sync - a first connect fires nothing" and "send on sync completion regardless of count ... which closes the gap where
POST /api/banks/:id/synchas no completion signal". Those contradict:/syncis the historical sync. Resolved by suppressing the visible alert rather than the whole notification, and applying it to the first-connect sync too (which the plan wanted covered, but which runs throughqueue_sync, notqueue_historical_sync). So alerts fire only on webhook-driven syncs - exactly when new charges genuinely arrive - and every run still wakes the app.Drive-by
mix openapiwas writing./openapi.json, not thepriv/static/openapi.jsonthat CI diffs - the task takes--filenameand ignores a positional path, so the drift check could never have failed. Fixed, stray copy deleted.Gates
mix format,mix compile --warnings-as-errors,mix credo,mix coveralls100%, spec + Dart client regenerated.Not verified here
The APNs request itself has never hit Apple - no
.p8on this machine. Needs a real key and a device before it is known to work end to end.🤖 Generated with Claude Code