Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical regressions break Settings callbacks and allow stale saves to overwrite remote edits and delete newly added webhooks.
6 open issues
Prevent stale settings saves from overwriting remote changes · New Restore the removed settings reload helper · New Save only the auto-start setting when toggled · New Honor explicitly cleared secrets in test requests · New Preserve message whitespace when stripping keywords · New Reconcile queued deliveries when target states change · New
What changed in this PR
Extends inbound SMS forwarding with multiple prefix-routed Webhooks while preserving single-target behavior and migrating legacy configuration.
Changes:
- Adds routing, prefix stripping, sender allowlists, and per-Webhook delivery lanes.
- Updates settings, status, and test APIs for multiple targets.
- Introduces editable Webhook cards, expands tests, and documents version 1.3.0.
| File | Description |
|---|---|
| README.md | Documents configuration, routing, and delivery behavior. |
| GLOSSARY.md | Defines routing and multi-Webhook terminology. |
| docs/webhook/receiver_test.md | Updates sample request version and headers. |
| docs/remote-api.md | Describes API schemas, migration, and validation. |
| docs/adr/0003-multi-webhook-routing.md | Records multi-Webhook design decisions. |
| docs/adr/0001-inbound-sms-webhook.md | Notes decisions superseded by ADR 0003. |
| CHANGELOG.md | Adds the 1.3.0 release summary. |
| app/tests/test_webhook.py | Covers routing, allowlists, and independent delivery lanes. |
| app/tests/test_settings_local_save.py | Updates local-save and migration coverage. |
| app/tests/test_remote_api.py | Tests multi-target settings, status, and test delivery. |
| app/services/webhookSvc.py | Implements routing, delivery lanes, and per-target status. |
| app/services/settingsSvc.py | Adds array settings, migration, and validation. |
| app/services/postApi.py | Exposes multi-Webhook API operations. |
| app/services/config.py | Bumps the version to 1.3.0. |
| app/services/appSvc.py | Reports per-target pending counts and routing outcomes. |
| app/screens/settings.py | Introduces editable Webhook cards. |
| app/main.py | Connects card management, saving, testing, and status display. |
Review effort: Balanced
| if webhook is None: | ||
| return None | ||
| form["webhook"] = webhook | ||
| form["webhooks"] = [card.read() for card in self.webhook_cards] |
There was a problem hiding this comment.
Fixed in ef6ef95. The Settings form now carries the loaded Revision into save_local_settings; a stale full save raises SettingsRevisionConflict, the UI shows a notice and reloads instead of replacing the array. Added a regression test (test_a_stale_full_save_is_rejected).
|
|
||
| def webhook_switch_active(self, instance, value): | ||
| """Apply the toggle immediately, instead of waiting for Save. | ||
| def refresh_webhook_view(self): |
There was a problem hiding this comment.
Fixed in aa056a3. reload_settings_config is restored and both on_settings_entry and the port-change callback use it; also verified on-device that opening Settings no longer raises AttributeError.
| if webhook is None: | ||
| return None | ||
| form["webhook"] = webhook | ||
| form["webhooks"] = [card.read() for card in self.webhook_cards] |
There was a problem hiding this comment.
Fixed in ef6ef95. The auto-start switch now saves only {"boot": ...} and updates the local switch state; it no longer touches Webhook cards or secrets. A boot-only save test confirms remote card changes survive.
| url = (card.ids.url_inp.text or "").strip() | ||
| secret = card.ids.secret_inp.text or "" | ||
| if ( | ||
| not secret |
There was a problem hiding this comment.
Fixed in ef6ef95. WebhookCard exposes secret_cleared, and the test-delivery path no longer falls back to the stored secret when that sentinel is set; it sends an unsigned test until/unless a new secret is typed.
| if mode == STRIP_KEYWORD: | ||
| return rest.lstrip() | ||
| if rest[:1] == ":" or (rest[:1] and rest[0].isspace()): | ||
| rest = rest[1:] | ||
| return rest.lstrip() |
There was a problem hiding this comment.
Fixed in ef6ef95. strip_route_prefix now preserves the separator and following whitespace in keyword mode, and removes only the separator plus at most one following space in keyword_and_separator mode. Added space-preservation cases to test_strip_prefix_modes.
| if due <= now: | ||
| self._lanes.move_to_end(webhook_id) | ||
| return record, None | ||
| soonest = due if soonest is None else min(soonest, due) |
There was a problem hiding this comment.
Fixed in ef6ef95. The worker reconciles every 0.2 s against the live Settings before checking retry deadlines: records for a disabled or deleted Webhook are failed immediately, their lane is removed, and capacity is freed. Added tests for disabling, deleting, and re-enabling a target.
|
All six review findings are addressed in
|


Summary
Adds multiple Webhooks with prefix-keyword routing on top of the 1.2.0 inbound SMS webhook. A received SMS is delivered to exactly one enabled Webhook, optionally after removing the route prefix, and only if the sender is allowed for that Webhook.
Behaviour
#sales: hello), matched only at the start and only when followed by:or whitespace;none,keywordonly, orkeyword_and_separator.Remote API
settings.webhookbecomessettings.webhooks; retry policy moves to top-levelwebhook_delivery.PUT /api/settingsis a full-array replacement with server-assigned opaque ids (wh_…). Entries with an id update, entries without one are created, omitted entries are deleted.""clears, non-empty replaces.POST /api/webhook/testacceptsid(required when several are configured), selects a saved target, and addsX-OpenSMS-Webhook-Id.url/secretoverrides remain.GET /api/statusreturns a per-Webhookwebhooksarray withpendingandlast_delivery; newwebhook_unroutedwarning and per-entrywebhook_url_invalidwithwebhook_id.webhookPUT body is accepted for one release as a one-entry shim (cannot be combined with the new shape). Deprecated; removal targeted at 1.4.0.Migration
config.jsonwebhookobjects migrate on load to a one-element array with idwh_legacy; the next write persists the new shape. Migration does not bump the Revision.webhook_idattach towh_legacyand keep their captured URLs.webhook_status.jsonmaps to the migrated Webhook.Settings UI
The single Webhook block becomes collapsible Webhook cards with add/delete/test, per-card last-delivery status, keyword/strip fields (shown when 2+ are configured), and a multiline allowed-senders field. Edits are local until Save; the enabled toggle no longer auto-saves. Delete confirms that pending deliveries for that Webhook will be dropped.
Tests
python -m unittest discover -s tests— 208 tests pass, including new routing, stripping, allowlist, per-target lane, migration, API schema, id/secret semantics, status, and local-save coverage.Docs
README,
docs/remote-api.md,GLOSSARY.md, ADR 0003, CHANGELOG, and version1.3.0.Notes
/api/statuswarns when 2+ are enabled without one.