[localserver] implement message content access#340
Conversation
WalkthroughReworked localserver message domain into a messages subpackage with typed content (Text/Data/Hashed), changed persistence serialization and enqueue flow to return persisted messages and raise conflicts, updated routes to honor includeContent and surface 400/409, and expanded/modified OpenAPI schemas and auth/token endpoints. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Routes as MessagesRoutes
participant Service as MessagesService
participant Repo as MessagesRepository
participant DB as Database
rect rgba(100,150,200,0.5)
Note over Client,DB: POST /inbox — enqueue with conflict handling
Client->>Routes: POST /inbox (SendRequest)
Routes->>Service: enqueueMessage(request)
Service->>Repo: enqueue(request)
Repo->>DB: insert message
alt duplicate ID
DB-->>Repo: constraint error
Repo-->>Service: throws ConflictException
Service-->>Routes: exception
Routes-->>Client: 409 Conflict
else success
DB-->>Repo: MessageWithRecipients
Repo-->>Service: MessageWithRecipients
Service-->>Routes: MessageWithRecipients
Routes->>Routes: toDomain(deviceId, includeContent=true)
Routes-->>Client: 200 OK (message with content)
end
end
rect rgba(150,100,200,0.5)
Note over Client,DB: GET /inbox — conditional content inclusion
Client->>Routes: GET /inbox?includeContent=true
Routes->>Routes: parse includeContent (400 if invalid)
Routes->>DB: fetch messages
DB-->>Routes: messages list
Routes->>Routes: map each message toDomain(includeContent)
Routes-->>Client: 200 OK (list with/without content)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/main/assets/api/swagger.json (1)
662-719:⚠️ Potential issue | 🟠 Major
GET /messages/{id}is now out of contract in OpenAPI.These properties were added only to
smsgateway.MessageState, but/messages/{id}still advertisessmsgateway.GetMessageResponse. Please mirrortextMessageanddataMessageintosmsgateway.GetMessageResponsestarting at Line 338, or switch that endpoint to a schema that includes them, otherwise generated clients for the single-message endpoint will miss fields the server now returns.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/assets/api/swagger.json` around lines 662 - 719, The OpenAPI contract is out of sync: the new textMessage and dataMessage properties were added to smsgateway.MessageState but not to smsgateway.GetMessageResponse used by GET /messages/{id}; update the GetMessageResponse schema (or change the /messages/{id} response to reference a schema that includes these fields) to include the textMessage and dataMessage properties (same structure/refs used in smsgateway.MessageState) so generated clients receive the same fields the server returns.
🧹 Nitpick comments (1)
app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt (1)
58-66: Please add route coverage for the newincludeContentbranches.This change adds a new 400 path, changes the
/messagesresponse shape, and makes/messages/{id}depend on the same content mapper, but there are no tests covering omitted/true/invalidincludeContentvalues or text/data payload mapping.Also applies to: 119-121, 300-300, 321-364
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt` around lines 58 - 66, Add tests to cover the new includeContent query handling and response mapping: exercise the MessagesRoutes handlers that serve the /messages list and /messages/{id} endpoints (locate the route code around the includeContent parsing block and the content-mapper function used for both list and single-item responses). Specifically add cases for includeContent=false (default) to assert text/data payloads are omitted and response shape unchanged, includeContent=true to assert the mapper returns text/data fields correctly, and an invalid value (e.g., includeContent=notabool) to assert a 400 with message "includeContent must be true or false". Also update existing message-list and message-by-id test expectations to use the same content-mapper assertions so both endpoints are covered under omitted/true/invalid branches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt`:
- Around line 321-336: In MessageWithRecipients.toDomain (the includeContent
branch) wrap each gson.fromJson call for MessageContent.Text and
MessageContent.Data in a try/catch so a malformed message.content does not throw
for the whole GET /messages; on parse exception for the current row, log/debug
the error and return null (or an empty safe placeholder) for that message's
content while allowing the rest of the conversion to proceed. Ensure you only
catch JSON parsing exceptions around gson.fromJson for message.content and leave
other logic unchanged.
---
Outside diff comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 662-719: The OpenAPI contract is out of sync: the new textMessage
and dataMessage properties were added to smsgateway.MessageState but not to
smsgateway.GetMessageResponse used by GET /messages/{id}; update the
GetMessageResponse schema (or change the /messages/{id} response to reference a
schema that includes these fields) to include the textMessage and dataMessage
properties (same structure/refs used in smsgateway.MessageState) so generated
clients receive the same fields the server returns.
---
Nitpick comments:
In
`@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt`:
- Around line 58-66: Add tests to cover the new includeContent query handling
and response mapping: exercise the MessagesRoutes handlers that serve the
/messages list and /messages/{id} endpoints (locate the route code around the
includeContent parsing block and the content-mapper function used for both list
and single-item responses). Specifically add cases for includeContent=false
(default) to assert text/data payloads are omitted and response shape unchanged,
includeContent=true to assert the mapper returns text/data fields correctly, and
an invalid value (e.g., includeContent=notabool) to assert a 400 with message
"includeContent must be true or false". Also update existing message-list and
message-by-id test expectations to use the same content-mapper assertions so
both endpoints are covered under omitted/true/invalid branches.
🪄 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: 675d1db1-22cc-44cf-affe-8abd85c5f3f7
📒 Files selected for processing (4)
app/src/main/assets/api/swagger.jsonapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.ktdocs/plans/messages-content-in-list-plan.md
0b029df to
7b92ffe
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt (1)
332-348:⚠️ Potential issue | 🟠 MajorWrap content deserialization in try-catch to prevent one malformed record from failing the entire response.
The
message.textContentandmessage.dataContentproperties internally callgson.fromJson(), which can throwJsonSyntaxExceptionif the storedcontentJSON is malformed. Since these are optional fields, a parse failure for one message should not abort the entireGET /messagesresponse.🛡️ Proposed fix with error isolation
- textMessage = when (includeContent) { - true -> message.textContent?.let { - TextMessage(it.text) - } - - else -> null - }, - dataMessage = when (includeContent) { - true -> message.dataContent?.let { - me.capcom.smsgateway.modules.localserver.domain.DataMessage( - data = it.data, - port = it.port.toInt() - ) - } - - else -> null - }, + textMessage = if (includeContent) { + try { + message.textContent?.let { TextMessage(it.text) } + } catch (e: Exception) { + null + } + } else null, + dataMessage = if (includeContent) { + try { + message.dataContent?.let { + me.capcom.smsgateway.modules.localserver.domain.DataMessage( + data = it.data, + port = it.port.toInt() + ) + } + } catch (e: Exception) { + null + } + } else null,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt` around lines 332 - 348, The deserialization of message.textContent and message.dataContent can throw JsonSyntaxException and must be isolated so one bad record doesn't fail the whole GET /messages response; wrap each access to message.textContent and message.dataContent in a try-catch that catches JsonSyntaxException (or Exception) and on parse error log the failure and return null for that field so TextMessage(...) or DataMessage(...) is only constructed on successful parse; update the mapping in MessagesRoutes.kt where includeContent is handled (the when branches constructing TextMessage and me.capcom.smsgateway.modules.localserver.domain.DataMessage) to perform the safe-parse logic instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt`:
- Around line 83-93: The gson instance used by the dataContent getter cannot
deserialize MessageContent.Data.port (UShort) because Gson has no UShort
support; replace the plain Gson() with a GsonBuilder configured to register a
UShort TypeAdapter (e.g. registerTypeAdapter for UShort via a UShortTypeAdapter)
and create() it, or ensure the existing gson creation/extension registers that
UShort adapter so gson.fromJson(content, MessageContent.Data::class.java)
succeeds; update the gson initialization (the variable named gson) rather than
changing the dataContent getter logic.
---
Duplicate comments:
In
`@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt`:
- Around line 332-348: The deserialization of message.textContent and
message.dataContent can throw JsonSyntaxException and must be isolated so one
bad record doesn't fail the whole GET /messages response; wrap each access to
message.textContent and message.dataContent in a try-catch that catches
JsonSyntaxException (or Exception) and on parse error log the failure and return
null for that field so TextMessage(...) or DataMessage(...) is only constructed
on successful parse; update the mapping in MessagesRoutes.kt where
includeContent is handled (the when branches constructing TextMessage and
me.capcom.smsgateway.modules.localserver.domain.DataMessage) to perform the
safe-parse logic instead.
🪄 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: ea637741-2f67-45e6-b970-817294baaeed
📒 Files selected for processing (5)
app/src/main/assets/api/swagger.jsonapp/src/main/java/me/capcom/smsgateway/data/entities/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.kt
✅ Files skipped from review due to trivial changes (1)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/Message.kt
🤖 Pull request artifacts
|
includeContent to GET /messages and include message payloads in list responsesThere was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/Message.kt`:
- Around line 12-14: The Message model exposes hashedMessage but MessagesRoutes
constructs Message with hashedMessage = null causing inconsistent state with
isHashed; update the route that builds Message (in MessagesRoutes.kt) to
populate hashedMessage when isHashed is true (or remove/derive isHashed if you
prefer) by creating the appropriate HashedMessage instance from the existing
hashing logic/payload used elsewhere, and set hashedMessage = null only when
isHashed is false to keep Message.kt’s fields consistent with the isHashed flag.
In `@app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt`:
- Around line 93-95: The new throw in MessagesService.enqueueMessage (the
getMessage(request.message.id) != null branch) makes duplicates raise
ConflictException and breaks non-HTTP callers like
GatewayService.enqueueMessage; change enqueueMessage to be idempotent instead:
if getMessage(request.message.id) != null, return the existing
Message/appropriate result (or a boolean indicating already-enqueued) instead of
throwing, so callers such as GatewayService.enqueueMessage can continue without
catching exceptions; update the method signature/return type if needed and
adjust MessagesRoutes to still translate the "already exists" result into an
HTTP 409 where required.
🪄 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: 6ecfdfc1-fdf4-4442-bf10-70b18e3a7512
📒 Files selected for processing (7)
app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/HashedMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageRequest.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
✅ Files skipped from review due to trivial changes (3)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageRequest.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/HashedMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
🚧 Files skipped from review as they are similar to previous changes (2)
- app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt
a207a1e to
4bad1eb
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/main/assets/api/swagger.json (1)
397-405:⚠️ Potential issue | 🔴 CriticalRemove
type: objectfrom allOf properties referencing scalar schemas.The properties at the specified lines use
allOfto reference scalar enum schemas (smsgateway.ProcessingState,smsgateway.MessagePriority,smsgateway.WebhookEvent), which are defined astype: stringortype: integer. Adding"type": "object"creates a schema contradiction—the examples show scalar values ("Pending",0,"sms:received"), not objects. This will cause validation and code generation issues.Suggested fix
"state": { "allOf": [ { "$ref": "#/components/schemas/smsgateway.ProcessingState" } ], "description": "State", "example": "Pending", - "type": "object" }"priority": { "allOf": [ { "$ref": "#/components/schemas/smsgateway.MessagePriority" } ], "description": "Priority, messages with values greater than `99` will bypass limits and delays", "example": 0, - "type": "object" }Apply the same removal to lines 794-802, 874-882, and 1094-1102.
Also applies to: 634-642, 794-802, 874-882, 1094-1102
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/assets/api/swagger.json` around lines 397 - 405, The OpenAPI properties like "state" that use allOf to reference scalar enum schemas (e.g., smsgateway.ProcessingState, smsgateway.MessagePriority, smsgateway.WebhookEvent) must not declare "type": "object" — remove the "type": "object" entries from those allOf property blocks (including the ones referencing the examples "Pending", 0, "sms:received") so the schema remains a scalar (string/integer) and matches the referenced enum; apply the same removal for all occurrences referencing those schemas (also present in the other allOf blocks for the same enums).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 1279-1302: The JWTAuth security scheme in the OpenAPI spec was
changed to a generic apiKey and no longer documents Bearer semantics, and the
/auth/token/refresh operation reuses JWTAuth without specifying how the refresh
token is supplied; either restore JWTAuth to a Bearer HTTP scheme (HTTP type
with scheme "bearer" and bearerFormat "JWT") so Authorization: Bearer <token> is
documented, or add a distinct security scheme or explicit requestBody/parameter
for the refresh token on /auth/token/refresh (e.g., a RefreshToken scheme or a
body parameter named refresh_token) so clients know where to send the refresh
token; update the swagger.json entries for "JWTAuth" and the /auth/token/refresh
operation accordingly (refer to symbols JWTAuth and /auth/token/refresh).
---
Outside diff comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 397-405: The OpenAPI properties like "state" that use allOf to
reference scalar enum schemas (e.g., smsgateway.ProcessingState,
smsgateway.MessagePriority, smsgateway.WebhookEvent) must not declare "type":
"object" — remove the "type": "object" entries from those allOf property blocks
(including the ones referencing the examples "Pending", 0, "sms:received") so
the schema remains a scalar (string/integer) and matches the referenced enum;
apply the same removal for all occurrences referencing those schemas (also
present in the other allOf blocks for the same enums).
🪄 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: f27f3c50-5faf-408f-95ff-a696f0d4a4ab
📒 Files selected for processing (1)
app/src/main/assets/api/swagger.json
f703d38 to
215a6dc
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (2)
app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt (1)
326-342:⚠️ Potential issue | 🟠 MajorWrap content parsing to prevent single malformed message from failing entire response.
When
includeContent=true,message.textContentandmessage.dataContentcallgson.fromJson()internally. If any message has corrupted/malformed JSON content, the exception will propagate and fail the entireGET /messagesresponse. Since these fields are optional, isolate parsing failures per item.🛡️ Proposed fix
- textMessage = when (includeContent) { - true -> message.textContent?.let { - TextMessage(it.text) - } - - else -> null - }, - dataMessage = when (includeContent) { - true -> message.dataContent?.let { - DataMessage( - data = it.data, - port = it.port.toInt() - ) - } - - else -> null - }, + textMessage = if (includeContent) { + runCatching { message.textContent } + .getOrNull() + ?.let { TextMessage(it.text) } + } else null, + dataMessage = if (includeContent) { + runCatching { message.dataContent } + .getOrNull() + ?.let { DataMessage(data = it.data, port = it.port.toInt()) } + } else null,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt` around lines 326 - 342, In MessagesRoutes.kt, when includeContent is true you must guard the per-message parsing of message.textContent and message.dataContent (which call gson.fromJson) so a single malformed JSON doesn't fail the whole GET /messages response; wrap the parsing logic used to create TextMessage(...) and DataMessage(...) in try/catch blocks, catch JSON parsing exceptions from gson.fromJson, log the error with message identifier/context, and return null for textMessage or dataMessage on failure so the rest of the items still return; update the branches that set textMessage and dataMessage to use these safe-parsing wrappers.app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt (1)
89-93:⚠️ Potential issue | 🔴 CriticalGson lacks native
UShortsupport — deserialization ofMessageContent.Data.portwill fail.The
dataContentgetter at line 91 callsgson.fromJson(content, MessageContent.Data::class.java), butMessageContent.Datahas aport: UShortfield. The plainGson()instance at line 100 has no customTypeAdapterforUShort, so deserialization will fail at runtime.Register a
UShorttype adapter:🛠️ Proposed fix
- private val gson = Gson() + private val gson = GsonBuilder() + .registerTypeAdapter(UShort::class.java, object : JsonDeserializer<UShort>, JsonSerializer<UShort> { + override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): UShort { + return json.asInt.toUShort() + } + override fun serialize(src: UShort, typeOfSrc: Type, context: JsonSerializationContext): JsonElement { + return JsonPrimitive(src.toInt()) + } + }) + .create()Add these imports:
import com.google.gson.GsonBuilder import com.google.gson.JsonDeserializer import com.google.gson.JsonSerializer import com.google.gson.JsonDeserializationContext import com.google.gson.JsonSerializationContext import com.google.gson.JsonElement import com.google.gson.JsonPrimitive import java.lang.reflect.TypeAlso applies to: 100-100
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt` around lines 89 - 93, The dataContent getter uses gson.fromJson to parse MessageContent.Data which contains a port: UShort, but the gson instance (gson) has no UShort TypeAdapter so deserialization will fail; register a Gson TypeAdapter/serializer/deserializer for kotlin.UShort on the gson used (the gson property/instance) so UShort values are converted to/from JSON (e.g., serialize as number/string and deserialize back to UShort), then rebuild the gson used by the dataContent getter to use that adapter (update the gson construction where the gson instance is created).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt`:
- Around line 89-93: The dataContent getter uses gson.fromJson to parse
MessageContent.Data which contains a port: UShort, but the gson instance (gson)
has no UShort TypeAdapter so deserialization will fail; register a Gson
TypeAdapter/serializer/deserializer for kotlin.UShort on the gson used (the gson
property/instance) so UShort values are converted to/from JSON (e.g., serialize
as number/string and deserialize back to UShort), then rebuild the gson used by
the dataContent getter to use that adapter (update the gson construction where
the gson instance is created).
In
`@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt`:
- Around line 326-342: In MessagesRoutes.kt, when includeContent is true you
must guard the per-message parsing of message.textContent and
message.dataContent (which call gson.fromJson) so a single malformed JSON
doesn't fail the whole GET /messages response; wrap the parsing logic used to
create TextMessage(...) and DataMessage(...) in try/catch blocks, catch JSON
parsing exceptions from gson.fromJson, log the error with message
identifier/context, and return null for textMessage or dataMessage on failure so
the rest of the items still return; update the branches that set textMessage and
dataMessage to use these safe-parsing wrappers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7f0aeea5-386a-4699-b71e-756265d378e7
📒 Files selected for processing (13)
app/src/main/assets/api/swagger.jsonapp/src/main/java/me/capcom/smsgateway/data/entities/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/PostMessageRequest.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
💤 Files with no reviewable changes (2)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.kt
✅ Files skipped from review due to trivial changes (5)
- app/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.kt
- app/src/main/assets/api/swagger.json
🚧 Files skipped from review as they are similar to previous changes (4)
- app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.kt
- app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/PostMessageRequest.kt
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/main/assets/api/swagger.json (1)
397-406:⚠️ Potential issue | 🟠 MajorIncorrect
type: objectfor enum reference will break code generators.The
statefield referencessmsgateway.ProcessingState(a string enum) viaallOf, but declares"type": "object". This contradicts the referenced schema's"type": "string"and can cause code generators to emit incorrect types.The same issue appears in:
- Line 642:
Message.priority(should be integer, not object)- Line 802:
MessageState.state(should be string, not object)- Line 882:
RecipientState.state(should be string, not object)- Line 1101:
Webhook.event(should be string, not object)Remove the
"type": "object"from these fields or change to match the referenced enum's type.🛠️ Proposed fix for GetMessageResponse.state (apply similar fix to other affected fields)
"state": { "allOf": [ { "$ref": "#/components/schemas/smsgateway.ProcessingState" } ], "description": "State", - "example": "Pending", - "type": "object" + "example": "Pending" },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/assets/api/swagger.json` around lines 397 - 406, The referenced schema entries (e.g., GetMessageResponse.state, Message.priority, MessageState.state, RecipientState.state, Webhook.event) declare "type": "object" while using allOf to $ref enum schemas (like smsgateway.ProcessingState) whose type is string or integer; remove the incorrect "type": "object" (or replace it with the correct primitive type matching the referenced schema, e.g., "type": "string" for smsgateway.ProcessingState or "type": "integer" for priority) so the allOf/$ref and declared type are consistent and code generators produce correct types.
🧹 Nitpick comments (1)
app/src/main/assets/api/swagger.json (1)
349-422: ClarifyhashedMessageinclusion behavior.The descriptions for
textMessageanddataMessagestate they're present "only whenincludeContent=true", buthashedMessagedescription says "if isHashed is true" without mentioningincludeContent. IshashedMessagealways returned whenisHashed=true, regardless ofincludeContent? If so, document this explicitly. If not, align the description with the other fields.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/assets/api/swagger.json` around lines 349 - 422, The swagger schema is ambiguous about when smsgateway.HashedMessage is returned: update the description for the hashedMessage property to explicitly state whether it is gated by includeContent or returned whenever isHashed=true to match textMessage/dataMessage behavior; specifically edit the hashedMessage description to either "Present only when `includeContent=true` and `isHashed=true`" or "Returned when `isHashed=true` regardless of `includeContent`" (choose the correct behavior), ensuring consistency with the textMessage and dataMessage descriptions and referencing the hashedMessage, textMessage, dataMessage, includeContent and isHashed symbols so reviewers can locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 1074-1077: The OpenAPI spec lists "refresh_token" in TokenResponse
but the backend data class TokenResponse (TokenResponse.kt) does not include
that field; either remove "refresh_token" from
app/src/main/assets/api/swagger.json or add a corresponding property to the
TokenResponse data class and ensure serialization names match ("refresh_token"
vs refreshToken). Locate the TokenResponse class and the TokenResponse schema in
swagger.json, then either delete the "refresh_token" entry from the JSON schema
or add a String? refreshToken (with appropriate
`@JsonProperty`("refresh_token")/serialization annotation and any nullable
handling) and update any creation/mapper code that constructs TokenResponse so
the server returns the field consistently.
---
Outside diff comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 397-406: The referenced schema entries (e.g.,
GetMessageResponse.state, Message.priority, MessageState.state,
RecipientState.state, Webhook.event) declare "type": "object" while using allOf
to $ref enum schemas (like smsgateway.ProcessingState) whose type is string or
integer; remove the incorrect "type": "object" (or replace it with the correct
primitive type matching the referenced schema, e.g., "type": "string" for
smsgateway.ProcessingState or "type": "integer" for priority) so the allOf/$ref
and declared type are consistent and code generators produce correct types.
---
Nitpick comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 349-422: The swagger schema is ambiguous about when
smsgateway.HashedMessage is returned: update the description for the
hashedMessage property to explicitly state whether it is gated by includeContent
or returned whenever isHashed=true to match textMessage/dataMessage behavior;
specifically edit the hashedMessage description to either "Present only when
`includeContent=true` and `isHashed=true`" or "Returned when `isHashed=true`
regardless of `includeContent`" (choose the correct behavior), ensuring
consistency with the textMessage and dataMessage descriptions and referencing
the hashedMessage, textMessage, dataMessage, includeContent and isHashed symbols
so reviewers can locate the change.
🪄 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: 3c013ef2-3ed0-4cfb-ab51-2f16eddab223
📒 Files selected for processing (1)
app/src/main/assets/api/swagger.json
fdac3a4 to
75cf7aa
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt (1)
89-92:⚠️ Potential issue | 🔴 Critical
MessageContent.Data.portdeserialization is unsafe with plain Gson.
dataContent(Line 89-Line 92) uses thegsoninstance from Line 100 (Gson()), butMessageContent.Data.portisUShort. This can fail at runtime when reading Data messages.#!/bin/bash # Verify whether UShort Gson adapters exist and how gson is initialized for Message deserialization. rg -n "UShort|TypeAdapter|registerTypeAdapter|GsonBuilder\\(|Gson\\(" --type=kt -C2 sed -n '80,110p' app/src/main/java/me/capcom/smsgateway/data/entities/Message.ktAlso applies to: 100-100
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt` around lines 89 - 92, The current dataContent getter uses the plain gson instance (Gson()) which cannot safely deserialize MessageContent.Data.port of type UShort; create and use a GsonBuilder-backed gson that registers a custom TypeAdapter/JsonSerializer/JsonDeserializer for kotlin.UShort (or its boxed class) that converts numeric JSON values into UShort and handles nulls/invalid values, replace the simple Gson() assignment with this GsonBuilder configuration, and ensure the Message.dataContent getter continues to use that gson so MessageContent.Data.port is deserialized safely.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt`:
- Around line 93-98: The pre-check using getMessage(...) before calling
messages.enqueue(...) is TOCTOU-racy and can let two concurrent requests slip
through; remove the pre-check and make conflict detection atomic by either
relying on messages.enqueue(...) to fail deterministically or by catching the
low-level DB unique-constraint exception thrown by messages.enqueue(...) and
rethrowing ConflictException(); update the MessagesService.kt flow so calls to
messages.enqueue(request) are wrapped to translate DB constraint errors into
ConflictException (reference getMessage, messages.enqueue, and
ConflictException).
---
Duplicate comments:
In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt`:
- Around line 89-92: The current dataContent getter uses the plain gson instance
(Gson()) which cannot safely deserialize MessageContent.Data.port of type
UShort; create and use a GsonBuilder-backed gson that registers a custom
TypeAdapter/JsonSerializer/JsonDeserializer for kotlin.UShort (or its boxed
class) that converts numeric JSON values into UShort and handles nulls/invalid
values, replace the simple Gson() assignment with this GsonBuilder
configuration, and ensure the Message.dataContent getter continues to use that
gson so MessageContent.Data.port is deserialized safely.
🪄 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: 68cd3e95-d63d-4a60-b422-eec7710ddf34
📒 Files selected for processing (13)
app/src/main/assets/api/swagger.jsonapp/src/main/java/me/capcom/smsgateway/data/entities/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/PostMessageRequest.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
💤 Files with no reviewable changes (2)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.kt
✅ Files skipped from review due to trivial changes (5)
- app/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.kt
- app/src/main/assets/api/swagger.json
🚧 Files skipped from review as they are similar to previous changes (3)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/PostMessageRequest.kt
fca9066 to
188853e
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (2)
app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt (1)
89-91:⚠️ Potential issue | 🔴 CriticalDon’t rely on plain
Gson()to round-trip KotlinUShort.
MessageContent.Data.portis a KotlinUShort, while Gson’s current docs describe built-in special handling around Java primitives/common types and exact-type custom adapters when you need something else. This means this newdataContentpath should be verified rather than assumed; if it is not adapter-backed here, the first data-message read can fail while building the new response payloads. (google.github.io)#!/bin/bash set -euo pipefail echo "MessageContent.Data definition:" sed -n '1,40p' app/src/main/java/me/capcom/smsgateway/domain/MessageContent.kt echo echo "Message entity JSON accessors:" sed -n '80,110p' app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt echo echo "Search for any UShort Gson adapter or configured GsonBuilder usage:" rg -nP --type=kt 'UShortTypeAdapter|registerTypeAdapter|GsonBuilder\(|TypeAdapter<\s*UShort'Expected:
MessageContent.Data.portisUShort, this file still usesprivate val gson = Gson(), and this path is not obviously wired through aUShortadapter. If that is what you see, switch this accessor path to the app’s configuredGsonBuilderor register an explicit adapter here.Also applies to: 95-100
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt` around lines 89 - 91, The dataContent getter uses a plain Gson instance (private val gson = Gson()) to deserialize MessageContent.Data which has a UShort field (MessageContent.Data.port); replace this with the app's configured Gson (the shared GsonBuilder instance) or create/register a UShort TypeAdapter and use that Gson for the dataContent getter (also update the similar accessor around lines 95-100) so UShort round-tripping is handled correctly rather than relying on the default Gson().app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt (1)
326-342:⚠️ Potential issue | 🟠 MajorDon’t let one bad payload abort the whole response.
message.textContent/message.dataContentcan throw here, and this helper is used by the paged list plus the always-includeGET /messages/{id}path. Because these fields are optional, degrade just that row tonullinstead of turning the entire response into a 500.💡 Minimal guard
- textMessage = when (includeContent) { - true -> message.textContent?.let { - TextMessage(it.text) - } - - else -> null - }, - dataMessage = when (includeContent) { - true -> message.dataContent?.let { - DataMessage( - data = it.data, - port = it.port.toInt() - ) - } - - else -> null - }, + textMessage = if (includeContent) { + try { + message.textContent?.let { TextMessage(it.text) } + } catch (_: RuntimeException) { + null + } + } else { + null + }, + dataMessage = if (includeContent) { + try { + message.dataContent?.let { + DataMessage( + data = it.data, + port = it.port.toInt() + ) + } + } catch (_: RuntimeException) { + null + } + } else { + null + },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt` around lines 326 - 342, In MessagesRoutes.kt where the response row builds textMessage and dataMessage (the when(includeContent) blocks that create TextMessage and DataMessage from message.textContent and message.dataContent), guard the optional payload access so a thrown exception degrades just that field to null instead of bubbling to a 500; wrap each message.textContent / message.dataContent access in a small try-catch (or use runCatching { … }.getOrNull()) and on failure return null for that field, keeping the rest of the row and the overall paged list / GET /messages/{id} response intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt`:
- Around line 89-91: The dataContent getter uses a plain Gson instance (private
val gson = Gson()) to deserialize MessageContent.Data which has a UShort field
(MessageContent.Data.port); replace this with the app's configured Gson (the
shared GsonBuilder instance) or create/register a UShort TypeAdapter and use
that Gson for the dataContent getter (also update the similar accessor around
lines 95-100) so UShort round-tripping is handled correctly rather than relying
on the default Gson().
In
`@app/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.kt`:
- Around line 326-342: In MessagesRoutes.kt where the response row builds
textMessage and dataMessage (the when(includeContent) blocks that create
TextMessage and DataMessage from message.textContent and message.dataContent),
guard the optional payload access so a thrown exception degrades just that field
to null instead of bubbling to a 500; wrap each message.textContent /
message.dataContent access in a small try-catch (or use runCatching { …
}.getOrNull()) and on failure return null for that field, keeping the rest of
the row and the overall paged list / GET /messages/{id} response intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2d8aae70-7f03-4d12-b5fa-249388574595
📒 Files selected for processing (13)
app/src/main/assets/api/swagger.jsonapp/src/main/java/me/capcom/smsgateway/data/entities/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/PostMessageRequest.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
💤 Files with no reviewable changes (2)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.kt
✅ Files skipped from review due to trivial changes (4)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.kt
🚧 Files skipped from review as they are similar to previous changes (3)
- app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.kt
- app/src/main/assets/api/swagger.json
188853e to
aa13121
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/main/assets/api/swagger.json (1)
397-405:⚠️ Potential issue | 🟠 MajorRemove
type: "object"from scalar$refwrappers.These properties reference scalar enum schemas—
smsgateway.ProcessingState(string values),smsgateway.MessagePriority(integer values), andsmsgateway.WebhookEvent(string values)—but are wrapped inallOfwithtype: "object", creating a contradictory constraint. Validators and code generators cannot reconcile requiring an object type with accepting only scalar enum values. Remove thetype: "object"line from these properties.Occurs at lines 397-405, 635-643, 794-803, 874-882, and 1094-1102.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/assets/api/swagger.json` around lines 397 - 405, Several properties (e.g., the "state" property wrapping smsgateway.ProcessingState, and similar wrappers for smsgateway.MessagePriority and smsgateway.WebhookEvent) use allOf to $ref scalar enum schemas but incorrectly include type: "object"; remove the type: "object" entry from those allOf wrappers so the referenced scalar enum types are not constrained to object, leaving the $ref, description and example intact; locate the wrappers referencing smsgateway.ProcessingState, smsgateway.MessagePriority, and smsgateway.WebhookEvent and delete only the "type": "object" line in each.
♻️ Duplicate comments (3)
app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt (2)
83-93:⚠️ Potential issue | 🟠 MajorGuard these computed accessors against bad stored payloads.
MessagesRoutes.toDomain()now reads these properties on both the list and detail endpoints. If any row hascontentthat does not match the declaredtype,fromJsonwill throw here and turn the whole response into a 500. Catch parse failures here and returnnull/fallback per record instead of letting one bad row break the endpoint.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt` around lines 83 - 93, The computed accessors textContent and dataContent currently call gson.fromJson(...) directly and will throw on malformed content; wrap each gson.fromJson call in a try-catch that catches JSON parse exceptions (e.g., JsonSyntaxException/JsonParseException/RuntimeException) and returns null on failure so a single bad payload doesn't raise a 500; modify the getters for textContent and dataContent to perform parsing inside the try block and return null in the catch, leaving other behavior unchanged.
89-100:⚠️ Potential issue | 🔴 CriticalUse a configured Gson for
MessageContent.Data.
MessageContent.Data.portisUShort, but this companion still uses a bareGson(). Gson does not deserialize Kotlin unsigned types out of the box, sodataContentwill fail at runtime for stored data messages until aUShortadapter or equivalent configured builder is used.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt` around lines 89 - 100, The current private gson in the Message companion uses a plain Gson which cannot deserialize Kotlin unsigned types (so Message.dataContent -> MessageContent.Data with UShort port will fail); replace the bare Gson() with the app's configured Gson instance or build a Gson via GsonBuilder that registers a UShort type adapter/serializer (or reuse an existing Gson provider) and assign it to the companion object's gson so Message.dataContent correctly deserializes MessageContent.Data.port; update the companion's private val gson accordingly (referencing the companion object, gson, dataContent and MessageContent.Data symbols).app/src/main/assets/api/swagger.json (1)
1279-1284:⚠️ Potential issue | 🟠 MajorDocument how clients supply the refresh token.
The operation says it refreshes "with specified refresh token", but there is no request body, parameter, or distinct security scheme—just the same
JWTAuthheader used by normal authenticated calls. As written, clients cannot tell whether this endpoint expects an access token or a refresh token inAuthorization.Also applies to: 1488-1547
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/assets/api/swagger.json` around lines 1279 - 1284, The OpenAPI entry for JWTAuth (name "Authorization", type "apiKey") doesn't explain how the refresh endpoint receives the refresh token; update the refresh operation to explicitly accept a refresh token either by (a) adding a distinct security scheme such as "RefreshTokenAuth" (in header or cookie) and reference it in the refresh operation's security requirement, or (b) adding a request parameter/body parameter named "refresh_token" (string) to the refresh operation and clarifying in its description that the Authorization header still expects the access token while the refresh_token parameter carries the refresh token; ensure the operation's description and schema reference "JWTAuth" and the new "RefreshTokenAuth" or "refresh_token" param so clients know which token goes where.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 349-357: The description for the dataMessage schema overstates the
includeContent requirement: update the "dataMessage" schema description (and the
analogous second block around lines ~414-421) to say that the object is present
for messages of type "data" and that inclusion depends on the endpoint (for list
endpoints it's present only when includeContent=true, whereas single-message
endpoints such as GET /messages/{id} always include content per
MessagesRoutes.kt). Change the phrasing to remove the absolute "Present only
when `includeContent=true`" and clearly state the endpoint-specific behavior so
the schema is accurate for both list and single-message responses.
- Around line 216-219: The OpenAPI schema requires Base64 but the server
(MessagesRoutes.kt handling POST /messages, around the dataMessage.data
handling) only checks for non-empty data; either align server to schema or relax
the schema—add a server-side Base64 validation in MessagesRoutes.kt: validate
dataMessage.data against the same regex
(^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$) and return a
400 with an explicit error when it fails, or alternatively remove the pattern
(and minLength/maxLength) from the swagger schema so the contract matches the
existing non-empty check.
---
Outside diff comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 397-405: Several properties (e.g., the "state" property wrapping
smsgateway.ProcessingState, and similar wrappers for smsgateway.MessagePriority
and smsgateway.WebhookEvent) use allOf to $ref scalar enum schemas but
incorrectly include type: "object"; remove the type: "object" entry from those
allOf wrappers so the referenced scalar enum types are not constrained to
object, leaving the $ref, description and example intact; locate the wrappers
referencing smsgateway.ProcessingState, smsgateway.MessagePriority, and
smsgateway.WebhookEvent and delete only the "type": "object" line in each.
---
Duplicate comments:
In `@app/src/main/assets/api/swagger.json`:
- Around line 1279-1284: The OpenAPI entry for JWTAuth (name "Authorization",
type "apiKey") doesn't explain how the refresh endpoint receives the refresh
token; update the refresh operation to explicitly accept a refresh token either
by (a) adding a distinct security scheme such as "RefreshTokenAuth" (in header
or cookie) and reference it in the refresh operation's security requirement, or
(b) adding a request parameter/body parameter named "refresh_token" (string) to
the refresh operation and clarifying in its description that the Authorization
header still expects the access token while the refresh_token parameter carries
the refresh token; ensure the operation's description and schema reference
"JWTAuth" and the new "RefreshTokenAuth" or "refresh_token" param so clients
know which token goes where.
In `@app/src/main/java/me/capcom/smsgateway/data/entities/Message.kt`:
- Around line 83-93: The computed accessors textContent and dataContent
currently call gson.fromJson(...) directly and will throw on malformed content;
wrap each gson.fromJson call in a try-catch that catches JSON parse exceptions
(e.g., JsonSyntaxException/JsonParseException/RuntimeException) and returns null
on failure so a single bad payload doesn't raise a 500; modify the getters for
textContent and dataContent to perform parsing inside the try block and return
null in the catch, leaving other behavior unchanged.
- Around line 89-100: The current private gson in the Message companion uses a
plain Gson which cannot deserialize Kotlin unsigned types (so
Message.dataContent -> MessageContent.Data with UShort port will fail); replace
the bare Gson() with the app's configured Gson instance or build a Gson via
GsonBuilder that registers a UShort type adapter/serializer (or reuse an
existing Gson provider) and assign it to the companion object's gson so
Message.dataContent correctly deserializes MessageContent.Data.port; update the
companion's private val gson accordingly (referencing the companion object,
gson, dataContent and MessageContent.Data symbols).
🪄 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: 5b82325b-6f69-441e-a1ec-c670ba99dae3
📒 Files selected for processing (13)
app/src/main/assets/api/swagger.jsonapp/src/main/java/me/capcom/smsgateway/data/entities/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/PostMessageRequest.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.ktapp/src/main/java/me/capcom/smsgateway/modules/localserver/routes/MessagesRoutes.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.ktapp/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
💤 Files with no reviewable changes (2)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/GetMessagesResponse.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/PostMessageResponse.kt
✅ Files skipped from review due to trivial changes (3)
- app/src/main/java/me/capcom/smsgateway/modules/messages/exceptions/ConflictException.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/DataMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/TextMessage.kt
🚧 Files skipped from review as they are similar to previous changes (5)
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/HashedMessage.kt
- app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesRepository.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/Message.kt
- app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt
- app/src/main/java/me/capcom/smsgateway/modules/localserver/domain/messages/PostMessageRequest.kt
Motivation
textMessageordataMessage) fromGET /messageswithout breaking existing clients.Description
includeContenttoGET /messagesand document it inapp/src/main/assets/api/swagger.jsonso list responses can include message payloads when requested.Messagemodel inMessage.ktwithtextMessage: TextMessage?anddataMessage: DataMessage?fields.MessagesRoutes.ktto parseincludeContentquery parameter, validate it, and conditionally parse message content usingGsonwhen building list responses, and to always include content for the singleGET /messages/{id}endpoint.docs/plans/messages-content-in-list-plan.mddescribing design, rollout, and considerations.Testing
./gradlew assembleand./gradlew test, and the existing test suite completed successfully.Codex Task
Summary by CodeRabbit
New Features
Bug Fixes
Other