mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
clear msg tools
This commit is contained in:
parent
c7d2f7f3b2
commit
36fee3f14a
@ -77,7 +77,7 @@ func (c *MsgTool) ClearConversationsMsg(ctx context.Context, conversationIDs []s
|
|||||||
if err := c.msgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, int64(config.Config.Mongo.DBRetainChatRecords*24*60*60)); err != nil {
|
if err := c.msgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, int64(config.Config.Mongo.DBRetainChatRecords*24*60*60)); err != nil {
|
||||||
log.ZError(ctx, "DeleteUserSuperGroupMsgsAndSetMinSeq failed", err, "conversationID", conversationID, "DBRetainChatRecords", config.Config.Mongo.DBRetainChatRecords)
|
log.ZError(ctx, "DeleteUserSuperGroupMsgsAndSetMinSeq failed", err, "conversationID", conversationID, "DBRetainChatRecords", config.Config.Mongo.DBRetainChatRecords)
|
||||||
}
|
}
|
||||||
if err := c.fixAndCheckSeq(ctx, conversationID); err != nil {
|
if err := c.checkMaxSeq(ctx, conversationID); err != nil {
|
||||||
log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID)
|
log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,20 +95,11 @@ func (c *MsgTool) checkMaxSeqWithMongo(ctx context.Context, conversationID strin
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MsgTool) fixAndCheckSeq(ctx context.Context, conversationID string) error {
|
func (c *MsgTool) checkMaxSeq(ctx context.Context, conversationID string) error {
|
||||||
maxSeq, err := c.msgDatabase.GetMaxSeq(ctx, conversationID)
|
maxSeq, err := c.msgDatabase.GetMaxSeq(ctx, conversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
minSeq, err := c.msgDatabase.GetMinSeq(ctx, conversationID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if minSeq > maxSeq {
|
|
||||||
if err = c.msgDatabase.SetMinSeq(ctx, conversationID, maxSeq); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := c.checkMaxSeqWithMongo(ctx, conversationID, maxSeq); err != nil {
|
if err := c.checkMaxSeqWithMongo(ctx, conversationID, maxSeq); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -125,8 +116,8 @@ func (c *MsgTool) FixAllSeq(ctx context.Context) error {
|
|||||||
conversationIDs = append(conversationIDs, utils.GetNotificationConversationIDByConversationID(conversationID))
|
conversationIDs = append(conversationIDs, utils.GetNotificationConversationIDByConversationID(conversationID))
|
||||||
}
|
}
|
||||||
for _, conversationID := range conversationIDs {
|
for _, conversationID := range conversationIDs {
|
||||||
if err := c.fixAndCheckSeq(ctx, conversationID); err != nil {
|
if err := c.checkMaxSeq(ctx, conversationID); err != nil {
|
||||||
log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID)
|
log.ZWarn(ctx, "fixSeq failed", err, "conversationID", conversationID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("fix all seq finished")
|
fmt.Println("fix all seq finished")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user