Changeset 0.28.0.5 (#177)
This commit is contained in:
@@ -278,6 +278,48 @@ func (h *FileHandler) ListByChannel(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"files": files})
|
||||
}
|
||||
|
||||
// ── List by Message ───────────────────────
|
||||
// GET /api/v1/messages/:id/files
|
||||
// Returns files attached to a specific message (inline artifacts, tool output).
|
||||
func (h *FileHandler) ListByMessage(c *gin.Context) {
|
||||
messageID := c.Param("id")
|
||||
|
||||
files, err := h.stores.Files.GetByMessage(c.Request.Context(), messageID)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to list files"})
|
||||
return
|
||||
}
|
||||
if files == nil {
|
||||
files = []models.File{}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"files": files})
|
||||
}
|
||||
|
||||
// ── List by User (File Manager) ───────────
|
||||
// GET /api/v1/files?page=1&per_page=50
|
||||
// Paginated list of all files owned by the authenticated user.
|
||||
func (h *FileHandler) ListByUser(c *gin.Context) {
|
||||
userID := getUserID(c)
|
||||
page, perPage, _ := parsePagination(c)
|
||||
|
||||
files, total, err := h.stores.Files.GetByUser(c.Request.Context(), userID, page, perPage)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to list files"})
|
||||
return
|
||||
}
|
||||
if files == nil {
|
||||
files = []models.File{}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"files": files,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"per_page": perPage,
|
||||
})
|
||||
}
|
||||
|
||||
// ── Delete ─────────────────────────────────
|
||||
// DELETE /api/v1/files/:id
|
||||
func (h *FileHandler) Delete(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user