feat(privacy): add user privacy settings and account deletion system
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:
@@ -11,11 +11,29 @@ import (
|
||||
type UserStatus string
|
||||
|
||||
const (
|
||||
UserStatusActive UserStatus = "active"
|
||||
UserStatusBanned UserStatus = "banned"
|
||||
UserStatusInactive UserStatus = "inactive"
|
||||
UserStatusActive UserStatus = "active"
|
||||
UserStatusBanned UserStatus = "banned"
|
||||
UserStatusInactive UserStatus = "inactive"
|
||||
UserStatusPendingDeletion UserStatus = "pending_deletion"
|
||||
)
|
||||
|
||||
// VisibilityLevel 可见性级别
|
||||
type VisibilityLevel string
|
||||
|
||||
const (
|
||||
VisibilityEveryone VisibilityLevel = "everyone"
|
||||
VisibilityFollowing VisibilityLevel = "following"
|
||||
VisibilitySelf VisibilityLevel = "self"
|
||||
)
|
||||
|
||||
// PrivacySettings 隐私设置
|
||||
type PrivacySettings struct {
|
||||
FollowersVisibility VisibilityLevel `json:"followers_visibility" gorm:"type:varchar(20);default:everyone"`
|
||||
FollowingVisibility VisibilityLevel `json:"following_visibility" gorm:"type:varchar(20);default:everyone"`
|
||||
PostsVisibility VisibilityLevel `json:"posts_visibility" gorm:"type:varchar(20);default:everyone"`
|
||||
FavoritesVisibility VisibilityLevel `json:"favorites_visibility" gorm:"type:varchar(20);default:everyone"`
|
||||
}
|
||||
|
||||
// UserIdentity 用户身份类型
|
||||
type UserIdentity string
|
||||
|
||||
@@ -73,6 +91,12 @@ type User struct {
|
||||
LastLoginAt *time.Time `json:"last_login_at" gorm:"type:timestamp"`
|
||||
LastLoginIP string `json:"last_login_ip" gorm:"type:varchar(45)"`
|
||||
|
||||
// 账号注销
|
||||
DeletionRequestedAt *time.Time `json:"deletion_requested_at" gorm:"type:timestamp"`
|
||||
|
||||
// 隐私设置
|
||||
PrivacySettings PrivacySettings `json:"privacy_settings" gorm:"embedded;embeddedPrefix:privacy_"`
|
||||
|
||||
// 时间戳
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
|
||||
Reference in New Issue
Block a user