From 41480cedbc840e4339010857293d974d2754d915 Mon Sep 17 00:00:00 2001 From: pluto <2631223275@qq.com> Date: Wed, 16 Aug 2023 14:55:30 +0800 Subject: [PATCH] Judging whether to be kicked out --- pkg/common/db/cache/user.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/cache/user.go b/pkg/common/db/cache/user.go index e58a8b1c0..3ed509596 100644 --- a/pkg/common/db/cache/user.go +++ b/pkg/common/db/cache/user.go @@ -269,8 +269,16 @@ func (u *UserCacheRedis) SetUserStatus(ctx context.Context, list []*user.OnlineS } } else { onlineStatus.Status = constant.Online - for _, val := range status.PlatformIDs { - onlineStatus.PlatformIDs = append(onlineStatus.PlatformIDs, val) + // Judging whether to be kicked out. + flag := false + for _, val := range onlineStatus.PlatformIDs { + if val == status.PlatformIDs[0] { + flag = true + break + } + } + if !flag { + onlineStatus.PlatformIDs = append(onlineStatus.PlatformIDs, status.PlatformIDs[0]) } newjsonData, err := json.Marshal(&onlineStatus) if err != nil {