Skip to content

[incoming] cleanup incoming messages periodically#387

Open
capcom6 wants to merge 1 commit into
masterfrom
issue/385-incoming-messages-cleanup
Open

[incoming] cleanup incoming messages periodically#387
capcom6 wants to merge 1 commit into
masterfrom
issue/385-incoming-messages-cleanup

Conversation

@capcom6

@capcom6 capcom6 commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added an Inbox settings area for incoming message options (replacing the previous receiver settings screen).
    • Introduced configurable incoming log retention (days) with numeric-only input and export/import support.
    • Enabled periodic background cleanup of incoming logs based on the retention setting.
    • Updated inbox/receiver labels and added an inbox icon.
  • Bug Fixes
    • Retention setting now validates values (minimum 1 day) and cleanup safely no-ops when retention is not set.

@capcom6 capcom6 linked an issue Jun 19, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🤖 Pull request artifacts

file commit
app-release.apk c0995d7
app-release.aab c0995d7
app-insecure.apk c0995d7
app-insecure.aab c0995d7

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3318e2d1-9a8a-4e0a-aea2-2e0c109fb323

📥 Commits

Reviewing files that changed from the base of the PR and between 7819ca8 and c0995d7.

📒 Files selected for processing (17)
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesService.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesSettings.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/db/IncomingMessagesDao.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/repositories/IncomingMessagesRepository.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/workers/IncomingLogTruncateWorker.kt
  • app/src/main/java/me/capcom/smsgateway/modules/orchestrator/OrchestratorService.kt
  • app/src/main/java/me/capcom/smsgateway/modules/settings/Module.kt
  • app/src/main/java/me/capcom/smsgateway/modules/settings/SettingsService.kt
  • app/src/main/java/me/capcom/smsgateway/ui/settings/InboxSettingsFragment.kt
  • app/src/main/java/me/capcom/smsgateway/ui/settings/ReceiverSettingsFragment.kt
  • app/src/main/res/drawable/ic_inbox.xml
  • app/src/main/res/values-ar/strings.xml
  • app/src/main/res/values-ru/strings.xml
  • app/src/main/res/values-zh/strings.xml
  • app/src/main/res/values/strings.xml
  • app/src/main/res/xml/inbox_preferences.xml
  • app/src/main/res/xml/root_preferences.xml
💤 Files with no reviewable changes (1)
  • app/src/main/java/me/capcom/smsgateway/ui/settings/ReceiverSettingsFragment.kt
✅ Files skipped from review due to trivial changes (1)
  • app/src/main/res/drawable/ic_inbox.xml
🚧 Files skipped from review as they are similar to previous changes (15)
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/db/IncomingMessagesDao.kt
  • app/src/main/res/xml/root_preferences.xml
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/repositories/IncomingMessagesRepository.kt
  • app/src/main/java/me/capcom/smsgateway/ui/settings/InboxSettingsFragment.kt
  • app/src/main/java/me/capcom/smsgateway/modules/settings/SettingsService.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/workers/IncomingLogTruncateWorker.kt
  • app/src/main/java/me/capcom/smsgateway/modules/settings/Module.kt
  • app/src/main/res/values/strings.xml
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesService.kt
  • app/src/main/res/values-zh/strings.xml
  • app/src/main/res/xml/inbox_preferences.xml
  • app/src/main/java/me/capcom/smsgateway/modules/orchestrator/OrchestratorService.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesSettings.kt
  • app/src/main/res/values-ar/strings.xml
  • app/src/main/res/values-ru/strings.xml

Walkthrough

This PR adds incoming log retention settings, a truncation worker, and inbox settings UI wiring. It also removes unused string resources in localized XML files and reformats a long consent string element.

Changes

Incoming Log Lifetime and Truncation

Layer / File(s) Summary
Settings contract and DI wiring
app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesSettings.kt, app/src/main/java/me/capcom/smsgateway/modules/settings/Module.kt, app/src/main/java/me/capcom/smsgateway/modules/settings/SettingsService.kt
IncomingMessagesSettings stores lifetime_days, exports/imports it, and is registered in Koin and SettingsService under "incoming".
Suspend truncation path
app/src/main/java/me/capcom/smsgateway/modules/incoming/db/IncomingMessagesDao.kt, app/src/main/java/me/capcom/smsgateway/modules/incoming/repositories/IncomingMessagesRepository.kt
truncate(until: Long) becomes a suspend call in both DAO and repository.
Truncation worker and service lifecycle
app/src/main/java/me/capcom/smsgateway/modules/incoming/workers/IncomingLogTruncateWorker.kt, app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesService.kt
A periodic CoroutineWorker calls truncateLog(), and IncomingMessagesService gains worker lifecycle hooks plus cutoff-based truncation from lifetimeDays.
Orchestrator and inbox preferences
app/src/main/java/me/capcom/smsgateway/modules/orchestrator/OrchestratorService.kt, app/src/main/java/me/capcom/smsgateway/ui/settings/InboxSettingsFragment.kt, app/src/main/res/drawable/ic_inbox.xml, app/src/main/res/xml/inbox_preferences.xml, app/src/main/res/xml/root_preferences.xml, app/src/main/res/values/strings.xml
OrchestratorService starts/stops the incoming service, and the new inbox settings screen, icon, preference XML, and labels expose incoming.lifetime_days in the UI.

Locale String Resource Cleanup

Layer / File(s) Summary
Unused strings removed
app/src/main/res/values/strings.xml, app/src/main/res/values-ar/strings.xml, app/src/main/res/values-ru/strings.xml, app/src/main/res/values-zh/strings.xml
Removes more_settings and notifications entries and reformats the long privacy policy string element across default and localized resources.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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: periodic cleanup of incoming messages.
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/385-incoming-messages-cleanup

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: 4

🤖 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/incoming/IncomingMessagesSettings.kt`:
- Around line 24-30: The lifetimeDays assignment uses toFloat().toInt() which
silently truncates decimal values like "1.9" to "1" instead of rejecting them.
Replace the toFloat().toInt() conversion chain in the lifetimeDays assignment
with a direct toInt() call, or add explicit validation to ensure the input is a
whole number before parsing. This will cause non-integer values to throw an
exception rather than being silently coerced.

In
`@app/src/main/java/me/capcom/smsgateway/modules/incoming/workers/IncomingLogTruncateWorker.kt`:
- Around line 24-27: In the `doWork()` method of `IncomingLogTruncateWorker`,
change the catch clause from catching `Throwable` to catching `Exception`
instead. Additionally, add a check within the catch block to detect if the
caught exception is a `CancellationException`, and if so, rethrow it immediately
to allow coroutine cancellation to propagate properly. This ensures that when
the worker is cancelled, the cancellation signal is not mistakenly converted to
a retriable failure, which would break the cancellation semantics of
`CoroutineWorker`.

In
`@app/src/main/java/me/capcom/smsgateway/ui/settings/IncomingSettingsFragment.kt`:
- Around line 16-18: The preference key being checked in the when statement does
not match the actual key defined in the XML preferences file. In the when block
that handles the preference customization, change the key from
"incoming.log_lifetime_days" to "incoming.lifetime_days" to align with the key
defined in incoming_preferences.xml. This mismatch is preventing the
setOnBindEditTextListener block from executing when the preference is accessed.

In `@app/src/main/res/values/strings.xml`:
- Line 179: The incoming_dotdotdot string resource uses three ASCII dots ("...")
instead of the single ellipsis character ("…") that other *_dotdotdot labels use
throughout the strings.xml file. Replace the three ASCII dots in the
incoming_dotdotdot string with the single Unicode ellipsis character to maintain
consistency with the existing UI label formatting.
🪄 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: b8f3e21f-80ff-45d0-8707-c73228f416cd

📥 Commits

Reviewing files that changed from the base of the PR and between aacce02 and 137f573.

📒 Files selected for processing (12)
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesService.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/IncomingMessagesSettings.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/db/IncomingMessagesDao.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/repositories/IncomingMessagesRepository.kt
  • app/src/main/java/me/capcom/smsgateway/modules/incoming/workers/IncomingLogTruncateWorker.kt
  • app/src/main/java/me/capcom/smsgateway/modules/orchestrator/OrchestratorService.kt
  • app/src/main/java/me/capcom/smsgateway/modules/settings/Module.kt
  • app/src/main/java/me/capcom/smsgateway/modules/settings/SettingsService.kt
  • app/src/main/java/me/capcom/smsgateway/ui/settings/IncomingSettingsFragment.kt
  • app/src/main/res/values/strings.xml
  • app/src/main/res/xml/incoming_preferences.xml
  • app/src/main/res/xml/root_preferences.xml

Comment thread app/src/main/res/values/strings.xml Outdated
@capcom6 capcom6 force-pushed the issue/385-incoming-messages-cleanup branch from cdf8b36 to d5d85b6 Compare June 22, 2026 13:38
@capcom6 capcom6 added the ready label Jun 23, 2026
@capcom6 capcom6 force-pushed the issue/385-incoming-messages-cleanup branch from d5d85b6 to 4abf62f Compare June 24, 2026 02:03
@github-actions github-actions Bot removed the ready label Jun 24, 2026
@capcom6 capcom6 added the ready label Jun 24, 2026
@capcom6 capcom6 force-pushed the issue/385-incoming-messages-cleanup branch from 4abf62f to 34cecd1 Compare June 25, 2026 00:13
@github-actions github-actions Bot removed the ready label Jun 25, 2026
@capcom6 capcom6 added the ready label Jun 25, 2026
@capcom6 capcom6 force-pushed the issue/385-incoming-messages-cleanup branch from 34cecd1 to 1de992a Compare July 1, 2026 00:50
@github-actions github-actions Bot removed the ready label Jul 1, 2026
@capcom6 capcom6 force-pushed the issue/385-incoming-messages-cleanup branch 2 times, most recently from f7cef1b to 7819ca8 Compare July 2, 2026 02:17
@capcom6 capcom6 added the ready label Jul 2, 2026
@capcom6 capcom6 force-pushed the issue/385-incoming-messages-cleanup branch from 7819ca8 to c0995d7 Compare July 8, 2026 01:11
@github-actions github-actions Bot removed the ready label Jul 8, 2026
@capcom6 capcom6 added the ready label Jul 8, 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.

Add API endpoint to delete messages by filter or date

1 participant