From 8501c66d14b6774157886ae5b6538139ca5e7f94 Mon Sep 17 00:00:00 2001 From: Brabem <69128477+luhaoling@users.noreply.github.com> Date: Wed, 13 Mar 2024 10:13:15 +0800 Subject: [PATCH] fix: fix the protocol version (#2074) --- go.mod | 2 +- go.sum | 4 ++-- internal/api/route.go | 1 - internal/rpc/group/group.go | 13 +++---------- internal/rpc/msg/sync_msg.go | 4 ++-- internal/rpc/third/log.go | 7 +++++++ pkg/common/db/mgo/group.go | 4 +++- pkg/common/db/unrelation/msg.go | 4 ++-- scripts/install/test.sh | 2 +- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index 10f08fa53..da2815571 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( firebase.google.com/go v3.13.0+incompatible - github.com/OpenIMSDK/protocol v0.0.55 + github.com/OpenIMSDK/protocol v0.0.56 github.com/OpenIMSDK/tools v0.0.37 github.com/bwmarrin/snowflake v0.3.0 // indirect github.com/dtm-labs/rockscache v0.1.1 diff --git a/go.sum b/go.sum index 230c142c6..c3803ef58 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIw github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/IBM/sarama v1.42.2 h1:VoY4hVIZ+WQJ8G9KNY/SQlWguBQXQ9uvFPOnrcu8hEw= github.com/IBM/sarama v1.42.2/go.mod h1:FLPGUGwYqEs62hq2bVG6Io2+5n+pS6s/WOXVKWSLFtE= -github.com/OpenIMSDK/protocol v0.0.55 h1:eBjg8DyuhxGmuCUjpoZjg6MJJJXU/xJ3xJwFhrn34yA= -github.com/OpenIMSDK/protocol v0.0.55/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= +github.com/OpenIMSDK/protocol v0.0.56 h1:mbVFyDBachEsmJLfYW5AU1z2KL8AUEpoHG8RPCIxjgg= +github.com/OpenIMSDK/protocol v0.0.56/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/tools v0.0.37 h1:qvDqmA4RbEJtPjZouWCkVuf/pjm6Y8nUrG5iH2gcnOg= github.com/OpenIMSDK/tools v0.0.37/go.mod h1:wBfR5CYmEyvxl03QJbTkhz1CluK6J4/lX0lviu8JAjE= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= diff --git a/internal/api/route.go b/internal/api/route.go index 92fa83fb0..ca0b6829e 100644 --- a/internal/api/route.go +++ b/internal/api/route.go @@ -50,7 +50,6 @@ import ( ) func Start(config *config.GlobalConfig, port int, proPort int) error { - log.ZDebug(context.Background(), "configAPI1111111111111111111", config, "port", port, "javafdasfs") if port == 0 || proPort == 0 { err := "port or proPort is empty:" + strconv.Itoa(port) + "," + strconv.Itoa(proPort) return errs.Wrap(fmt.Errorf(err)) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 4be8fab0c..d966bfad8 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -1068,6 +1068,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) group []*relationtb.GroupModel err error ) + if req.GroupID != "" { group, err = s.db.FindGroup(ctx, []string{req.GroupID}) resp.Total = uint32(len(group)) @@ -1080,15 +1081,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) return nil, err } - var groups []*relationtb.GroupModel - for _, v := range group { - if v.Status == constant.GroupStatusDismissed { - resp.Total-- - continue - } - groups = append(groups, v) - } - groupIDs := utils.Slice(groups, func(e *relationtb.GroupModel) string { + groupIDs := utils.Slice(group, func(e *relationtb.GroupModel) string { return e.GroupID }) ownerMembers, err := s.db.FindGroupsOwner(ctx, groupIDs) @@ -1102,7 +1095,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) if err != nil { return nil, err } - resp.Groups = utils.Slice(groups, func(group *relationtb.GroupModel) *pbgroup.CMSGroup { + resp.Groups = utils.Slice(group, func(group *relationtb.GroupModel) *pbgroup.CMSGroup { var ( userID string username string diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go index 6fa4a0c9d..379302e98 100644 --- a/internal/rpc/msg/sync_msg.go +++ b/internal/rpc/msg/sync_msg.go @@ -131,7 +131,7 @@ func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq sendIDs = append(sendIDs, chatLog.SendID) } switch chatLog.SessionType { - case constant.SingleChatType: + case constant.SingleChatType, constant.NotificationChatType: recvIDs = append(recvIDs, chatLog.RecvID) case constant.GroupChatType, constant.SuperGroupChatType: groupIDs = append(groupIDs, chatLog.GroupID) @@ -173,7 +173,7 @@ func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq pbchatLog.SenderNickname = sendMap[chatLog.SendID] } switch chatLog.SessionType { - case constant.SingleChatType: + case constant.SingleChatType, constant.NotificationChatType: pbchatLog.RecvNickname = recvMap[chatLog.RecvID] case constant.GroupChatType, constant.SuperGroupChatType: diff --git a/internal/rpc/third/log.go b/internal/rpc/third/log.go index b425dd819..97428254c 100644 --- a/internal/rpc/third/log.go +++ b/internal/rpc/third/log.go @@ -133,6 +133,13 @@ func (t *thirdServer) SearchLogs(ctx context.Context, req *third.SearchLogsReq) if req.StartTime > req.EndTime { return nil, errs.ErrArgs.Wrap("startTime>endTime") } + if req.StartTime == 0 && req.EndTime == 0 { + t := time.Date(2019, time.January, 1, 0, 0, 0, 0, time.UTC) + timestampMills := t.UnixNano() / int64(time.Millisecond) + req.StartTime = timestampMills + req.EndTime = time.Now().UnixNano() / int64(time.Millisecond) + } + total, logs, err := t.thirdDatabase.SearchLogs(ctx, req.Keyword, time.UnixMilli(req.StartTime), time.UnixMilli(req.EndTime), req.Pagination) if err != nil { return nil, err diff --git a/pkg/common/db/mgo/group.go b/pkg/common/db/mgo/group.go index 1bef90ebe..a3d777f59 100644 --- a/pkg/common/db/mgo/group.go +++ b/pkg/common/db/mgo/group.go @@ -16,6 +16,7 @@ package mgo import ( "context" + "github.com/OpenIMSDK/protocol/constant" "time" "github.com/OpenIMSDK/tools/errs" @@ -69,7 +70,8 @@ func (g *GroupMgo) Take(ctx context.Context, groupID string) (group *relation.Gr } func (g *GroupMgo) Search(ctx context.Context, keyword string, pagination pagination.Pagination) (total int64, groups []*relation.GroupModel, err error) { - return mgoutil.FindPage[*relation.GroupModel](ctx, g.coll, bson.M{"group_name": bson.M{"$regex": keyword}}, pagination) + return mgoutil.FindPage[*relation.GroupModel](ctx, g.coll, bson.M{"group_name": bson.M{"$regex": keyword}, + "status": bson.M{"$ne": constant.GroupStatusDismissed}}, pagination) } func (g *GroupMgo) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) { diff --git a/pkg/common/db/unrelation/msg.go b/pkg/common/db/unrelation/msg.go index 4deca56f8..a129f3e99 100644 --- a/pkg/common/db/unrelation/msg.go +++ b/pkg/common/db/unrelation/msg.go @@ -1063,8 +1063,8 @@ func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessa // Changed to keyed fields for bson.M to avoid govet errors condition = append(condition, bson.M{"$eq": bson.A{bson.M{"$dateToString": bson.M{"format": "%Y-%m-%d", "date": bson.M{"$toDate": "$$item.msg.send_time"}}}, req.SendTime}}) } - if req.MsgType != 0 { - condition = append(condition, bson.M{"$eq": bson.A{"$$item.msg.content_type", req.MsgType}}) + if req.ContentType != 0 { + condition = append(condition, bson.M{"$eq": bson.A{"$$item.msg.content_type", req.ContentType}}) } if req.SessionType != 0 { condition = append(condition, bson.M{"$eq": bson.A{"$$item.msg.session_type", req.SessionType}}) diff --git a/scripts/install/test.sh b/scripts/install/test.sh index 4ea3f16ca..326307570 100755 --- a/scripts/install/test.sh +++ b/scripts/install/test.sh @@ -1272,7 +1272,7 @@ openim::test::search_msg() { { "sendID": "${sendID}", "recvID": "${recvID}", - "msgType": ${msgType}, + "contentType": ${msgType}, "sendTime": "${sendTime}", "sessionType": ${sessionType}, "pagination": {