Conversation
📝 WalkthroughWalkthroughAdds an incoming SMS/MMS module with encrypted batch ingestion, persistence, filtered retrieval, attachment access, database migrations, mobile routing, configurable retention, gateway wiring, and a periodic cleanup worker. ChangesIncoming message subsystem
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant MobileClient
participant MobileInboxController
participant IncomingService
participant IncomingRepository
participant MySQL
MobileClient->>MobileInboxController: POST encrypted inbox batch
MobileInboxController->>IncomingService: Convert and validate messages
IncomingService->>IncomingRepository: InsertBatch
IncomingRepository->>MySQL: Persist messages and attachments
MySQL-->>IncomingRepository: Return persistence result
IncomingRepository-->>IncomingService: Complete batch insertion
IncomingService-->>MobileInboxController: Return result
MobileInboxController-->>MobileClient: Return HTTP response
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@internal/sms-gateway/models/migrations/mysql/20260724000000_create_incoming_tables.sql`:
- Around line 3-20: Align the incoming-message soft-delete model with its
queries and retention cleanup: embed the deleted-at field in
IncomingMessageModel, add incoming_messages.deleted_at with an index covering
the soft-delete predicates in the migration, and update Cleanup to use
Unscoped().Delete so expired parent messages and incoming_attachments are
physically removed. Apply the schema change in
internal/sms-gateway/models/migrations/mysql/20260724000000_create_incoming_tables.sql
and the purge change in internal/sms-gateway/modules/incoming/repository.go; the
model change belongs in IncomingMessageModel.
In `@internal/sms-gateway/modules/incoming/repository.go`:
- Around line 53-66: Update the message insertion loop in InsertBatch to inspect
the Create result’s RowsAffected value; only assign attachment MessageID values
and call tx.Create for attachments when a new message was inserted. Skip
attachment processing for conflict-skipped messages while preserving existing
error handling.
In `@internal/sms-gateway/modules/incoming/service.go`:
- Around line 59-70: Update the message construction in the incoming service to
preserve the source timestamp by assigning MessageInput.CreatedAt to
TimedModel.CreatedAt instead of forcing a zero time. Leave UpdatedAt behavior
unchanged and ensure persisted messages retain their original chronological and
retention metadata.
- Around line 46-56: Update the attachment conversion in the incoming message
service to propagate AttachmentInput.IsEncrypted into attachmentModel for every
attachment. Ensure the model field is populated alongside PartID, ContentType,
Name, Size, and Data so encrypted status is retained and plaintext attachments
cannot bypass enforcement.
In `@internal/worker/config/config.go`:
- Around line 41-43: Validate IncomingCleanup during configuration loading and
reject configurations where either Interval or MaxAge is less than or equal to
zero. Ensure invalid values from TASKS__INCOMING_CLEANUP__INTERVAL and
TASKS__INCOMING_CLEANUP__MAX_AGE fail before the cleanup settings are accepted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f9e16dec-80ba-4687-8de9-08590b8fdd94
📒 Files selected for processing (17)
internal/config/config.gointernal/config/module.gointernal/sms-gateway/app.gointernal/sms-gateway/models/migrations/mysql/20260724000000_create_incoming_tables.sqlinternal/sms-gateway/modules/incoming/config.gointernal/sms-gateway/modules/incoming/domain.gointernal/sms-gateway/modules/incoming/errors.gointernal/sms-gateway/modules/incoming/models.gointernal/sms-gateway/modules/incoming/module.gointernal/sms-gateway/modules/incoming/repository.gointernal/sms-gateway/modules/incoming/service.gointernal/worker/config/config.gointernal/worker/config/module.gointernal/worker/tasks/incoming/cleanup.gointernal/worker/tasks/incoming/config.gointernal/worker/tasks/incoming/module.gointernal/worker/tasks/module.go
🤖 Pull request artifacts
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@api/mobile.http`:
- Around line 119-130: Replace the placeholder data values in the MMS attachment
examples with valid Base64 payloads, including both attachment objects
identified by partId 1 and partId 2, while leaving their metadata unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 824d349e-a81f-4fb8-a037-b984bfb75294
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
api/mobile.httpgo.modinternal/sms-gateway/handlers/inbox/mobile.gointernal/sms-gateway/handlers/mobile.gointernal/sms-gateway/handlers/module.go
f6b3797 to
9a120db
Compare
00e72d3 to
a715aad
Compare
a4fbcf8 to
30a4b34
Compare
30a4b34 to
fef19c9
Compare
d2e643f to
6ccbc88
Compare
6ccbc88 to
fb84b11
Compare
fb84b11 to
76a53a7
Compare
|
This PR is stale because it has been open for 7 days with no activity. |
796c19b to
d435d79
Compare
95d8496 to
1379dae
Compare
59514b1 to
d51d790
Compare
434c3ed to
9cc6f39
Compare
fa16e4f to
ca1fa4e
Compare
ca1fa4e to
c24ae3d
Compare
Summary by CodeRabbit
The PR appears safe to merge because the previously reported migration failure has been corrected and no blocking failure remains.
Summary
The PR adds durable inbox synchronization, retrieval, attachment handling, and retention cleanup for encrypted incoming messages.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Mobile[Android device] -->|Encrypted inbox upload| API[Mobile inbox endpoint] Consumer[Third-party client] -->|List / refresh / attachment read| API API --> Service[Inbox service] Service --> DB[(inbox and inbox_attachments)] Worker[Retention worker] -->|Delete expired records| DBReviews (29) · Last reviewed commit: "[inbox] add module"