@@ -206,16 +206,6 @@ func (o *OnlineCache) GetUserOnlinePlatform(ctx context.Context, userID string)
206
206
return platformIDs , nil
207
207
}
208
208
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
-
219
209
func (o * OnlineCache ) GetUserOnline (ctx context.Context , userID string ) (bool , error ) {
220
210
platformIDs , err := o .getUserOnlinePlatform (ctx , userID )
221
211
if err != nil {
@@ -225,6 +215,9 @@ func (o *OnlineCache) GetUserOnline(ctx context.Context, userID string) (bool, e
225
215
}
226
216
227
217
func (o * OnlineCache ) getUserOnlinePlatformBatch (ctx context.Context , userIDs []string ) (map [string ][]int32 , error ) {
218
+ if len (userIDs ) == 0 {
219
+ return nil , nil
220
+ }
228
221
platformIDsMap , err := o .lruCache .GetBatch (userIDs , func (missingUsers []string ) (map [string ][]int32 , error ) {
229
222
platformIDsMap := make (map [string ][]int32 )
230
223
usersStatus , err := o .client .GetUsersOnlinePlatform (ctx , missingUsers )
@@ -281,40 +274,6 @@ func (o *OnlineCache) GetUsersOnline(ctx context.Context, userIDs []string) ([]s
281
274
return userIDs , offlineUserIDs , nil
282
275
}
283
276
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
-
318
277
func (o * OnlineCache ) setUserOnline (userID string , platformIDs []int32 ) {
319
278
switch o .fullUserCache {
320
279
case true :
0 commit comments