Repository navigation
feat(notifications): SMS opt-in/opt-out consent ledger - #1863
Merged
Merged
Conversation
Record phone-level SMS consent with provenance (web form, inbound STOP/START, admin) and an append-only audit trail, honouring opt-outs in the shared provider store. Adds the /api/sms-consent router, migration 016, an on-device store and an SMS Consent screen linked from Settings.
# Conflicts: # backend/server.ts
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
Adds a phone-level SMS consent ledger so we can answer, for any number,
whether we may text it, since when, where that decision came from, and why —
the provenance the bare provider
optOutStoredoes not record.SmsConsentServicekeeps one currentSmsConsentrecord per number plus anappend-only audit event log. Recording a decision always appends an event,
even when the status is unchanged, so a replayed inbound STOP is still
attributable.
sourceis one ofweb_form,inbound_sms,admin,import,api,system; inbound STOP/START records the matched keyword as the reason and theTwilio MessageSid for provenance.
optOutStoreiswritten so the low-level send path refuses opted-out numbers, and
isOptedOut(phone)lets higher layers check before a send.explicitOptIn), so a later system-level reset doesnot silently revoke a deliberate opt-in.
Routes
GET /api/sms-consent/:phoneGET /api/sms-consent/:phone/eventsGET /api/sms-consent/user/:userIdPOST /api/sms-consent/:phone/opt-outPOST /api/sms-consent/:phone/opt-inChanges
smsConsentService.ts,smsConsentRouter.ts, wired intocontainer.tsandserver.ts;smsInboundHandler.tsnow records consent onSTOP/START.
016_sms_consent.sql.src/store/smsConsentStore.ts,SmsConsentScreen, route +Settings entry under Privacy.
docs/NOTIFICATIONS.md.Testing
smsConsentService.test.ts(15) andsmsConsentRouter.test.ts(10) passunder
jest.backend.config.js.src/store/__tests__/smsConsentStore.test.ts(11) passes.SmsConsentScreen.test.tsxfollows the RN screen-test convention (the localjest-expo preset is broken per AGENTS.md, so it runs in CI).
tscunchanged at the pre-existing baseline; ESLint clean on touched files.closes #1747