mirror of
https://github.com/hexastack/hexabot
synced 2025-02-23 04:48:51 +00:00
fix(api): remove unused filterDynamicFields method
This commit is contained in:
parent
5df35d94f7
commit
3e234b15c6
@ -65,34 +65,6 @@ export class ContentController extends BaseController<
|
|||||||
super(contentService);
|
super(contentService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters and processes dynamic fields in the content DTO based on the associated content type.
|
|
||||||
* It ensures that only fields matching the content type are passed forward.
|
|
||||||
*
|
|
||||||
* @param contentDto - The content DTO containing dynamic fields.
|
|
||||||
* @param contentType - The content type schema defining valid fields.
|
|
||||||
*
|
|
||||||
* @returns The content DTO with filtered dynamic fields.
|
|
||||||
*/
|
|
||||||
filterDynamicFields(contentDto: ContentCreateDto, contentType: ContentType) {
|
|
||||||
if (!contentType) {
|
|
||||||
this.logger.warn(
|
|
||||||
`Content type of id ${contentDto.entity}. Content type not found.`,
|
|
||||||
);
|
|
||||||
throw new NotFoundException(
|
|
||||||
`Content type of id ${contentDto.entity} not found`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Filter the fields coming from the request body to correspond to the contentType
|
|
||||||
const dynamicFields = contentType.fields.reduce((acc, { name }) => {
|
|
||||||
return name in contentDto.dynamicFields && contentDto.dynamicFields[name]
|
|
||||||
? { ...acc, [name]: contentDto.dynamicFields[name] }
|
|
||||||
: acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
return { ...contentDto, dynamicFields };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new content based on the provided DTO, filtering dynamic fields to match
|
* Creates new content based on the provided DTO, filtering dynamic fields to match
|
||||||
* the associated content type before persisting it.
|
* the associated content type before persisting it.
|
||||||
|
Loading…
Reference in New Issue
Block a user