Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group members do not set their names and avatars to be updated in real time #974

Merged
merged 52 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
85d3045
fix: create group type limit
withchao Aug 9, 2023
f8a649e
Merge branch 'OpenIMSDK:main' into main
withchao Aug 9, 2023
5db572b
fix: group notification
withchao Aug 9, 2023
7436b77
fix: group notification
withchao Aug 9, 2023
f8518f7
fix: group notification
withchao Aug 9, 2023
79237d2
Merge branch 'OpenIMSDK:main' into main
withchao Aug 11, 2023
2253e95
chore: group member hash
withchao Aug 11, 2023
e9d784b
chore: group member hash
withchao Aug 11, 2023
adeeb38
chore: group member hash
withchao Aug 11, 2023
b99672f
chore: group member hash
withchao Aug 11, 2023
5b0ae6e
test: log
withchao Aug 11, 2023
d5f6aff
test: log
withchao Aug 11, 2023
15c17a2
test: log
withchao Aug 11, 2023
26431b0
test: log
withchao Aug 11, 2023
b97f168
test: log
withchao Aug 11, 2023
6a50db8
sync: hash code
withchao Aug 14, 2023
77c7a87
sync: hash code
withchao Aug 14, 2023
fa26732
Merge branch 'OpenIMSDK:main' into main
withchao Aug 14, 2023
be8eea9
sync: hash code
withchao Aug 14, 2023
dfbb252
test: log
withchao Aug 14, 2023
a572c4a
test: log
withchao Aug 14, 2023
bb9230e
test: log
withchao Aug 14, 2023
9a081d8
test: log
withchao Aug 14, 2023
f3ae067
test: log
withchao Aug 14, 2023
2997dd4
fix: time stamp
withchao Aug 14, 2023
4db7612
Merge branch 'OpenIMSDK:main' into main
withchao Aug 15, 2023
dce606a
Merge branch 'OpenIMSDK:main' into main
withchao Aug 16, 2023
49640ac
fix: minio sign endpoint opts
withchao Aug 16, 2023
f50fee1
Merge remote-tracking branch 'origin/main'
withchao Aug 16, 2023
0aea359
Merge branch 'OpenIMSDK:main' into main
withchao Aug 24, 2023
b0cb4ac
cicd: robot automated Change
withchao Aug 24, 2023
9937a57
fix: minio bucket url
withchao Aug 24, 2023
b0f29f6
Merge remote-tracking branch 'origin/main'
withchao Aug 24, 2023
601d4f9
Merge branch 'OpenIMSDK:main' into main
withchao Aug 25, 2023
9f431b0
fix: op user info
withchao Aug 25, 2023
db13592
cicd: robot automated Change
withchao Aug 25, 2023
c3cb271
fix: importFriends Conversation
withchao Aug 25, 2023
3365b4d
Merge remote-tracking branch 'origin/main'
withchao Aug 25, 2023
c9e1d44
Merge branch 'OpenIMSDK:main' into main
withchao Aug 28, 2023
6f0eea2
fix: importFriends Notification
withchao Aug 28, 2023
bfdff16
cicd: robot automated Change
withchao Aug 28, 2023
d669018
fix: importFriends Notification
withchao Aug 28, 2023
2883a3e
Merge remote-tracking branch 'origin/main'
withchao Aug 28, 2023
800bdd7
NotificationUserInfoUpdate
withchao Aug 30, 2023
e9361a6
Merge branch 'OpenIMSDK:main' into main
withchao Aug 30, 2023
64d3273
NotificationUserInfoUpdate
withchao Aug 30, 2023
eab395b
Merge remote-tracking branch 'origin/main'
withchao Aug 30, 2023
dfe4cb8
NotificationUserInfoUpdate
withchao Aug 30, 2023
54bf150
NotificationUserInfoUpdate
withchao Aug 30, 2023
ec65630
NotificationUserInfoUpdate
withchao Aug 30, 2023
4f1e3fb
NotificationUserInfoUpdate
withchao Aug 30, 2023
6cf2c57
NotificationUserInfoUpdate
withchao Aug 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
require github.com/google/uuid v1.3.0

require (
github.com/OpenIMSDK/protocol v0.0.15
github.com/OpenIMSDK/protocol v0.0.17
github.com/OpenIMSDK/tools v0.0.14
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
github.com/go-redis/redis v6.15.9+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OpenIMSDK/protocol v0.0.15 h1:KrrvdHH9kFF/tFYL2FXRPAr2e5F5DctSHfHq6MQjUI4=
github.com/OpenIMSDK/protocol v0.0.15/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/OpenIMSDK/protocol v0.0.17 h1:ixjKUVGlTW+jQK5cPaKV//6l4bk9DAlbjDhocztYSbU=
github.com/OpenIMSDK/protocol v0.0.17/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=
Expand Down
7 changes: 1 addition & 6 deletions internal/rpc/group/fill.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ import (
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
)

func (s *groupServer) FindGroupMember(
ctx context.Context,
groupIDs []string,
userIDs []string,
roleLevels []int32,
) ([]*relationtb.GroupMemberModel, error) {
func (s *groupServer) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationtb.GroupMemberModel, error) {
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
if err != nil {
return nil, err
Expand Down
18 changes: 18 additions & 0 deletions internal/rpc/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@
msgRpcClient rpcclient.MessageRpcClient
}

func (s *groupServer) NotificationUserInfoUpdate(ctx context.Context, req *pbgroup.NotificationUserInfoUpdateReq) (*pbgroup.NotificationUserInfoUpdateResp, error) {
defer log.ZDebug(ctx, "return")

members, err := s.GroupDatabase.FindGroupMember(ctx, nil, []string{req.UserID}, nil)
if err != nil {
return nil, err
}
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)
}
}
return &pbgroup.NotificationUserInfoUpdateResp{}, nil

Check failure on line 132 in internal/rpc/group/group.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
}

func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error {
if !authverify.IsAppManagerUid(ctx) {
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, mcontext.GetOpUserID(ctx))
Expand Down
8 changes: 8 additions & 0 deletions internal/rpc/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type userServer struct {
friendNotificationSender *notification.FriendNotificationSender
userNotificationSender *notification.UserNotificationSender
friendRpcClient *rpcclient.FriendRpcClient
groupRpcClient *rpcclient.GroupRpcClient
RegisterCenter registry.SvcDiscoveryRegistry
}

Expand Down Expand Up @@ -81,11 +82,13 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
userMongoDB := unrelation.NewUserMongoDriver(mongo.GetDatabase())
database := controller.NewUserDatabase(userDB, cache, tx.NewGorm(db), userMongoDB)
friendRpcClient := rpcclient.NewFriendRpcClient(client)
groupRpcClient := rpcclient.NewGroupRpcClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
u := &userServer{
UserDatabase: database,
RegisterCenter: client,
friendRpcClient: &friendRpcClient,
groupRpcClient: &groupRpcClient,
friendNotificationSender: notification.NewFriendNotificationSender(&msgRpcClient, notification.WithDBFunc(database.FindWithError)),
userNotificationSender: notification.NewUserNotificationSender(&msgRpcClient, notification.WithUserFunc(database.FindWithError)),
}
Expand Down Expand Up @@ -125,6 +128,11 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
if err != nil {
return nil, err
}
if req.UserInfo.Nickname != "" || req.UserInfo.FaceURL != "" {
if err := s.groupRpcClient.NotificationUserInfoUpdate(ctx, req.UserInfo.UserID); err != nil {
log.ZError(ctx, "NotificationUserInfoUpdate", err)
}
}
for _, friendID := range friends {
s.friendNotificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, friendID)
}
Expand Down
93 changes: 27 additions & 66 deletions pkg/common/db/controller/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,83 +41,34 @@
TakeGroup(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
SearchGroup(
ctx context.Context,
keyword string,
pageNumber, showNumber int32,
) (uint32, []*relationtb.GroupModel, error)
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationtb.GroupModel, error)
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
DismissGroup(ctx context.Context, groupID string, deleteMember bool) error // 解散群,并删除群成员
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
// GroupMember
TakeGroupMember(
ctx context.Context,
groupID string,
userID string,
) (groupMember *relationtb.GroupMemberModel, err error)
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationtb.GroupMemberModel, err error)
TakeGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error)
FindGroupMember(
ctx context.Context,
groupIDs []string,
userIDs []string,
roleLevels []int32,
) ([]*relationtb.GroupMemberModel, error)
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationtb.GroupMemberModel, error)
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
PageGroupRequest(
ctx context.Context,
groupIDs []string,
pageNumber, showNumber int32,
) (uint32, []*relationtb.GroupRequestModel, error)
// PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber,
// showNumber int32) (uint32, []*relationtb.GroupMemberModel, error)
PageGetJoinGroup(
ctx context.Context,
userID string,
pageNumber, showNumber int32,
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
PageGetGroupMember(
ctx context.Context,
groupID string,
pageNumber, showNumber int32,
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
SearchGroupMember(
ctx context.Context,
keyword string,
groupIDs []string,
userIDs []string,
roleLevels []int32,
pageNumber, showNumber int32,
) (uint32, []*relationtb.GroupMemberModel, error)
HandlerGroupRequest(
ctx context.Context,
groupID string,
userID string,
handledMsg string,
handleResult int32,
member *relationtb.GroupMemberModel,
) error
PageGroupRequest(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (uint32, []*relationtb.GroupRequestModel, error)

PageGetJoinGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
PageGetGroupMember(ctx context.Context, groupID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationtb.GroupMemberModel, error)
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationtb.GroupMemberModel) error
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error)
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
TransferGroupOwner(
ctx context.Context,
groupID string,
oldOwnerUserID, newOwnerUserID string,
roleLevel int32,
) error // 转让群
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
UpdateGroupMembers(ctx context.Context, data []*relationtb.BatchUpdateGroupMember) error
// GroupRequest
CreateGroupRequest(ctx context.Context, requests []*relationtb.GroupRequestModel) error
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationtb.GroupRequestModel, error)
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationtb.GroupRequestModel, error)
PageGroupRequestUser(
ctx context.Context,
userID string,
pageNumber, showNumber int32,
) (uint32, []*relationtb.GroupRequestModel, error)
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationtb.GroupRequestModel, error)
// SuperGroupModelInterface
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationtb.SuperGroupModel, error)
FindJoinSuperGroup(ctx context.Context, userID string) ([]string, error)
Expand Down Expand Up @@ -310,12 +261,22 @@
return g.groupRequestDB.PageGroup(ctx, groupIDs, pageNumber, showNumber)
}

func (g *groupDatabase) FindGroupMember(
ctx context.Context,
groupIDs []string,
userIDs []string,
roleLevels []int32,
) (totalGroupMembers []*relationtb.GroupMemberModel, err error) {
func (g *groupDatabase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) (totalGroupMembers []*relationtb.GroupMemberModel, err error) {
if len(groupIDs) == 0 && len(roleLevels) == 0 && len(userIDs) == 1 {
gIDs, err := g.cache.GetJoinedGroupIDs(ctx, userIDs[0])
if err != nil {
return nil, err
}
var res []*relationtb.GroupMemberModel
for _, groupID := range gIDs {
v, err := g.cache.GetGroupMemberInfo(ctx, groupID, userIDs[0])
if err != nil {
return nil, err
}
res = append(res, v)
}
return res, nil

Check failure on line 278 in pkg/common/db/controller/group.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
}
if len(roleLevels) == 0 {
for _, groupID := range groupIDs {
groupMembers, err := g.cache.GetGroupMembersInfo(ctx, groupID, userIDs)
Expand Down
7 changes: 7 additions & 0 deletions pkg/rpcclient/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,10 @@
})
return err
}

func (g *GroupRpcClient) NotificationUserInfoUpdate(ctx context.Context, userID string) error {
_, err := g.Client.NotificationUserInfoUpdate(ctx, &group.NotificationUserInfoUpdateReq{
UserID: userID,
})
return err

Check failure on line 216 in pkg/rpcclient/group.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
}
5 changes: 4 additions & 1 deletion pkg/rpcclient/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
UserID: userID,
})
return resp.GlobalRecvMsgOpt, err
if err != nil {
return 0, err
}
return resp.GlobalRecvMsgOpt, nil

Check failure on line 153 in pkg/rpcclient/user.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
}

// Access verifies the access rights for the provided user ID.
Expand Down
Loading