mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-13 05:25:59 +08:00
style: add format and lint (#773)
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Vendored
+2
-1
@@ -24,9 +24,10 @@ import (
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Vendored
+2
-1
@@ -21,8 +21,9 @@ import (
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Vendored
+2
-1
@@ -23,9 +23,10 @@ import (
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
unrelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Vendored
+2
-1
@@ -22,9 +22,10 @@ import (
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/mw/specialerror"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Vendored
+5
-3
@@ -16,23 +16,25 @@ package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
||||
|
||||
"github.com/dtm-labs/rockscache"
|
||||
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
"github.com/gogo/protobuf/jsonpb"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
|
||||
Vendored
+7
-6
@@ -17,12 +17,13 @@ package cache
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/OpenIMSDK/protocol/user"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"hash/crc32"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/user"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
@@ -163,12 +164,12 @@ func (u *UserCacheRedis) getOnlineStatusKey(userID string) string {
|
||||
return olineStatusKey + userID
|
||||
}
|
||||
|
||||
// GetUserStatus get user status
|
||||
// GetUserStatus get user status.
|
||||
func (u *UserCacheRedis) GetUserStatus(ctx context.Context, userIDs []string) ([]*user.OnlineStatus, error) {
|
||||
var res []*user.OnlineStatus
|
||||
for _, userID := range userIDs {
|
||||
UserIDNum := crc32.ChecksumIEEE([]byte(userID))
|
||||
var modKey = strconv.Itoa(int(UserIDNum % statusMod))
|
||||
modKey := strconv.Itoa(int(UserIDNum % statusMod))
|
||||
var onlineStatus user.OnlineStatus
|
||||
key := olineStatusKey + modKey
|
||||
result, err := u.rdb.HGet(ctx, key, userID).Result()
|
||||
@@ -195,12 +196,12 @@ func (u *UserCacheRedis) GetUserStatus(ctx context.Context, userIDs []string) ([
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// SetUserStatus Set the user status and save it in redis
|
||||
// SetUserStatus Set the user status and save it in redis.
|
||||
func (u *UserCacheRedis) SetUserStatus(ctx context.Context, list []*user.OnlineStatus) error {
|
||||
for _, status := range list {
|
||||
var isNewKey int64
|
||||
UserIDNum := crc32.ChecksumIEEE([]byte(status.UserID))
|
||||
var modKey = strconv.Itoa(int(UserIDNum % statusMod))
|
||||
modKey := strconv.Itoa(int(UserIDNum % statusMod))
|
||||
key := olineStatusKey + modKey
|
||||
jsonData, err := json.Marshal(status)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user