Skip to content

feat: add native contact conversation filtering - #38

Open
scmmishra wants to merge 5 commits into
mainfrom
feat/contact-conversation-filters
Open

feat: add native contact conversation filtering#38
scmmishra wants to merge 5 commits into
mainfrom
feat/contact-conversation-filters

Conversation

@scmmishra

@scmmishra scmmishra commented Aug 21, 2026

Copy link
Copy Markdown
Member

Summary

  • add SDK support for the paginated conversation filter API
  • expose contact filtering through convs --contact and contact ID conversations
  • normalize filter responses into the standard data.payload JSON shape
  • support both the documented data envelope and the root-level envelope emitted by current Chatwoot servers
  • upgrade Go to 1.26.6 for the latest standard-library security fixes
  • document native filtering and pagination in the CLI and bundled agent skill

Verification

  • request method, payload fields, operators, value types, and page query match the official Chatwoot Conversations Filter reference
  • SDK contract test covers the documented data envelope
  • command regression test covers the current server root-level envelope

Testing

  • go test ./...
  • govulncheck ./...

@github-actions

Copy link
Copy Markdown

⚠️ Note: Baseline coverage from main branch is not available (artifact may be expired). Showing current coverage for changed files only.

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/chatwoot/cli/internal/cmd 50.68% (+50.68%) 🌟
github.com/chatwoot/cli/internal/sdk 57.69% (+57.69%) 🌟

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/chatwoot/cli/internal/cmd/contact.go 18.18% (+18.18%) 44 (+44) 8 (+8) 36 (+36) 🎉
github.com/chatwoot/cli/internal/cmd/conversation.go 51.74% (+51.74%) 259 (+259) 134 (+134) 125 (+125) 🌟
github.com/chatwoot/cli/internal/sdk/contacts.go 73.91% (+73.91%) 23 (+23) 17 (+17) 6 (+6) 🌟
github.com/chatwoot/cli/internal/sdk/conversations.go 60.94% (+60.94%) 64 (+64) 39 (+39) 25 (+25) 🌟

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/chatwoot/cli/internal/cmd/contact_test.go
  • github.com/chatwoot/cli/internal/sdk/contract_test.go

@scmmishra
scmmishra marked this pull request as ready for review August 21, 2026 10:10
@scmmishra

Copy link
Copy Markdown
Member Author

@codex please review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f37b8c8c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +534 to +536
filters = appendConversationFilter(filters, "assignee_id", "is_present")
case "unassigned":
filters = appendConversationFilter(filters, "assignee_id", "is_not_present")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use documented operators for assignment-state filters

When --assignee assigned or --assignee unassigned is combined with --contact (including through contact <id> conversations), these branches send is_present or is_not_present. The pinned Chatwoot Conversations Filter contract in internal/sdk/testdata/application_swagger.json:3092-3100 permits only equal_to, not_equal_to, contains, and does_not_contain, so a server enforcing the documented contract rejects these advertised filters with HTTP 400. Encode the assignment state using a supported filter representation or remove these options from the contact-filter path.

Useful? React with 👍 / 👎.

})
var resp *sdk.ConversationsListResponse
var err error
if c.Contact > 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject nonpositive contact flag values

When a caller explicitly supplies --contact 0 or a negative ID, this condition treats the flag as absent and executes the ordinary conversation-list request, potentially returning unrelated conversations instead of reporting invalid input. This also bypasses the ContactID <= 0 validation in filterConversations, so scripts can silently operate on the wrong result set; track whether the flag was supplied or validate it before choosing the request path.

Useful? React with 👍 / 👎.

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