From eb749af8070e34ebead5233f65a6493c2fb2713b Mon Sep 17 00:00:00 2001 From: withchao <48119764+withchao@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:38:53 +0800 Subject: [PATCH] fix: modifying user information notifications to join groups and group avatar issues (#1147) * fix: user update group notification, group member face url * fix: user update group notification, group member face url --- go.work | 2 +- internal/rpc/group/group.go | 61 +++++++++++++++++++++---------------- internal/rpc/user/user.go | 3 ++ pkg/common/convert/group.go | 16 +++++----- 4 files changed, 47 insertions(+), 35 deletions(-) diff --git a/go.work b/go.work index f01eace52..323a727e8 100644 --- a/go.work +++ b/go.work @@ -4,7 +4,7 @@ use ( . ./test/typecheck ./tools/changelog - ./tools/imctl + //./tools/imctl ./tools/infra ./tools/ncpu ./tools/openim-web diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 507d83d81..0a3856c9b 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -225,15 +225,16 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR return nil, err } joinGroup := func(userID string, roleLevel int32) error { - groupMember := convert.Pb2DbGroupMember(userMap[userID]) - groupMember.Nickname = "" - groupMember.GroupID = group.GroupID - groupMember.RoleLevel = roleLevel - groupMember.OperatorUserID = mcontext.GetOpUserID(ctx) - groupMember.JoinSource = constant.JoinByInvitation - groupMember.InviterUserID = mcontext.GetOpUserID(ctx) - groupMember.JoinTime = time.Now() - groupMember.MuteEndTime = time.Unix(0, 0) + groupMember := &relationtb.GroupMemberModel{ + GroupID: group.GroupID, + UserID: userID, + RoleLevel: roleLevel, + OperatorUserID: opUserID, + JoinSource: constant.JoinByInvitation, + InviterUserID: opUserID, + JoinTime: time.Now(), + MuteEndTime: time.UnixMilli(0), + } if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil { return err } @@ -359,6 +360,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite if err != nil { return nil, err } + if len(userMap) != len(req.InvitedUserIDs) { + return nil, errs.ErrRecordNotFound.Wrap("user not found") + } var groupMember *relationtb.GroupMemberModel var opUserID string if !authverify.IsAppManagerUid(ctx) { @@ -416,15 +420,16 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite opUserID := mcontext.GetOpUserID(ctx) var groupMembers []*relationtb.GroupMemberModel for _, userID := range req.InvitedUserIDs { - member := convert.Pb2DbGroupMember(userMap[userID]) - member.Nickname = "" - member.GroupID = req.GroupID - member.RoleLevel = constant.GroupOrdinaryUsers - member.OperatorUserID = opUserID - member.InviterUserID = opUserID - member.JoinSource = constant.JoinByInvitation - member.JoinTime = time.Now() - member.MuteEndTime = time.Unix(0, 0) + member := &relationtb.GroupMemberModel{ + GroupID: req.GroupID, + UserID: userID, + RoleLevel: constant.GroupOrdinaryUsers, + OperatorUserID: opUserID, + InviterUserID: opUserID, + JoinSource: constant.JoinByInvitation, + JoinTime: time.Now(), + MuteEndTime: time.UnixMilli(0), + } if err := CallbackBeforeMemberJoinGroup(ctx, member, group.Ex); err != nil { return nil, err } @@ -800,14 +805,15 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq) if group.GroupType == constant.SuperGroup { return nil, errs.ErrGroupTypeNotSupport.Wrap() } - groupMember := convert.Pb2DbGroupMember(user) - groupMember.GroupID = group.GroupID - groupMember.RoleLevel = constant.GroupOrdinaryUsers - groupMember.OperatorUserID = mcontext.GetOpUserID(ctx) - groupMember.JoinSource = constant.JoinByInvitation - groupMember.InviterUserID = req.InviterUserID - groupMember.JoinTime = time.Now() - groupMember.MuteEndTime = time.Unix(0, 0) + groupMember := &relationtb.GroupMemberModel{ + GroupID: group.GroupID, + UserID: user.UserID, + RoleLevel: constant.GroupOrdinaryUsers, + OperatorUserID: mcontext.GetOpUserID(ctx), + InviterUserID: req.InviterUserID, + JoinTime: time.Now(), + MuteEndTime: time.UnixMilli(0), + } if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil { return nil, err } @@ -1272,6 +1278,9 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGr if len(req.Members) == 0 { return nil, errs.ErrArgs.Wrap("members empty") } + for i := range req.Members { + req.Members[i].FaceURL = nil + } duplicateMap := make(map[[2]string]struct{}) userIDMap := make(map[string]struct{}) groupIDMap := make(map[string]struct{}) diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 44e0a6cf4..d22715f0c 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -139,6 +139,9 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI for _, friendID := range friends { s.friendNotificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, friendID) } + if err := s.groupRpcClient.NotificationUserInfoUpdate(ctx, req.UserInfo.UserID); err != nil { + log.ZError(ctx, "NotificationUserInfoUpdate", err, "userID", req.UserInfo.UserID) + } return resp, nil } diff --git a/pkg/common/convert/group.go b/pkg/common/convert/group.go index c13016b7e..18940f518 100644 --- a/pkg/common/convert/group.go +++ b/pkg/common/convert/group.go @@ -138,11 +138,11 @@ func Pb2DBGroupInfo(m *sdkws.GroupInfo) *relation.GroupModel { } } -func Pb2DbGroupMember(m *sdkws.UserInfo) *relation.GroupMemberModel { - return &relation.GroupMemberModel{ - UserID: m.UserID, - Nickname: m.Nickname, - FaceURL: m.FaceURL, - Ex: m.Ex, - } -} +//func Pb2DbGroupMember(m *sdkws.UserInfo) *relation.GroupMemberModel { +// return &relation.GroupMemberModel{ +// UserID: m.UserID, +// Nickname: m.Nickname, +// FaceURL: m.FaceURL, +// Ex: m.Ex, +// } +//}