Repository navigation
Multimedia in PersonalID Messenger - #315
Conversation
Point the attachment download test and the prompt's help text at messaging/management/commands/_local_message_server/server.py, and document send_rich, send_future_version and clear_pending in its README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (26)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe change adds configurable storage buckets for user photos and message attachments. It adds rich-message fields and attachment records, a multipart message-creation endpoint, message serialization updates, and attachment downloads. The local message server can send rich messages, create future-version messages, and clear unacknowledged messages. Tests cover storage configuration, message validation, serialization, attachment access, and local-server operations. Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Feature Merge Risk: ⚪ Minimal · up to No actionable issue remains from the reviewed changes; the PR is mergeable after normal checks and the documented deployment prerequisites. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Message creation and downloads have explicit authentication and ownership controls, and new sending is disabled by default. Before enabling it, expiry and attachment cleanup need an end-to-end lifecycle guarantee: expired messages remain eligible for delivery, and interrupted or failed cleanup can leave stored files behind. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 15.97% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 144 functions across 23 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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 |
Technical Summary
Adds Rich (multimedia enabled) Messaging to the existing PersonalID messenger service along with the new models and storage. Safe, in-place addition that doesn't require changes to other infra (exiting callers, or existing Android apps).
Likely best reviewed commit by commit.
Detailed design notes available
Initial mobile implementation located here.
Adds
POST /messaging/create_message/(multipart: text plus encrypted attachments), attachment storage and download, and rich fields in the device sync. Sending stays switched off behindRICH_MESSAGING_ENABLED(defaultFalse). Design:rich-messaging/02-ground-design.md,05-personalid-spec.md.Migration (
messaging/0008)Messageand a newMessageAttachmenttable.messaging_message(expires_at): building it scans the table once and blocks writes to it while it runs. Plain messages are never deleted today, so in theory the row count should be checked today in case this reindex is extensive.Changes outside of new Rich Messages
The design attempts to isolate new functionality strictly to the new callpaths. The push,
retrieve_messages, reply forwarding andsend_fcmare unchanged. Literal pinning tests inmessaging/test_message_projections.pycover them.However, there are a couple of areas that are changed for existing code.
retrieve_notifications: every messaging entry gains"version": 2. This is the only change to an existing output. CommCare apps with older messaging versions ignore keys they don't know.defaultstorage to a nameduser_photosstorage (as discussed in Configuration mode for Local development #307). Same bucket, sameAWS_S3_PHOTO_BUCKET_NAME. There is no longer adefaultstorage, so any code usingdefault_storagefails loudly instead of writing to the photo bucket.Known limits or risks
Logging and monitoring
No initial surface area after rollout until adopted.
Safety Assurance
Safety story
Safety
The behavior of this PR was validated against the real android application with a test sender app using both existing Android apps (to ensure compatibility and fallbacks were correctly implemented) and the new implementation (to test edge cases and ensure compatibility with previous messaging).
Core storage refactors were already applied, and existing messaging continues to work even if the new attachment bucket fails.
All migrations are additive only: Redeploy of previous version can happen in-place if critical.
Other key safety notes:
There are limits on individual and overall attachment volume: A request declaring more than 16 MiB is refused before the body is parsed. Limits: 10 attachments, 2.5 MiB each, 15 MiB per message.
Attachments are auth scoped to their message. Downloads check that the message belongs to the requesting user first, then look the attachment up within it.
PersonalID still never has access to message contents, but the metadata and number/type of attachments are visible to ensure processing is functional.
I am confident that this change will not break current and/or previous versions of CommCare apps
Automated test coverage
Automated tests cover both the new functionality and the compatibility guarantees important to rollout.
QA Plan
Existing Messaging tests should continue to function identically for QA assurance.
Deployment
Rollout will require:
Creating the new bucket (
personalid-message-attachments) with identical ACL and semantics to the profile photo bucket. This be done pre-emptively and idempotently)The migration and new index on deploy
This PR can be deployed: any required configuration, commands, or other manual steps required before this PR can be deployed are done.
Labels & Review