Skip to content

[gateway] add support for data messages#237

Merged
capcom6 merged 2 commits intomasterfrom
feature/cloud-data-messages
Jul 7, 2025
Merged

[gateway] add support for data messages#237
capcom6 merged 2 commits intomasterfrom
feature/cloud-data-messages

Conversation

@capcom6
Copy link
Copy Markdown
Owner

@capcom6 capcom6 commented Jul 1, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced message handling to support both text and data messages, allowing for more flexible message content types.
    • Improved compatibility with legacy message formats to ensure smooth transition and backward support.
  • Bug Fixes

    • Corrected port number handling to use unsigned values, expanding the valid range for data message ports and ensuring accurate processing.
  • Documentation

    • Updated README to clarify feature description with improved phrasing.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 1, 2025

## Walkthrough

The changes introduce a sealed class hierarchy for message content, supporting both text and data messages with explicit typing. The `port` property for data messages is updated from `Short` to `UShort` throughout the codebase. Message construction and handling logic is updated to accommodate these changes, ensuring proper type conversions and backward compatibility.

## Changes

| File(s)                                                                                      | Change Summary                                                                                                   |
|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| `.../domain/MessageContent.kt`                                                              | Changed `port` property in `MessageContent.Data` from `Short` to `UShort`.                                       |
| `.../modules/gateway/GatewayApi.kt`                                                         | Introduced sealed class `MessageContent` (`Text`, `Data`). Updated `Message` class to use new content structure, added compatibility logic. |
| `.../modules/gateway/GatewayService.kt`                                                     | Injected `LogsService` for error logging. Updated message processing to handle `Text` and `Data` content types distinctly. |
| `.../modules/localserver/routes/MessagesRoutes.kt`                                          | Changed conversion of `port` to use `toUShort()` instead of `toShort()` in message construction.                 |
| `.../modules/messages/MessagesService.kt`                                                   | Explicitly converts `content.port` to `Short` with `.toShort()` when sending data SMS messages.                  |
| `android-sms-gateway/dev-docs`                                                              | Added new empty file `dev-docs`.                                                                                 |
| `README.md`                                                                                 | Updated phrasing of "Data SMS support" feature description, changed emoji, and added a link to detailed feature page. |
| `.../modules/gateway/Module.kt`                                                             | Renamed constant `NAME` to `MODULE_NAME` without changing value or usage.                                        |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant GatewayApi
    participant GatewayService
    participant MessagesService
    participant SmsManager

    Client->>GatewayApi: Sends message (text or data)
    GatewayApi->>GatewayService: Parses message into MessageContent (Text/Data)
    GatewayService->>MessagesService: Processes message content
    alt Data message
        MessagesService->>SmsManager: sendDataMessage(data, port.toShort())
    else Text message
        MessagesService->>SmsManager: sendTextMessage(text)
    end

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 0c8446050b2d9f3521931250ff9cfca50f56cf90 and 429f7d691bfeebe662383a7ac39e0d6ae5b7903b.

</details>

<details>
<summary>📒 Files selected for processing (8)</summary>

* `README.md` (1 hunks)
* `app/src/main/java/me/capcom/smsgateway/domain/MessageContent.kt` (1 hunks)
* `app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayApi.kt` (2 hunks)
* `app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayService.kt` (4 hunks)
* `app/src/main/java/me/capcom/smsgateway/modules/gateway/Module.kt` (1 hunks)
* `app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt` (1 hunks)
* `app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt` (1 hunks)
* `dev-docs` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (1)</summary>

* app/src/main/java/me/capcom/smsgateway/domain/MessageContent.kt

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (7)</summary>

* dev-docs
* app/src/main/java/me/capcom/smsgateway/modules/gateway/Module.kt
* app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt
* app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt
* README.md
* app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayService.kt
* app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayApi.kt

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4BtItRIB3NLIC66WvUTZu3fBVxIADN/SFpqNEg2REQ0UkQDADlsZgFKLgAmAGYAdgMAVUR0xjRuJmYANiN9Y3AoMnp8IJwCYjJlGnpytgxOHj5BETFJaUg5BSUqVXUtHRqTKDhUVEwWwlJyKk6FVnYuKkdIb1Y0CnlxpkmVNU1tXTBDWtMDUu4AekQKBjfmbQw3oRoCRoH4kN4MUrlD7MRD2GjOWRvWgsP5vACy0lipAAwvheuwNABrTgGABE5IMAGJKZAAIIASTamwcXhSvzO/GaDFgmHiZlgJEguFk3EFTSFAsgAAM/AEpf18KKAvJ4FhcJKpQARCLy7wCBgWNAxTkSwVFNBWLqG41SjExOIkXH43ry5zIbm8ujBCgsdBHeBEcj0ACMFTANxQ+NIfAAFFKAMqwfy4KUASiF+HQWGwGEQAaDkFD4fUkZo0cgcfyieTaY0MAQyGYingQXgo3VgqoGFIJuBFng9D72FGIT4Mpr3t9YCyGRyFQAHBnIDO5zklwAGJcVACs26y27riUz+A7fA93fbmYs+CI8AYABoFL0fRZgtfHI/QpQfXweRhaP23aQI4lCCr8SgaEYRjUnSFg0Fs8B4sgBCmmEoiGghSEmiQAAesrbKE3DYAI/YMJA7DqG2CQGFA2J/qQ9C8IqlDCkKIqCqq0rhLgkQGkayDajx8pMLmuAUNgYj+Fw44BFw1ZypAgBJhNK+FcFWSYKZxtqYg6To0C6RwkBaXp8caWmvB8Xw/KigLAqC4KQiw0Kwg4CJIiiqrojpOJ4vpmjElKZIUjRzwWZ83y/J5tkgmwDllE5iAwnCTguD8ijYFYiBvMlbkAOKuS4tLcPARIkuSpJUjSDJMh0XrHOy8jiuefIGLShnGVa/HSnaWKOr57CukapY+rQEle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ilCm8W8Gj293hO9esARbte97sMVB8XsJsnt0R0orAQdKVeiIcBiTDYd/SG8V8dVMBAhX4QDOd5BHCGDEhaQ2j5RPCxhvCsAUj9kI5MxbQ2ZNR8gZUa0RZez+zeV+C8Asxr9T5Ot1BGSX9Ez5c4sM59pDxjxRSA0MAg0L1QhD0xAk4dEAswYgzwJm8wyKE8i4yozljxDijmgWFSidyKtOEFCG8oAAA1U4HmSmW5bsro6URRBcmtSAAAXkgFJCe1JHlGUheR0TRCnJnLnNgoQqQpQuVXRjJT72YCPwH1aw6IrOkA0Ce142otmwzJqAMAWC4UaGaDQDwHWH6O2G6D2FT0OEGI5AuEUGUGmFuDmAeBYrqBBPUBFgHEQBFgWKcDoBFkOlOECGYtYvnAABZ1xgwMhgwch5wMhaAdwdKABOKy7cDINACoEgAQYMbcecdcCymccIAQLILINIIIdcHIZoeYGS+cMyqynINAecHIYMececLITwIICyjICoCy4yhgCoBgHIHINykgTKrIdcHStAHSoIAQDIe4QwVihgYMNAOcbcBcbcCy4MRy4MYMSy+cEgZy3K0MWgUyz2OynIBgCyioIIHcAKqS1iiy7cHSpQKqioHS7cEgQyxK+ygQGyoIPcLIEgCobygQdcNAdcfqoyoyDIRcQKiASAPa3SnSiodcbcdcYq2gCyoIfcQytygym6n9CyhgIICEN6mqz6iyzcE6qAHSjIB6nIEKhq39ByjaiobIGKqqr+LICykgdcMytANqgQTK9cby0qp4KAboOShSpS4AtsECWgEWEk/QIAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings
<details open="true">
<summary>🧪 Generate Unit Tests</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Create PR with Unit Tests
- [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Post Copyable Unit Tests in a Comment
- [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Commit Unit Tests in branch `feature/cloud-data-messages`

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=capcom6/android-sms-gateway&utm_content=237):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai auto-generate unit tests` to generate unit tests for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayApi.kt (1)

203-208: Consider safer error handling in the computed property.

The computed content property throws a RuntimeException when no valid content is found, which could cause runtime crashes. Consider returning a nullable type or using a sealed class for error states to enable better error handling at compile time.

-    val content: MessageContent
-        get() = this._dataMessage
-            ?: this._textMessage
-            ?: _message?.let { MessageContent.Text(it) }
-            ?: throw RuntimeException("Invalid message content")
+    val content: MessageContent?
+        get() = this._dataMessage
+            ?: this._textMessage
+            ?: _message?.let { MessageContent.Text(it) }

Alternatively, consider using a validation method that can be called during deserialization to fail early with better context.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d19025f and 8401217.

📒 Files selected for processing (5)
  • app/src/main/java/me/capcom/smsgateway/domain/MessageContent.kt (1 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayApi.kt (2 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayService.kt (1 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt (1 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt (1 hunks)
🔇 Additional comments (6)
app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt (1)

372-372: LGTM: Necessary type conversion for SMS API compatibility.

The conversion from UShort to Short is required because the SmsManager.sendDataMessage() API expects a signed short, while the domain model now correctly uses UShort for port values. The conversion is safe as both types can represent the full valid port range (0-65535).

app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt (1)

141-141: LGTM: Correct type conversion aligning with domain model.

The conversion to UShort correctly aligns with the updated MessageContent.Data definition. The existing port validation (lines 79-85) ensures the value is within the valid range (0-65535) before this conversion, making the operation safe.

app/src/main/java/me/capcom/smsgateway/domain/MessageContent.kt (1)

10-10: LGTM: Improved semantic correctness for port representation.

Changing the port type from Short to UShort is semantically correct since port numbers are inherently unsigned values ranging from 0 to 65535. This improves type safety and makes the domain model more accurate.

app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayService.kt (1)

208-214: LGTM: Proper handling of new message content types.

The when expression correctly maps the API MessageContent types to domain types, handling both Text and Data message variants. The mapping preserves all necessary data (text for Text messages, data and port for Data messages) and integrates well with the new sealed class hierarchy.

app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayApi.kt (2)

175-184: LGTM: Well-designed sealed class hierarchy.

The MessageContent sealed class provides excellent type safety and clear separation between text and data messages. Using UShort for the port in the Data class is semantically correct for representing port numbers (0-65535 range).


186-202: LGTM: Backward-compatible message structure.

The multiple nullable properties with @SerializedName annotations provide good backward compatibility while supporting the new message content types. The priority order (_dataMessage → _textMessage → _message) in the computed property is logical and maintains expected behavior.

@capcom6 capcom6 force-pushed the feature/cloud-data-messages branch from 0c84460 to 429f7d6 Compare July 2, 2025 02:22
@capcom6 capcom6 marked this pull request as ready for review July 2, 2025 07:06
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 2, 2025

🤖 Pull request artifacts

file commit
app-release.apk 429f7d6
app-release.aab 429f7d6

@capcom6 capcom6 merged commit 327b9e7 into master Jul 7, 2025
5 checks passed
@capcom6 capcom6 deleted the feature/cloud-data-messages branch July 7, 2025 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant