mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 09:00:52 +03:00
feat(feedback): add validation for feedback creation and update (#4260)
* feat(feedback): add validation for feedback creation and update Introduced validation functions for feedback creation and update in the new validation service. Updated feedback controller to utilize these validation functions before processing requests. * refactor(feedback): update validation to return feedback object - Modified validateFeedbackExists to return the ChatMessageFeedback object instead of a boolean. - Updated validateFeedbackForUpdate to utilize the returned feedback object for setting default values.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Request, Response, NextFunction } from 'express'
|
||||
import feedbackService from '../../services/feedback'
|
||||
import { validateFeedbackForCreation, validateFeedbackForUpdate } from '../../services/feedback/validation'
|
||||
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
|
||||
import { StatusCodes } from 'http-status-codes'
|
||||
|
||||
@@ -31,6 +32,7 @@ const createChatMessageFeedbackForChatflow = async (req: Request, res: Response,
|
||||
`Error: feedbackController.createChatMessageFeedbackForChatflow - body not provided!`
|
||||
)
|
||||
}
|
||||
await validateFeedbackForCreation(req.body)
|
||||
const apiResponse = await feedbackService.createChatMessageFeedbackForChatflow(req.body)
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
@@ -52,6 +54,7 @@ const updateChatMessageFeedbackForChatflow = async (req: Request, res: Response,
|
||||
`Error: feedbackController.updateChatMessageFeedbackForChatflow - id not provided!`
|
||||
)
|
||||
}
|
||||
await validateFeedbackForUpdate(req.params.id, req.body)
|
||||
const apiResponse = await feedbackService.updateChatMessageFeedbackForChatflow(req.params.id, req.body)
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user