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
		
			
				
	
	
		
			81 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package cron
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"os"
 | |
| 	"time"
 | |
| 
 | |
| 	"github.com/openimsdk/protocol/third"
 | |
| 	"github.com/openimsdk/tools/log"
 | |
| 	"github.com/openimsdk/tools/mcontext"
 | |
| )
 | |
| 
 | |
| func (c *cronServer) clearS3() {
 | |
| 	start := time.Now()
 | |
| 	deleteTime := start.Add(-time.Hour * 24 * time.Duration(c.config.CronTask.FileExpireTime))
 | |
| 	operationID := fmt.Sprintf("cron_s3_%d_%d", os.Getpid(), deleteTime.UnixMilli())
 | |
| 	ctx := mcontext.SetOperationID(c.ctx, operationID)
 | |
| 	log.ZDebug(ctx, "deleteoutDatedData", "deletetime", deleteTime, "timestamp", deleteTime.UnixMilli())
 | |
| 	const (
 | |
| 		deleteCount = 10000
 | |
| 		deleteLimit = 100
 | |
| 	)
 | |
| 
 | |
| 	var count int
 | |
| 	for i := 1; i <= deleteCount; i++ {
 | |
| 		resp, err := c.thirdClient.DeleteOutdatedData(ctx, &third.DeleteOutdatedDataReq{ExpireTime: deleteTime.UnixMilli(), ObjectGroup: c.config.CronTask.DeleteObjectType, Limit: deleteLimit})
 | |
| 		if err != nil {
 | |
| 			log.ZError(ctx, "cron deleteoutDatedData failed", err)
 | |
| 			return
 | |
| 		}
 | |
| 		count += int(resp.Count)
 | |
| 		if resp.Count < deleteLimit {
 | |
| 			break
 | |
| 		}
 | |
| 	}
 | |
| 	log.ZDebug(ctx, "cron deleteoutDatedData success", "deltime", deleteTime, "cont", time.Since(start), "count", count)
 | |
| }
 | |
| 
 | |
| //	var req *third.DeleteOutdatedDataReq
 | |
| //	count1, err := ExtractField(ctx, c.thirdClient.DeleteOutdatedData, req, (*third.DeleteOutdatedDataResp).GetCount)
 | |
| //
 | |
| //	c.thirdClient.DeleteOutdatedData(ctx, &third.DeleteOutdatedDataReq{})
 | |
| //	msggateway.GetUsersOnlineStatusCaller.Invoke(ctx, &msggateway.GetUsersOnlineStatusReq{})
 | |
| //
 | |
| //	var cli ThirdClient
 | |
| //
 | |
| //	c111, err := cli.DeleteOutdatedData(ctx, 100)
 | |
| //
 | |
| //	cli.ThirdClient.DeleteOutdatedData(ctx, &third.DeleteOutdatedDataReq{})
 | |
| //
 | |
| //	cli.AuthSign(ctx, &third.AuthSignReq{})
 | |
| //
 | |
| //	cli.SetAppBadge()
 | |
| //
 | |
| //}
 | |
| //
 | |
| //func extractField[A, B, C any](ctx context.Context, fn func(ctx context.Context, req *A, opts ...grpc.CallOption) (*B, error), req *A, get func(*B) C) (C, error) {
 | |
| //	resp, err := fn(ctx, req)
 | |
| //	if err != nil {
 | |
| //		var c C
 | |
| //		return c, err
 | |
| //	}
 | |
| //	return get(resp), nil
 | |
| //}
 | |
| //
 | |
| //func ignore(_ any, err error) error {
 | |
| //	return err
 | |
| //}
 | |
| //
 | |
| //type ThirdClient struct {
 | |
| //	third.ThirdClient
 | |
| //}
 | |
| //
 | |
| //func (c *ThirdClient) DeleteOutdatedData(ctx context.Context, expireTime int64) (int32, error) {
 | |
| //	return extractField(ctx, c.ThirdClient.DeleteOutdatedData, &third.DeleteOutdatedDataReq{ExpireTime: expireTime}, (*third.DeleteOutdatedDataResp).GetCount)
 | |
| //}
 | |
| //
 | |
| //func (c *ThirdClient) DeleteOutdatedData1(ctx context.Context, expireTime int64) error {
 | |
| //	return ignore(c.ThirdClient.DeleteOutdatedData(ctx, &third.DeleteOutdatedDataReq{ExpireTime: expireTime}))
 | |
| //}
 |