Skip to content

Comments

[localserver] support for deviceId field in messages#238

Merged
capcom6 merged 1 commit intomasterfrom
localserver/explicit-device-selection
Jul 9, 2025
Merged

[localserver] support for deviceId field in messages#238
capcom6 merged 1 commit intomasterfrom
localserver/explicit-device-selection

Conversation

@capcom6
Copy link
Owner

@capcom6 capcom6 commented Jul 7, 2025

Summary by CodeRabbit

  • New Features

    • Added device ID to message request and response data for clearer device identification.
    • Introduced device ID validation to ensure requests originate from the configured device.
    • Added optional filtering of devices by recent activity in message sending.
    • Updated API documentation to reflect new device ID fields and query parameters.
  • Bug Fixes

    • Enhanced validation to reject requests with mismatched device IDs, providing clear error messages.

@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

"""

Walkthrough

The changes update device ID handling in the local server module. Device IDs are now sourced directly from settings instead of being computed. Message request and response data classes are extended to include device ID fields. Message route handlers validate incoming device IDs and include the device ID in responses. The API specification is updated to reflect these changes with new deviceId properties and an optional query parameter.

Changes

File(s) Change Summary
.../modules/localserver/WebService.kt Removed device ID generation logic; now uses settings.deviceId directly for the Device object.
.../domain/PostMessageRequest.kt Added nullable deviceId property to PostMessageRequest data class.
.../domain/PostMessageResponse.kt Added non-null deviceId property to PostMessageResponse data class.
.../routes/MessagesRoutes.kt Added dependency on LocalServerSettings, device ID validation in POST route, and device ID in responses.
docs/api/swagger.json Added optional deviceActiveWithin query parameter; added optional deviceId to Message schema and required deviceId to MessageStatus schema.
.idea/vcs.xml Modified VCS directory mapping from $PROJECT_DIR$ to empty string "".

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant MessagesRoutes
    participant LocalServerSettings
    participant MessageService

    Client->>MessagesRoutes: POST /messages (with deviceId)
    MessagesRoutes->>LocalServerSettings: Get deviceId
    MessagesRoutes->>MessagesRoutes: Validate request.deviceId == settings.deviceId
    alt Invalid deviceId
        MessagesRoutes-->>Client: 400 Bad Request ("Invalid device ID")
    else Valid deviceId
        MessagesRoutes->>MessageService: Create message
        MessageService-->>MessagesRoutes: Message object
        MessagesRoutes-->>Client: PostMessageResponse (includes deviceId)
    end
Loading

Possibly related PRs


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ac0a0b2 and 5b3b6a4.

📒 Files selected for processing (6)
  • .idea/vcs.xml (1 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/WebService.kt (2 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageRequest.kt (1 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.kt (1 hunks)
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt (6 hunks)
  • docs/api/swagger.json (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .idea/vcs.xml
🚧 Files skipped from review as they are similar to previous changes (5)
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageRequest.kt
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.kt
  • docs/api/swagger.json
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt
  • app/src/main/java/me/capcom/smsgateway/modules/localserver/WebService.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build / build-apk
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch localserver/explicit-device-selection

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • 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 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 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 1

🧹 Nitpick comments (1)
docs/api/swagger.json (1)

1155-1162: Consider tightening the deviceId definition

deviceId is declared as an arbitrary nullable string, but every other occurrence in the spec uses a 21-char base-62 identifier (see examples at lines 736 and 1299). Adding a pattern constraint keeps clients & server validation aligned and prevents silent truncation / mismatch.

               "deviceId": {
                 "type": "string",
                 "nullable": true,
-                "description": "Optional device ID for explicit selection",
+                "description": "Optional device ID for explicit selection.",
+                "pattern": "^[A-Za-z0-9]{21}$",
                 "maxLength": 21,
                 "example": "PyDmBQZZXYmyxMwED8Fzy"
               }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c89b198 and 65d3600.

📒 Files selected for processing (1)
  • docs/api/swagger.json (2 hunks)

@capcom6 capcom6 force-pushed the localserver/explicit-device-selection branch 2 times, most recently from 65193aa to ac0a0b2 Compare July 8, 2025 04:24
@capcom6 capcom6 marked this pull request as ready for review July 8, 2025 12:10
@capcom6 capcom6 force-pushed the localserver/explicit-device-selection branch from ac0a0b2 to 5b3b6a4 Compare July 8, 2025 23:13
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2025

🤖 Pull request artifacts

file commit
app-release.apk 5b3b6a4
app-release.aab 5b3b6a4

@capcom6 capcom6 merged commit 33d4384 into master Jul 9, 2025
3 checks passed
@capcom6 capcom6 deleted the localserver/explicit-device-selection branch July 9, 2025 02:28
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