Skip to content

Commit a395c82

Browse files
authored
Merge pull request #3023 from openimsdk/cherry-pick-435d8bb
deps: Merge #3022 PRs into pre-release-v3.8.3
2 parents 5f33342 + 3d064d6 commit a395c82

File tree

4 files changed

+32
-49
lines changed

4 files changed

+32
-49
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/gorilla/websocket v1.5.1
1313
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
1414
github.com/mitchellh/mapstructure v1.5.0
15-
github.com/openimsdk/protocol v0.0.72-alpha.68
15+
github.com/openimsdk/protocol v0.0.72-alpha.69
1616
github.com/openimsdk/tools v0.0.50-alpha.62
1717
github.com/pkg/errors v0.9.1 // indirect
1818
github.com/prometheus/client_golang v1.18.0

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
317317
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
318318
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
319319
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
320-
github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y=
321-
github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
322-
github.com/openimsdk/protocol v0.0.72-alpha.68 h1:Ekn6S9Ftt12Xs/p9kJ39RDr2gSwIczz+MmSHQE4lAek=
323-
github.com/openimsdk/protocol v0.0.72-alpha.68/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
320+
github.com/openimsdk/gomake v0.0.15-alpha.2 h1:5Q8yl8ezy2yx+q8/ucU/t4kJnDfCzNOrkXcDACCqtyM=
321+
github.com/openimsdk/gomake v0.0.15-alpha.2/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
322+
github.com/openimsdk/protocol v0.0.72-alpha.69 h1:b22oY2XTdBR/BePqA73KsrM3GDF3Vk8YcBEXZU4ArJc=
323+
github.com/openimsdk/protocol v0.0.72-alpha.69/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
324324
github.com/openimsdk/tools v0.0.50-alpha.62 h1:e/m1XL7+EXbkOoxr/En/612WcOPKOUHPBj0++gG6MuQ=
325325
github.com/openimsdk/tools v0.0.50-alpha.62/go.mod h1:JowL2jYr8tu4vcQe+5hJh4v3BtSx1T0CIS3pgU/Mw+U=
326326
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=

pkg/rpccache/online.go

+3-44
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,6 @@ func (o *OnlineCache) GetUserOnlinePlatform(ctx context.Context, userID string)
206206
return platformIDs, nil
207207
}
208208

209-
// func (o *OnlineCache) GetUserOnlinePlatformBatch(ctx context.Context, userIDs []string) (map[string]int32, error) {
210-
// platformIDs, err := o.getUserOnlinePlatform(ctx, userIDs)
211-
// if err != nil {
212-
// return nil, err
213-
// }
214-
// tmp := make([]int32, len(platformIDs))
215-
// copy(tmp, platformIDs)
216-
// return platformIDs, nil
217-
// }
218-
219209
func (o *OnlineCache) GetUserOnline(ctx context.Context, userID string) (bool, error) {
220210
platformIDs, err := o.getUserOnlinePlatform(ctx, userID)
221211
if err != nil {
@@ -225,6 +215,9 @@ func (o *OnlineCache) GetUserOnline(ctx context.Context, userID string) (bool, e
225215
}
226216

227217
func (o *OnlineCache) getUserOnlinePlatformBatch(ctx context.Context, userIDs []string) (map[string][]int32, error) {
218+
if len(userIDs) == 0 {
219+
return nil, nil
220+
}
228221
platformIDsMap, err := o.lruCache.GetBatch(userIDs, func(missingUsers []string) (map[string][]int32, error) {
229222
platformIDsMap := make(map[string][]int32)
230223
usersStatus, err := o.client.GetUsersOnlinePlatform(ctx, missingUsers)
@@ -281,40 +274,6 @@ func (o *OnlineCache) GetUsersOnline(ctx context.Context, userIDs []string) ([]s
281274
return userIDs, offlineUserIDs, nil
282275
}
283276

284-
//func (o *OnlineCache) GetUsersOnline(ctx context.Context, userIDs []string) ([]string, error) {
285-
// onlineUserIDs := make([]string, 0, len(userIDs))
286-
// for _, userID := range userIDs {
287-
// online, err := o.GetUserOnline(ctx, userID)
288-
// if err != nil {
289-
// return nil, err
290-
// }
291-
// if online {
292-
// onlineUserIDs = append(onlineUserIDs, userID)
293-
// }
294-
// }
295-
// log.ZDebug(ctx, "OnlineCache GetUsersOnline", "userIDs", userIDs, "onlineUserIDs", onlineUserIDs)
296-
// return onlineUserIDs, nil
297-
//}
298-
//
299-
//func (o *OnlineCache) GetGroupOnline(ctx context.Context, groupID string) ([]string, error) {
300-
// userIDs, err := o.group.GetGroupMemberIDs(ctx, groupID)
301-
// if err != nil {
302-
// return nil, err
303-
// }
304-
// var onlineUserIDs []string
305-
// for _, userID := range userIDs {
306-
// online, err := o.GetUserOnline(ctx, userID)
307-
// if err != nil {
308-
// return nil, err
309-
// }
310-
// if online {
311-
// onlineUserIDs = append(onlineUserIDs, userID)
312-
// }
313-
// }
314-
// log.ZDebug(ctx, "OnlineCache GetGroupOnline", "groupID", groupID, "onlineUserIDs", onlineUserIDs, "allUserID", userIDs)
315-
// return onlineUserIDs, nil
316-
//}
317-
318277
func (o *OnlineCache) setUserOnline(userID string, platformIDs []int32) {
319278
switch o.fullUserCache {
320279
case true:

pkg/rpcli/group.go

+24
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,27 @@ func (x *GroupClient) GetGroupMemberUserIDs(ctx context.Context, groupID string)
4646
req := &group.GetGroupMemberUserIDsReq{GroupID: groupID}
4747
return extractField(ctx, x.GroupClient.GetGroupMemberUserIDs, req, (*group.GetGroupMemberUserIDsResp).GetUserIDs)
4848
}
49+
50+
func (x *GroupClient) GetGroupMembersInfo(ctx context.Context, groupID string, userIDs []string) ([]*sdkws.GroupMemberFullInfo, error) {
51+
if len(userIDs) == 0 {
52+
return nil, nil
53+
}
54+
req := &group.GetGroupMembersInfoReq{GroupID: groupID, UserIDs: userIDs}
55+
return extractField(ctx, x.GroupClient.GetGroupMembersInfo, req, (*group.GetGroupMembersInfoResp).GetMembers)
56+
}
57+
58+
func (x *GroupClient) GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) {
59+
return firstValue(x.GetGroupMembersInfo(ctx, groupID, []string{userID}))
60+
}
61+
62+
func (x *GroupClient) GetGroupMemberMapInfo(ctx context.Context, groupID string, userIDs []string) (map[string]*sdkws.GroupMemberFullInfo, error) {
63+
members, err := x.GetGroupMembersInfo(ctx, groupID, userIDs)
64+
if err != nil {
65+
return nil, err
66+
}
67+
memberMap := make(map[string]*sdkws.GroupMemberFullInfo)
68+
for _, member := range members {
69+
memberMap[member.UserID] = member
70+
}
71+
return memberMap, nil
72+
}

0 commit comments

Comments
 (0)