mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 09:05:59 +08:00
fix groupMuted send msg
This commit is contained in:
@@ -164,6 +164,21 @@ func msgListIsFull(chat *db.UserChat) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func CheckGroupUserMinSeq(operationID, groupID, userID string, diffusionType int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CheckUserMinSeqWithMongo(operationID, userID string, diffusionType int) error {
|
||||
//var seqRedis uint64
|
||||
//var err error
|
||||
//if diffusionType == constant.WriteDiffusion {
|
||||
// seqRedis, err = db.DB.GetUserMinSeq(ID)
|
||||
//} else {
|
||||
// seqRedis, err = db.DB.GetGroupUserMinSeq(ID)
|
||||
//}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
|
||||
var seqRedis uint64
|
||||
var err error
|
||||
@@ -185,17 +200,10 @@ func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
|
||||
if msg == nil {
|
||||
return nil
|
||||
}
|
||||
var seqMongo uint32
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
seqMongo = msgPb.Seq
|
||||
if math.Abs(float64(seqMongo-uint32(seqRedis))) > 10 {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "seqMongo, seqRedis", seqMongo, seqRedis, ID, "redis maxSeq is different with msg.Seq > 10", "status: ", msgPb.Status, msg.SendTime)
|
||||
if math.Abs(float64(msg.Seq-uint32(seqRedis))) > 10 {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "seqMongo, seqRedis", msg.Seq, seqRedis, ID, "redis maxSeq is different with msg.Seq > 10", "status: ", msg.Status, msg.SendTime)
|
||||
} else {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "seqMongo, seqRedis", seqMongo, seqRedis, ID, "seq and msg OK", "status:", msgPb.Status, msg.SendTime)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "seqMongo, seqRedis", msg.Seq, seqRedis, ID, "seq and msg OK", "status:", msg.Status, msg.SendTime)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -30,11 +30,8 @@ func StartCronTask(userID, workingGroupID string) {
|
||||
fmt.Println("clear msg finished")
|
||||
return
|
||||
}
|
||||
clearFunc := func() {
|
||||
ClearAll()
|
||||
}
|
||||
c := cron.New()
|
||||
_, err := c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, clearFunc)
|
||||
_, err := c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, ClearAll)
|
||||
if err != nil {
|
||||
fmt.Println("start cron failed", err.Error(), config.Config.Mongo.ChatRecordsClearTime)
|
||||
panic(err)
|
||||
@@ -53,7 +50,6 @@ func getCronTaskOperationID() string {
|
||||
func ClearAll() {
|
||||
operationID := getCronTaskOperationID()
|
||||
log.NewInfo(operationID, "====================== start del cron task ======================")
|
||||
//var userIDList []string
|
||||
var err error
|
||||
userIDList, err := im_mysql_model.SelectAllUserID()
|
||||
if err == nil {
|
||||
@@ -61,7 +57,6 @@ func ClearAll() {
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
//return
|
||||
// working group msg clear
|
||||
workingGroupIDList, err := im_mysql_model.GetGroupIDListByGroupType(constant.WorkingGroup)
|
||||
if err == nil {
|
||||
@@ -82,6 +77,9 @@ func StartClearMsg(operationID string, userIDList []string) {
|
||||
if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), userID, err)
|
||||
}
|
||||
if err := CheckUserMinSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), userID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,5 +98,10 @@ func StartClearWorkingGroupMsg(operationID string, workingGroupIDList []string)
|
||||
if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, err)
|
||||
}
|
||||
for _, userID := range userIDList {
|
||||
if err := CheckGroupUserMinSeq(operationID, groupID, userID, constant.ReadDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user