fix: 修复关注/粉丝列表隐私检查假阳性导致本人也无法访问

- follow_repo.go: GetFollowListPublic 改用显式 WHERE uid=? 避免 GORM 主键解析潜在问题
- follow_service.go: GetFollowListPublic 失败时默认公开并记录日志,而非返回错误
- follow_controller.go: 错误兜底时 Accessible 默认 true,避免误锁用户
This commit is contained in:
2026-06-01 20:22:50 +08:00
parent bab8e47d63
commit a0df66587b
3 changed files with 13 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package service
import (
"fmt"
"log"
"metazone.cc/metalab/internal/common"
"metazone.cc/metalab/internal/model"
@ -132,7 +133,8 @@ func (s *FollowService) GetStatus(currentUserID, targetUserID uint) (*FollowStat
func (s *FollowService) ListFollowers(userID, currentUserID uint, page, pageSize int) (*FollowListResult, error) {
listPublic, err := s.repo.GetFollowListPublic(userID)
if err != nil {
return nil, fmt.Errorf("查询公开设置: %w", err)
log.Printf("[FollowService] ListFollowers GetFollowListPublic error uid=%d: %v, fallback to public", userID, err)
listPublic = true
}
p := common.Pagination{Page: page, PageSize: pageSize}
@ -174,7 +176,8 @@ func (s *FollowService) ListFollowers(userID, currentUserID uint, page, pageSize
func (s *FollowService) ListFollowing(userID, currentUserID uint, page, pageSize int) (*FollowListResult, error) {
listPublic, err := s.repo.GetFollowListPublic(userID)
if err != nil {
return nil, fmt.Errorf("查询公开设置: %w", err)
log.Printf("[FollowService] ListFollowing GetFollowListPublic error uid=%d: %v, fallback to public", userID, err)
listPublic = true
}
p := common.Pagination{Page: page, PageSize: pageSize}