Skip to content

Commit 6e66684

Browse files
committed
perf: update json date
1 parent 7e18336 commit 6e66684

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

cmd/common/beat_service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ func (b *BeatService) KeepCheckTokens() {
176176
sessions := b.GetSessions()
177177
tokens := make(map[string]model.TokenCheckStatus, len(sessions))
178178
for _, s := range sessions {
179+
if s.TokenId == "" {
180+
logger.Infof("Check session %s token id empty", s.ID)
181+
continue
182+
}
179183
ret, ok := tokens[s.TokenId]
180184
if ok {
181185
b.handleTokenCheck(s, &ret)

cmd/impl/jms_chat.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package impl
22

33
import (
44
"context"
5+
"encoding/json"
56

6-
"github.com/go-viper/mapstructure/v2"
77
"github.com/jumpserver/wisp/pkg/logger"
88
pb "github.com/jumpserver/wisp/protobuf-go/protobuf"
99
"google.golang.org/protobuf/types/known/structpb"
@@ -21,10 +21,17 @@ func (j *JMServer) GetAccountChat(ctx context.Context, req *pb.Empty) (*pb.Accou
2121
Status: &status,
2222
}, nil
2323
}
24-
var m map[string]interface{}
25-
err = mapstructure.Decode(accountChatDetail, &m)
24+
var m map[string]any
25+
jsonBytes, err := json.Marshal(accountChatDetail)
2626
if err != nil {
27-
logger.Errorf("mapstructure decode: %v", err)
27+
logger.Errorf("Encode accountChatDetail failed: %v", err)
28+
status.Err = err.Error()
29+
return &pb.AccountDetailResponse{
30+
Status: &status,
31+
}, nil
32+
}
33+
if err = json.Unmarshal(jsonBytes, &m); err != nil {
34+
logger.Errorf("Unmarshal to map failed: %v", err)
2835
status.Err = err.Error()
2936
return &pb.AccountDetailResponse{
3037
Status: &status,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/aws/aws-sdk-go v1.44.306
99
github.com/elastic/go-elasticsearch/v6 v6.8.5
1010
github.com/elastic/go-elasticsearch/v8 v8.14.0
11-
github.com/go-viper/mapstructure/v2 v2.4.0
1211
github.com/gorilla/websocket v1.5.3
1312
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.25.4+incompatible
1413
github.com/jumpserver-dev/sdk-go v0.0.0-20250925081620-d22b2b8e24d1
@@ -30,6 +29,7 @@ require (
3029
github.com/go-logr/logr v1.4.1 // indirect
3130
github.com/go-logr/stdr v1.2.2 // indirect
3231
github.com/go-ole/go-ole v1.2.6 // indirect
32+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
3333
github.com/google/uuid v1.6.0 // indirect
3434
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3535
github.com/jmespath/go-jmespath v0.4.0 // indirect

0 commit comments

Comments
 (0)