feat(group): refactor group invite workflow for improved user experience

- Simplify InviteMembers to always send invite card directly to invitee
- Modify RespondInvite to check group join type (anyone vs need approval) before adding member
- Update SetGroupAddRequest to properly handle invite flow with invitee agreement and admin approval stages
- Add case-insensitive search using LOWER() in user repository
- Add random offset (0-50) for first page of recommended posts
- Update dependencies: remove gorilla/websocket, promote gomail to direct dependency
This commit is contained in:
2026-03-12 23:40:21 +08:00
parent 0a0cbacbcc
commit 1216423350
5 changed files with 138 additions and 76 deletions

View File

@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log"
"math/rand"
"strings"
"time"
@@ -255,7 +256,7 @@ func (s *PostService) List(ctx context.Context, page, pageSize int, userID strin
}
cacheKey := cache.PostListKey("latest", visibilityUserKey, page, pageSize)
result, err := cache.GetOrLoadTyped[*PostListResult](
result, err := cache.GetOrLoadTyped(
s.cache,
cacheKey,
postListTTL,
@@ -595,8 +596,14 @@ func (s *PostService) GetRecommendedPosts(ctx context.Context, userID string, pa
return s.GetHotPosts(ctx, page, pageSize)
}
// 计算偏移量
offset := (page - 1) * pageSize
// 计算偏移量:第一页使用随机偏移量,增加推荐多样性
var offset int
if page == 1 {
// 第一页随机偏移 0-50让每次刷新看到不同的推荐内容
offset = rand.Intn(51)
} else {
offset = (page - 1) * pageSize
}
// 从Gorse获取推荐列表
// 多取1条用于判断是否还有下一页