Skip to content

[receiver] delay mms parsing on download#402

Open
capcom6 wants to merge 2 commits into
masterfrom
issue/401-delayed-mms-parsing
Open

[receiver] delay mms parsing on download#402
capcom6 wants to merge 2 commits into
masterfrom
issue/401-delayed-mms-parsing

Conversation

@capcom6

@capcom6 capcom6 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved MMS processing reliability by retrying briefly until MMS content and attachments are available before handling the message.
    • Fixed MMS subject decoding to better recover from common charset mis-decoding, improving multilingual subject text.
    • Enhanced decoding of character-encoded MMS headers to provide more accurate message details.
  • Tests
    • Added unit tests for MMS subject decoding across UTF-8 (multilingual) and ASCII cases.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

MMS 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.

Changes

MMS processing

Layer / File(s) Summary
MMS subject charset decoding
app/src/main/java/me/capcom/smsgateway/modules/receiver/parsers/MMSParser.kt, app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt, app/src/test/java/me/capcom/smsgateway/modules/receiver/parsers/MMSParserTest.kt
Encoded subjects are decoded using resolved charsets, provider subjects undergo mis-encoding recovery, and UTF-8 and ASCII parsing are tested.
Downloaded MMS completion retry
app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.kt
Incomplete MMS content is reread with a bounded delay between attempts before processing the final message.

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
Loading

Possibly related PRs

Suggested labels: ready

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: delaying MMS parsing until download content is ready.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue/401-delayed-mms-parsing

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0cdc5d8 and e3b0b23.

📒 Files selected for processing (4)
  • app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.kt
  • app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt
  • app/src/main/java/me/capcom/smsgateway/modules/receiver/parsers/MMSParser.kt
  • app/src/test/java/me/capcom/smsgateway/modules/receiver/parsers/MMSParserTest.kt

Comment thread app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.kt Outdated
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

🤖 Pull request artifacts

file commit
app-release.apk 034623c
app-release.aab 034623c
app-insecure.apk 034623c
app-insecure.aab 034623c

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentReader.kt (1)

239-239: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Lower the lead byte threshold to support single-character subjects.

The current threshold leadByteCount >= 2 will 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 to 1 ensures single-character subjects are recovered, while the highByteCount >= leadByteCount check 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

📥 Commits

Reviewing files that changed from the base of the PR and between e3b0b23 and 034623c.

📒 Files selected for processing (2)
  • app/src/main/java/me/capcom/smsgateway/modules/receiver/MmsContentObserver.kt
  • app/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

@capcom6 capcom6 added the ready label Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mms:downloaded webhook fires with empty attachments and sender/phoneNumber = "unknown" (v1.68.0)

1 participant