Skip to content

[api] use ListMessagesOptions from client-go#253

Open
capcom6 wants to merge 1 commit into
masterfrom
api/use-client-go-list-messages-options
Open

[api] use ListMessagesOptions from client-go#253
capcom6 wants to merge 1 commit into
masterfrom
api/use-client-go-list-messages-options

Conversation

@capcom6

@capcom6 capcom6 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added optional delivery work-hours settings, including enablement and start/end times.
    • Improved message listing options with configurable content inclusion, limits, offsets, and filtering.
  • Bug Fixes

    • Added safer defaults and bounds for message pagination, including a maximum page size and non-negative offsets.

@coderabbitai

coderabbitai Bot commented Jul 9, 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: ce85c355-bc85-4db0-ae62-5c28c490a4ef

📥 Commits

Reviewing files that changed from the base of the PR and between ae8c2e9 and 957e74f.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • internal/sms-gateway/handlers/messages/params.go
  • internal/sms-gateway/openapi/docs.go
✅ Files skipped from review due to trivial changes (1)
  • internal/sms-gateway/openapi/docs.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • go.mod
  • internal/sms-gateway/handlers/messages/params.go

📝 Walkthrough

Walkthrough

The client-go dependency is updated, message listing parameters now use shared pointer-based options with direct filter mapping and bounded pagination defaults, and the OpenAPI settings schema gains work-hours configuration fields.

Changes

Params Refactor and Dependency Update

Layer / File(s) Summary
Dependency version bump
go.mod
The client-go dependency is updated to a newer version.
Query params refactor using ListMessagesOptions
internal/sms-gateway/handlers/messages/params.go
Message filters now map optional shared fields directly, while content inclusion, limits, and offsets use pointer-aware defaults and bounds.
OpenAPI settings schema
internal/sms-gateway/openapi/docs.go
SettingsMessages documents optional work-hours enablement and HH:mm start/end fields.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: switching message listing to ListMessagesOptions from client-go.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/sms-gateway/handlers/messages/params.go (1)

13-35: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore from/to order validation in thirdPartyGetQueryParams. QueryParserValidator only applies struct-tag rules, and ToFilter() forwards the dates directly to SelectStates; from > to now returns an empty result set instead of a 400. Add an explicit range check here or on smsgateway.ListMessagesOptions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/sms-gateway/handlers/messages/params.go` around lines 13 - 35,
`thirdPartyGetQueryParams.ToFilter` currently forwards `From` and `To` without
validating their ordering, so an invalid range can slip through and produce an
empty response instead of a bad-request error. Add an explicit `from <= to`
check in `ToFilter` or move the range validation into
`smsgateway.ListMessagesOptions` so the `QueryParserValidator` path still
rejects inverted date ranges before building the `messages.SelectFilter`.
🤖 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 `@api/requests.http`:
- Line 121: The sample request in api/requests.http has an inverted date range
because the Messages query uses a `from` value later than `to`. Update the
example under the `/3rdparty/v1/messages` request so the `to` timestamp matches
the same 2026 range as `from`, keeping the date window consistent with the other
sample requests.

In `@internal/sms-gateway/handlers/messages/params.go`:
- Around line 48-52: The Limit handling in the params parser only applies an
upper clamp, so zero or negative values can still flow into the SMS query
options. Update the limit assignment in the params logic (the branch that sets
options.Limit from p.Limit) to enforce a lower bound as well, matching the
Offset pattern with max(); clamp Limit to the valid range [1, maxLimit] and keep
the default when p.Limit is nil.

---

Outside diff comments:
In `@internal/sms-gateway/handlers/messages/params.go`:
- Around line 13-35: `thirdPartyGetQueryParams.ToFilter` currently forwards
`From` and `To` without validating their ordering, so an invalid range can slip
through and produce an empty response instead of a bad-request error. Add an
explicit `from <= to` check in `ToFilter` or move the range validation into
`smsgateway.ListMessagesOptions` so the `QueryParserValidator` path still
rejects inverted date ranges before building the `messages.SelectFilter`.
🪄 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: 201fd379-a6e7-4053-af23-7a64d3b15fac

📥 Commits

Reviewing files that changed from the base of the PR and between 884ab71 and ae8c2e9.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • api/requests.http
  • go.mod
  • internal/sms-gateway/handlers/messages/params.go
  • internal/sms-gateway/openapi/docs.go

Comment thread api/requests.http Outdated
Comment thread internal/sms-gateway/handlers/messages/params.go
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 server_Darwin_arm64.tar.gz
🍎 Darwin x86_64 server_Darwin_x86_64.tar.gz
🐧 Linux arm64 server_Linux_arm64.tar.gz
🐧 Linux i386 server_Linux_i386.tar.gz
🐧 Linux x86_64 server_Linux_x86_64.tar.gz
🪟 Windows arm64 server_Windows_arm64.zip
🪟 Windows i386 server_Windows_i386.zip
🪟 Windows x86_64 server_Windows_x86_64.zip

@capcom6 capcom6 force-pushed the api/use-client-go-list-messages-options branch from ae8c2e9 to 957e74f Compare July 10, 2026 04:02
@capcom6 capcom6 added the ready label Jul 10, 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.

1 participant