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:
@@ -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条用于判断是否还有下一页
|
||||
|
||||
Reference in New Issue
Block a user