feat(GRO-106): outbound SMS persistence #379

Closed
groombook-engineer[bot] wants to merge 6 commits from feat/GRO-984-outbound-sms-persistence into dev

6 Commits

Author SHA1 Message Date
Chris Farhood 2b646d9e5d fix(GRO-1003): address CI typecheck and lint failures on PR #379
Typecheck fixes:
- telnyx.ts:48 — coerce undefined to null for signature param
- inbound.ts/outbound.ts — add null guards on .returning() results
- schema.ts — add updatedAt to messages table
- package.json — add uuid and @types/uuid

Lint fixes:
- telnyx.ts — remove unused resolveBusinessIdByMessagingNumber import
- inbound.ts — remove unused messageDirectionEnum, messageStatusEnum imports
- inbound.ts — remove unused buildFindOrCreateConversationParams function
- inbound.test.ts — remove unused resolveBusinessIdByMessagingNumber import
- outbound.test.ts — remove unused mockEq/mockAnd variables
- outbound.test.ts — fix vi.mock path for sms.js (../../sms.js)
2026-05-04 16:18:23 +00:00
Chris Farhood 1c4453ed45 feat(GRO-984): outbound SMS persistence via outbound.ts
- New messaging/outbound.ts: sendMessage() with opt-in check, find/create
  conversation, queued->sent/failed status transition
- sms.ts refactored to be the Telnyx transport only (no persistence)
- Unit tests cover success path, opt-out suppression, missing tenant phone

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-04 02:49:56 +00:00
Chris Farhood 701889c06f feat(GRO-984): persist outbound SMS to messages table
Wire sendSms() to find/create the conversation by sender/recipient
and insert an outbound message row with the Telnyx message_id.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-04 02:44:59 +00:00
Chris Farhood c79b5220a4 feat(GRO-106): inbound Telnyx webhook + persistence
- Add POST /api/webhooks/telnyx/messaging route with HMAC signature verification
- Add services/messaging/inbound.ts: findOrCreateConversation, upsertMessage (idempotent on providerMessageId), delivery receipt handling
- Register telnyxWebhooksRouter in index.ts (before auth middleware)
- Add unit tests for signature validation, find-or-create, idempotent insert, delivery receipt

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-04 02:38:27 +00:00
Chris Farhood 2e24c371c3 fix(GRO-981): restore journal entries and add DESC to indexes
- _journal.json: restore idx 28 (0028_sms_reminders), add idx 29
  (0029_db_indexes_constraints), renumber 0030_messaging to idx 30
  (was missing 0028 and 0029 entries — they were silently skipped)
- schema.ts: add .desc() to conversations.lastMessageAt and
  messages.createdAt indexes per spec
- 0030_messaging.sql: add DESC to both generated index statements

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-04 02:16:25 +00:00
Chris Farhood 5e103a378c feat(GRO-106): messaging schema + migrations
- Add conversations, messages, message_attachments, message_consent_events tables
- Add messagingChannelEnum, messageDirectionEnum, messageStatusEnum, messageConsentKindEnum
- Extend business_settings with messagingPhoneNumber and telnyxMessagingProfileId columns
- Add required indexes and unique constraints with cascade-on-delete FKs
- Add migration 0030_messaging.sql

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-04 01:29:32 +00:00