feat: Implement section access validation for agent filtering and refine filterable field retrieval to include only fields from global or assigned sections.

This commit is contained in:
pradeepkumar
2026-02-24 21:45:39 +05:30
parent 49bd08c5fe
commit d30358755e
2 changed files with 47 additions and 12 deletions

View File

@@ -235,6 +235,7 @@ export class ProfileFieldsService {
/**
* Get all filterable fields (public endpoint for search filters)
* Returns fields with CHECKBOX_GROUP, SELECT, MULTI_SELECT types that have options
* Only includes fields from sections that are global or assigned to at least one agent type
* De-duplicates by both slug AND name to handle duplicate fields with different slugs
*/
async getFilterableFields() {
@@ -245,6 +246,14 @@ export class ProfileFieldsService {
isActive: true,
fieldType: { in: filterableTypes },
options: { not: Prisma.JsonNull },
// Only include fields from sections that are global or assigned to at least one agent type
section: {
isActive: true,
OR: [
{ isGlobal: true },
{ agentTypeSections: { some: {} } },
],
},
},
select: {
id: true,