[receiver] delay mms parsing on download#402
Conversation
WalkthroughMMS header parsing now decodes subjects using their declared charset, while content reading recovers common mojibake. Downloaded MMS processing retries until sender and attachments are available, and parser tests cover UTF-8 and ASCII subjects. ChangesMMS processing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MmsContentObserver
participant MmsContentReader
participant receiverSvc
MmsContentObserver->>MmsContentReader: Read downloaded MMS
MmsContentObserver->>MmsContentReader: Retry incomplete content after delay
MmsContentObserver->>receiverSvc: Process final MMS message
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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
`@app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.kt`:
- Around line 156-157: Update the needsRetry condition in the MMS observer retry
loop to retry only when the sender is unknown or both message.body and
message.attachments are empty. Preserve immediate processing for valid text-only
MMS messages, whose body is populated while attachments are absent.
In `@app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt`:
- Around line 232-251: Update isLikelyMisEncoded to remove the early
text.contains('\uFFFD') return, preventing lossy recovery of existing
replacement characters. Replace the c3Count-specific detection with a lead-byte
count covering character codes 0xC2..0xEF, while retaining the existing
high-byte correlation and threshold logic so both European and CJK mojibake are
detected.
🪄 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
Run ID: 084fcd3d-462b-44f5-b07c-41add10f2102
📒 Files selected for processing (4)
app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.ktapp/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.ktapp/src/main/java/me/capcom/smsgateway/modules/receiver/parsers/MMSParser.ktapp/src/test/java/me/capcom/smsgateway/modules/receiver/parsers/MMSParserTest.kt
🤖 Pull request artifacts
|
There was a problem hiding this comment.
♻️ Duplicate comments (1)
app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt (1)
239-239: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winLower the lead byte threshold to support single-character subjects.
The current threshold
leadByteCount >= 2will fail to recover misencoded subjects that consist of only a single multi-byte character (e.g., a single CJK character), as it will only produce 1 lead byte. Lowering the threshold to1ensures single-character subjects are recovered, while thehighByteCount >= leadByteCountcheck still guards against false positives.🛠️ Proposed fix
- return leadByteCount >= 2 && highByteCount >= leadByteCount + return leadByteCount >= 1 && highByteCount >= leadByteCount🤖 Prompt for 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. In `@app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt` at line 239, Update the subject recovery condition in MmsContentReader to use a leadByteCount threshold of 1 instead of 2, while preserving the existing highByteCount >= leadByteCount guard.
🤖 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.
Duplicate comments:
In `@app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt`:
- Line 239: Update the subject recovery condition in MmsContentReader to use a
leadByteCount threshold of 1 instead of 2, while preserving the existing
highByteCount >= leadByteCount guard.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cf5f1aef-f73b-4faf-b954-3813fa0bfcec
📒 Files selected for processing (2)
app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.ktapp/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.kt
Summary by CodeRabbit