feat(chat): add endpoint to get quoted message by ID
Add GET /api/v1/messages/:id endpoint to retrieve quoted/replied messages for preview fill and navigation purposes. The endpoint includes authorization checks ensuring only conversation participants can access the message. Additionally improve file upload handling for native clients (expo-file-system) by accepting explicit displayName from frontend, with sanitization to prevent path traversal and 255-character length limit. File extension detection now prioritizes the real display name over the multipart header filename.
This commit is contained in:
@@ -109,8 +109,12 @@ func (h *UploadHandler) UploadFile(c *gin.Context) {
|
||||
}
|
||||
|
||||
folder := c.DefaultPostForm("folder", "chat")
|
||||
// 前端(尤其原生端 expo-file-system)无法自定义 multipart filename,
|
||||
// 文件常被复制到缓存目录并以 UUID 命名,导致 header Filename 丢失真实名。
|
||||
// 因此前端额外把真实文件名通过 "name" 字段回传,作为权威展示名。
|
||||
displayName := c.PostForm("name")
|
||||
|
||||
result, err := h.uploadService.UploadFile(c.Request.Context(), file, folder, userID)
|
||||
result, err := h.uploadService.UploadFile(c.Request.Context(), file, folder, userID, displayName)
|
||||
if err != nil {
|
||||
// 参数类错误(大小/类型)返回 400,其余返回 500
|
||||
if file.Size > 0 && file.Size <= 100<<20 {
|
||||
|
||||
Reference in New Issue
Block a user