mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-31 03:23:43 +08:00
test cron
This commit is contained in:
parent
8839c36917
commit
389271c00d
@ -10,6 +10,8 @@ import (
|
|||||||
goRedis "github.com/go-redis/redis/v8"
|
goRedis "github.com/go-redis/redis/v8"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"math"
|
"math"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const oldestList = 0
|
const oldestList = 0
|
||||||
@ -120,11 +122,12 @@ func deleteMongoMsg(operationID string, ID string, index int64, delMsgIDList *[]
|
|||||||
return getDelMaxSeqByIDList(*delMsgIDList) + 1, utils.Wrap(err, "")
|
return getDelMaxSeqByIDList(*delMsgIDList) + 1, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 递归结束
|
||||||
return msgPb.Seq, nil
|
return msgPb.Seq, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 该列表中消息全部为老消息, 加入删除列表继续递归
|
// 该列表中消息全部为老消息并且列表满了, 加入删除列表继续递归
|
||||||
if len(msgs.Msg) > 0 {
|
if msgListIsFull(msgs) {
|
||||||
msgPb := &server_api_params.MsgData{}
|
msgPb := &server_api_params.MsgData{}
|
||||||
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, msgPb)
|
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, msgPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -141,6 +144,19 @@ func deleteMongoMsg(operationID string, ID string, index int64, delMsgIDList *[]
|
|||||||
return seq, nil
|
return seq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func msgListIsFull(chat *db.UserChat) bool {
|
||||||
|
index, _ := strconv.Atoi(strings.Split(chat.UID, ":")[1])
|
||||||
|
if index == 0 {
|
||||||
|
if len(chat.Msg) >= 4999 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(chat.Msg) >= 5000 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func getDelMaxSeqByIDList(delMsgIDList [][2]interface{}) uint32 {
|
func getDelMaxSeqByIDList(delMsgIDList [][2]interface{}) uint32 {
|
||||||
if len(delMsgIDList) == 0 {
|
if len(delMsgIDList) == 0 {
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user