diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index bfaa36a23..55a4fba69 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -420,30 +420,31 @@ func (db *commonMsgDatabase) handlerDBMsg(ctx context.Context, userID, conversat if msg.Msg.Content == "" { return } + //var quoteMsgItem map[string]json.RawMessage var quoteMsg struct { Text string `json:"text,omitempty"` - QuoteMsg *sdkws.MsgData `json:"quote_msg,omitempty"` + QuoteMessage *sdkws.MsgData `json:"quoteMessage,omitempty"` MessageEntityList json.RawMessage `json:"messageEntityList,omitempty"` } if err := json.Unmarshal([]byte(msg.Msg.Content), "eMsg); err != nil { log.ZError(ctx, "json.Unmarshal", err) return } - if quoteMsg.QuoteMsg == nil || quoteMsg.QuoteMsg.ContentType == constant.MsgRevokeNotification { + if quoteMsg.QuoteMessage == nil { return } - msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, userID, db.msg.GetDocID(conversationID, quoteMsg.QuoteMsg.Seq), []int64{quoteMsg.QuoteMsg.Seq}) + msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, userID, db.msg.GetDocID(conversationID, quoteMsg.QuoteMessage.Seq), []int64{quoteMsg.QuoteMessage.Seq}) if err != nil { - log.ZError(ctx, "GetMsgBySeqIndexIn1Doc", err, "conversationID", conversationID, "seq", quoteMsg.QuoteMsg.Seq) + log.ZError(ctx, "GetMsgBySeqIndexIn1Doc", err, "conversationID", conversationID, "seq", quoteMsg.QuoteMessage.Seq) return } if len(msgs) == 0 { - return - } - if msgs[0].Msg.ContentType == constant.MsgRevokeNotification { - quoteMsg.QuoteMsg.ContentType = constant.MsgRevokeNotification - quoteMsg.QuoteMsg.Content = []byte(msgs[0].Msg.Content) - return + quoteMsg.QuoteMessage = nil + } else { + if msgs[0].Msg.ContentType == constant.MsgRevokeNotification { + quoteMsg.QuoteMessage.ContentType = constant.MsgRevokeNotification + quoteMsg.QuoteMessage.Content = []byte(msgs[0].Msg.Content) + } } data, err := json.Marshal("eMsg) if err != nil { diff --git a/pkg/common/db/controller/msg_test.go b/pkg/common/db/controller/msg_test.go index 80e2db122..ba5aecd25 100644 --- a/pkg/common/db/controller/msg_test.go +++ b/pkg/common/db/controller/msg_test.go @@ -144,9 +144,9 @@ func Test_BatchInsertChat2DB(t *testing.T) { } func GetDB() *commonMsgDatabase { - config.Config.Mongo.Address = []string{"192.168.44.128:37017"} + config.Config.Mongo.Address = []string{"203.56.175.233:37017"} // config.Config.Mongo.Timeout = 60 - config.Config.Mongo.Database = "openIM" + config.Config.Mongo.Database = "openIM_v3" // config.Config.Mongo.Source = "admin" config.Config.Mongo.Username = "root" config.Config.Mongo.Password = "openIM123" @@ -232,37 +232,17 @@ func Test_FindBySeq(t *testing.T) { // } //} -//func Test_Delete1(t *testing.T) { -// config.Config.Mongo.DBAddress = []string{"192.168.44.128:37017"} -// config.Config.Mongo.DBTimeout = 60 -// config.Config.Mongo.DBDatabase = "openIM" -// config.Config.Mongo.DBSource = "admin" -// config.Config.Mongo.DBUserName = "root" -// config.Config.Mongo.DBPassword = "openIM123" -// config.Config.Mongo.DBMaxPoolSize = 100 -// config.Config.Mongo.DBRetainChatRecords = 3650 -// config.Config.Mongo.ChatRecordsClearTime = "0 2 * * 3" -// -// mongo, err := unrelation.NewMongo() -// if err != nil { -// panic(err) -// } -// err = mongo.GetDatabase().Client().Ping(context.Background(), nil) -// if err != nil { -// panic(err) -// } -// -// c := mongo.GetClient().Database("openIM").Collection("msg") -// -// var o unrelationtb.MsgDocModel -// -// err = c.FindOne(context.Background(), bson.M{"doc_id": "test:0"}).Decode(&o) -// if err != nil { -// panic(err) -// } -// -// for i, model := range o.Msg { -// fmt.Println(i, model == nil) -// } -// -//} +func TestName(t *testing.T) { + db := GetDB() + var seqs []int64 + for i := int64(1); i <= 4; i++ { + seqs = append(seqs, i) + } + msgs, err := db.getMsgBySeqsRange(context.Background(), "4931176757", "si_3866692501_4931176757", seqs, seqs[0], seqs[len(seqs)-1]) + if err != nil { + t.Fatal(err) + } + + t.Log(msgs) + +}