fix: the original message referenced by the pull message processing is withdrawn

pull/1388/head
withchao 2 years ago
parent 248b2b7cf8
commit 42009fd9a5

@ -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), &quoteMsg); 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
}
quoteMsg.QuoteMessage = nil
} else {
if msgs[0].Msg.ContentType == constant.MsgRevokeNotification {
quoteMsg.QuoteMsg.ContentType = constant.MsgRevokeNotification
quoteMsg.QuoteMsg.Content = []byte(msgs[0].Msg.Content)
return
quoteMsg.QuoteMessage.ContentType = constant.MsgRevokeNotification
quoteMsg.QuoteMessage.Content = []byte(msgs[0].Msg.Content)
}
}
data, err := json.Marshal(&quoteMsg)
if err != nil {

@ -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)
}

Loading…
Cancel
Save