[Customer Portal[BE] Refactor case response, update conversation search payload, and rename project activity stats field - #273
Conversation
…e project activity stats field
📝 WalkthroughWalkthroughThe changes extend the Case data structure with creator and catalog metadata fields, rename the time-logging field from totalTimeLogged to totalHours in project stats responses, and add a createdByMe filter to conversation search capabilities across multiple backend files. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 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 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/customer-portal/backend/service.bal (1)
1093-1100:⚠️ Potential issue | 🟠 MajorEnforce creator-only conversation filtering server-side.
Line 1099 passes
createdByMefrom client input. A client can omit or set it tofalse, which can bypass the “created by logged-in user only” behavior.🔧 Proposed fix
entity:ConversationSearchResponse|error conversationResponse = entity:searchConversations(userInfo.idToken, { filters: { projectIds: [id], stateKeys: payload.filters?.stateKeys, searchQuery: payload.filters?.searchQuery, - createdByMe: payload.filters?.createdByMe + createdByMe: true }, sortBy: payload.sortBy, pagination: payload.pagination });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/backend/service.bal` around lines 1093 - 1100, The call to entity:searchConversations currently passes the client-supplied payload.filters?.createdByMe which allows a client to bypass creator-only filtering; override that value server-side by replacing payload.filters?.createdByMe with a server-determined boolean (e.g., true when this endpoint must restrict results to the logged-in user) before calling entity:searchConversations (the call using userInfo.idToken and the filters object), ensuring the createdByMe flag cannot be controlled by client input.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/customer-portal/backend/service.bal`:
- Around line 1093-1100: The call to entity:searchConversations currently passes
the client-supplied payload.filters?.createdByMe which allows a client to bypass
creator-only filtering; override that value server-side by replacing
payload.filters?.createdByMe with a server-determined boolean (e.g., true when
this endpoint must restrict results to the logged-in user) before calling
entity:searchConversations (the call using userInfo.idToken and the filters
object), ensuring the createdByMe flag cannot be controlled by client input.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/customer-portal/backend/modules/entity/types.balapps/customer-portal/backend/modules/types/types.balapps/customer-portal/backend/service.balapps/customer-portal/backend/utils.bal
dea5a3b
into
wso2-open-operations:customer-portal-milestone-1
Description
This PR includes the following updates:
totalTimeLoggedtototalHoursChanges
1️⃣ Case Response Refactor
Reason:
Cases now support service request–based data, and the response structure needed to reflect related catalog information to support UI and downstream integrations.
2️⃣ Conversation Search Payload Update
Reason:
Ensures users only retrieve their own conversations, improving security and data isolation.
3️⃣ Project Activity Stats Field Rename
Reason:
The new field name better reflects the actual unit and improves clarity in reporting and dashboard usage.
Impact
⚠ Case response structure extended (may require frontend adjustment)
⚠ Field rename (
totalTimeLogged→totalHours) may be a breaking changeTesting
totalHoursRelated PRs
Summary by CodeRabbit
Release Notes
New Features
Improvements