feat: auth user feedbacks

This commit is contained in:
Krispire Admin
2026-07-14 18:26:03 +05:30
parent 47b3a6d96e
commit 4553725d4e
5 changed files with 76 additions and 2 deletions
+18
View File
@@ -68,3 +68,21 @@ func (h *FeedbackHandler) Submit(w http.ResponseWriter, r *http.Request) {
}
response.JSON(w, http.StatusCreated, f)
}
// Mine returns the authenticated caller's own feedback submissions,
// newest first — each with its status (acknowledged / resolved) and any
// admin reply. Registered under RequireAuth, so UserID is always set;
// the guard is belt-and-suspenders.
func (h *FeedbackHandler) Mine(w http.ResponseWriter, r *http.Request) {
uid := middleware.UserID(r.Context())
if uid == "" {
response.Error(w, http.StatusUnauthorized, "authentication required")
return
}
items, err := h.svc.ListForUser(r.Context(), uid, 50)
if err != nil {
response.Error(w, http.StatusInternalServerError, "could not load your feedback")
return
}
response.JSON(w, http.StatusOK, items)
}