feat(privacy): add user privacy settings and account deletion system
All checks were successful
Build Backend / build (push) Successful in 5m16s
Build Backend / build-docker (push) Successful in 3m44s

Add privacy settings allowing users to control visibility of their followers, following, posts, and favorites lists with three visibility levels: everyone, following, and self. Also implement account deletion workflow with 30-day cooldown period.

- Add PrivacySettings model with visibility levels
- Add DTOs for privacy settings and account deletion
- Add repository methods for privacy settings and deletion
- Add service methods to check visibility permissions
- Add handlers for get/update privacy settings and account deletion
- Add new routes for privacy settings and account management
- Add account cleanup service for hard-deleting expired accounts
- Modify login to cancel deletion when user logs in

BREAKING CHANGE: Users with pending_deletion status can no longer log in; logging in now automatically cancels deletion requests.
This commit is contained in:
lafay
2026-04-08 14:55:50 +08:00
parent 9440df66ba
commit 539bec6f63
9 changed files with 642 additions and 76 deletions

View File

@@ -187,6 +187,15 @@ func (r *Router) setupRoutes() {
users.POST("/change-password/send-code", authMiddleware, r.userHandler.SendChangePasswordCode)
users.POST("/change-password", authMiddleware, r.userHandler.ChangePassword)
// 隐私设置
users.GET("/me/privacy", authMiddleware, r.userHandler.GetPrivacySettings)
users.PUT("/me/privacy", authMiddleware, r.userHandler.UpdatePrivacySettings)
// 账号注销
users.POST("/me/deactivate", authMiddleware, r.userHandler.RequestAccountDeletion)
users.DELETE("/me/deactivate", authMiddleware, r.userHandler.CancelAccountDeletion)
users.GET("/me/deletion-status", authMiddleware, r.userHandler.GetDeletionStatus)
// 当前用户角色
if r.roleHandler != nil {
users.GET("/me/roles", authMiddleware, r.roleHandler.GetMyRoles)