diff --git a/go.mod b/go.mod index de3adee481..7413edd8cb 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require github.com/google/uuid v1.3.1 require ( github.com/IBM/sarama v1.41.2 - github.com/OpenIMSDK/protocol v0.0.25 + github.com/OpenIMSDK/protocol v0.0.26 github.com/OpenIMSDK/tools v0.0.14 github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible github.com/go-redis/redis v6.15.9+incompatible diff --git a/go.sum b/go.sum index 6fcc8ebfd6..a72bd884ac 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIw github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/IBM/sarama v1.41.2 h1:ZDBZfGPHAD4uuAtSv4U22fRZBgst0eEwGFzLj0fb85c= github.com/IBM/sarama v1.41.2/go.mod h1:xdpu7sd6OE1uxNdjYTSKUfY8FaKkJES9/+EyjSgiGQk= -github.com/OpenIMSDK/protocol v0.0.25 h1:AtB0Ia5LO26oqPoPJDIS4UMH3Wb2li96fMgfzI2cr4I= -github.com/OpenIMSDK/protocol v0.0.25/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= +github.com/OpenIMSDK/protocol v0.0.26 h1:jzq7EemhkO8W5kvOOg2f0b7OAMzMPrIBUG0GVbSNhDA= +github.com/OpenIMSDK/protocol v0.0.26/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ= github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 0a3856c9b5..8d529584a9 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -121,14 +121,23 @@ func (s *groupServer) NotificationUserInfoUpdate(ctx context.Context, req *pbgro if err != nil { return nil, err } + groupIDs := make([]string, 0, len(members)) for _, member := range members { if member.Nickname != "" && member.FaceURL != "" { continue } - if err := s.Notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID); err != nil { - log.ZError(ctx, "setGroupMemberInfo notification failed", err, "member", member.UserID, "groupID", member.GroupID) + groupIDs = append(groupIDs, member.GroupID) + } + log.ZInfo(ctx, "NotificationUserInfoUpdate", "joinGroupNum", len(members), "updateNum", len(groupIDs), "updateGroupIDs", groupIDs) + for _, groupID := range groupIDs { + if err := s.Notification.GroupMemberInfoSetNotification(ctx, groupID, req.UserID); err != nil { + log.ZError(ctx, "NotificationUserInfoUpdate setGroupMemberInfo notification failed", err, "groupID", groupID) } } + if err := s.GroupDatabase.DeleteGroupMemberHash(ctx, groupIDs); err != nil { + log.ZError(ctx, "NotificationUserInfoUpdate DeleteGroupMemberHash", err, "groupID", groupIDs) + } + return &pbgroup.NotificationUserInfoUpdateResp{}, nil } diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index f7ded8a2e0..194f3e8b20 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -81,6 +81,7 @@ type GroupDatabase interface { CountTotal(ctx context.Context, before *time.Time) (count int64, err error) // 获取范围内群增量 CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) + DeleteGroupMemberHash(ctx context.Context, groupIDs []string) error } func NewGroupDatabase( @@ -556,3 +557,15 @@ func (g *groupDatabase) FindGroupRequests(ctx context.Context, groupID string, u func (g *groupDatabase) FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error) { return g.groupDB.FindNotDismissedGroup(ctx, groupIDs) } + +func (g *groupDatabase) DeleteGroupMemberHash(ctx context.Context, groupIDs []string) error { + if len(groupIDs) == 0 { + return nil + } + c := g.cache.NewCache() + for _, groupID := range groupIDs { + c = c.DelGroupMembersHash(groupID) + } + + return c.ExecDel(ctx) +}