Add notification settings, account deletion, photo reporting, and pending-user photos

Addresses user bug reports: settings pages needed real notification
preferences and account deletion, admin needed a way to flag a specific
photo independent of deleting it, and the pending-approval users list
needed to surface applicant photos for review.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-26 18:08:57 +03:30
parent c8e6f80c51
commit 2c6d4bfbd2
12 changed files with 188 additions and 17 deletions
+34 -3
View File
@@ -165,14 +165,21 @@ func (h *AdminHandler) DeleteOption(c *gin.Context) {
// ListPendingUsers GET /admin/users/pending
func (h *AdminHandler) ListPendingUsers(c *gin.Context) {
users, err := h.adminService.ListPendingUsers()
users, photosByUser, err := h.adminService.ListPendingUsers()
if err != nil {
utils.Fail(c, http.StatusInternalServerError, "خطا در دریافت لیست کاربران", nil)
return
}
result := make([]dto.UserProfile, 0, len(users))
result := make([]dto.UserProfileWithPhotos, 0, len(users))
for i := range users {
result = append(result, toUserProfile(&users[i]))
photos := photosByUser[users[i].ID]
if photos == nil {
photos = []string{}
}
result = append(result, dto.UserProfileWithPhotos{
UserProfile: toUserProfile(&users[i]),
Photos: photos,
})
}
utils.Success(c, http.StatusOK, "", result)
}
@@ -382,6 +389,30 @@ func (h *AdminHandler) DeletePhoto(c *gin.Context) {
utils.Success(c, http.StatusOK, "عکس حذف شد", nil)
}
// ReportPhoto POST /admin/photos/:id/report body: {reason}
func (h *AdminHandler) ReportPhoto(c *gin.Context) {
id, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil {
utils.Fail(c, http.StatusBadRequest, "شناسه نامعتبر است", nil)
return
}
var req dto.ReportUserRequest
if err := c.ShouldBindJSON(&req); err != nil {
utils.Fail(c, http.StatusBadRequest, "ورودی نامعتبر است (ذکر دلیل گزارش الزامی است)", err.Error())
return
}
report, err := h.adminService.ReportPhoto(uint(id), req.Reason)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
utils.Fail(c, http.StatusNotFound, "عکس یافت نشد", nil)
return
}
utils.Fail(c, http.StatusBadRequest, err.Error(), nil)
return
}
utils.Success(c, http.StatusCreated, "گزارش ثبت شد", report)
}
// ---------------- سوالات پروفایل ----------------
// ListQuestions GET /admin/profile-questions