mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-26 21:22:16 +08:00 
			
		
		
		
	* pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * upgrading pkg tools * fix * fix * optimize log output * feat: support GetLastMessage * feat: support GetLastMessage * feat: s3 switch * feat: s3 switch * fix: GetUsersOnline * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: seq conversion failed without exiting * monolithic * fix: DeleteDoc crash * fix: DeleteDoc crash * fix: monolithic * fix: monolithic * fix: fill send time * fix: fill send time * fix: crash caused by withdrawing messages from users who have left the group * fix: mq * fix: mq * fix: user msg timestamp * fix: mq * 1 * 1 * 1 * 1 * 1 * 1 * 1 * seq read config * seq read config * 1 * 1 * fix: the source message of the reference is withdrawn, and the referenced message is deleted * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1
		
			
				
	
	
		
			36 lines
		
	
	
		
			948 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			948 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package cron
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"os"
 | |
| 	"time"
 | |
| 
 | |
| 	pbconversation "github.com/openimsdk/protocol/conversation"
 | |
| 	"github.com/openimsdk/tools/log"
 | |
| 	"github.com/openimsdk/tools/mcontext"
 | |
| )
 | |
| 
 | |
| func (c *cronServer) clearUserMsg() {
 | |
| 	now := time.Now()
 | |
| 	operationID := fmt.Sprintf("cron_user_msg_%d_%d", os.Getpid(), now.UnixMilli())
 | |
| 	ctx := mcontext.SetOperationID(c.ctx, operationID)
 | |
| 	log.ZDebug(ctx, "clear user msg cron start")
 | |
| 	const (
 | |
| 		deleteCount = 10000
 | |
| 		deleteLimit = 100
 | |
| 	)
 | |
| 	var count int
 | |
| 	for i := 1; i <= deleteCount; i++ {
 | |
| 		resp, err := c.conversationClient.ClearUserConversationMsg(ctx, &pbconversation.ClearUserConversationMsgReq{Timestamp: now.UnixMilli(), Limit: deleteLimit})
 | |
| 		if err != nil {
 | |
| 			log.ZError(ctx, "ClearUserConversationMsg failed.", err)
 | |
| 			return
 | |
| 		}
 | |
| 		count += int(resp.Count)
 | |
| 		if resp.Count < deleteLimit {
 | |
| 			break
 | |
| 		}
 | |
| 	}
 | |
| 	log.ZDebug(ctx, "clear user msg cron task completed", "cont", time.Since(now), "count", count)
 | |
| }
 |