mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 14:27:32 +08:00
feat(go-api): Add Go chat session message delete and feedback APIs (#16442)
### Summary ``` /api/v1/chats/<chat_id>/sessions/<session_id>/messages/<msg_id> DELETE /api/v1/chats/<chat_id>/sessions/<session_id>/messages/<msg_id>/feedback PUT ``` Migrates the chat session message delete and feedback APIs to the Go server, matching the Python behavior for authorization, session ownership checks, message/reference updates, and feedback validation. ### Testing - `/usr/local/go/bin/go test ./internal/service ./internal/handler` - Verified through the frontend page for deleting chat messages and updating message feedback
This commit is contained in:
@@ -474,3 +474,53 @@ func (h *ChatSessionHandler) UpdateSession(c *gin.Context) {
|
||||
}
|
||||
jsonResponse(c, common.CodeSuccess, result, "success")
|
||||
}
|
||||
|
||||
func (h *ChatSessionHandler) DeleteSessionMessage(c *gin.Context) {
|
||||
user, errorCode, errorMessage := GetUser(c)
|
||||
if errorCode != common.CodeSuccess {
|
||||
jsonError(c, errorCode, errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
userID := user.ID
|
||||
chatID, sessionID, msgID := c.Param("chat_id"), c.Param("session_id"), c.Param("msg_id")
|
||||
|
||||
result, code, err := h.chatSessionService.DeleteSessionMessage(userID, chatID, sessionID, msgID)
|
||||
if err != nil {
|
||||
if code == common.CodeAuthenticationError {
|
||||
jsonResponse(c, code, false, err.Error())
|
||||
return
|
||||
}
|
||||
jsonError(c, code, err.Error())
|
||||
return
|
||||
}
|
||||
jsonResponse(c, common.CodeSuccess, result, "success")
|
||||
}
|
||||
|
||||
func (h *ChatSessionHandler) UpdateMessageFeedback(c *gin.Context) {
|
||||
user, errorCode, errorMessage := GetUser(c)
|
||||
if errorCode != common.CodeSuccess {
|
||||
jsonError(c, errorCode, errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
userID := user.ID
|
||||
chatID, sessionID, msgID := c.Param("chat_id"), c.Param("session_id"), c.Param("msg_id")
|
||||
|
||||
req := map[string]interface{}{}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
jsonError(c, common.CodeArgumentError, "Invalid request: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
result, code, err := h.chatSessionService.UpdateMessageFeedback(userID, chatID, sessionID, msgID, req)
|
||||
if err != nil {
|
||||
if code == common.CodeAuthenticationError {
|
||||
jsonResponse(c, code, false, err.Error())
|
||||
return
|
||||
}
|
||||
jsonError(c, code, err.Error())
|
||||
return
|
||||
}
|
||||
jsonResponse(c, common.CodeSuccess, result, "success")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user