From 3e547958b02acfeb790c279d4ecc9b0e718771c8 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Thu, 1 Aug 2024 14:54:40 +0800 Subject: [PATCH] update func name and comments. --- internal/rpc/msg/clear.go | 3 +-- internal/tools/cron_task.go | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/rpc/msg/clear.go b/internal/rpc/msg/clear.go index 151dab861..fd121318b 100644 --- a/internal/rpc/msg/clear.go +++ b/internal/rpc/msg/clear.go @@ -127,6 +127,7 @@ func (m *msgServer) DestructMsgs(ctx context.Context, req *msg.DestructMsgsReq) continue } + // if you need Notify SDK client userseq is update. // m.msgNotificationSender.UserDeleteMsgsNotification(handleCtx, conversation.OwnerUserID, conversation.ConversationID, seqs) } } @@ -137,5 +138,3 @@ func (m *msgServer) DestructMsgs(ctx context.Context, req *msg.DestructMsgsReq) return nil, nil } - - diff --git a/internal/tools/cron_task.go b/internal/tools/cron_task.go index 3a9ce6da9..b1d59800c 100644 --- a/internal/tools/cron_task.go +++ b/internal/tools/cron_task.go @@ -75,7 +75,8 @@ func Start(ctx context.Context, config *CronTaskConfig) error { crontab := cron.New() - clearFunc := func() { + // scheduled hard delete outdated Msgs in specific time. + clearMsgFunc := func() { now := time.Now() deltime := now.Add(-time.Hour * 24 * time.Duration(config.CronTask.RetainChatRecords)) ctx := mcontext.SetOperationID(ctx, fmt.Sprintf("cron_%d_%d", os.Getpid(), deltime.UnixMilli())) @@ -86,10 +87,11 @@ func Start(ctx context.Context, config *CronTaskConfig) error { } log.ZInfo(ctx, "cron clear chat records success", "deltime", deltime, "cont", time.Since(now)) } - if _, err := crontab.AddFunc(config.CronTask.CronExecuteTime, clearFunc); err != nil { + if _, err := crontab.AddFunc(config.CronTask.CronExecuteTime, clearMsgFunc); err != nil { return errs.Wrap(err) } + // scheduled soft delete outdated Msgs in specific time when user set `is_msg_destruct` feature. msgDestructFunc := func() { now := time.Now() ctx := mcontext.SetOperationID(ctx, fmt.Sprintf("cron_%d_%d", os.Getpid(), now.UnixMilli())) @@ -112,7 +114,8 @@ func Start(ctx context.Context, config *CronTaskConfig) error { return errs.Wrap(err) } - deleteFunc := func() { + // scheduled delete outdated file Objects and their datas in specific time. + deleteObjectFunc := func() { now := time.Now() deleteTime := now.Add(-time.Hour * 24 * time.Duration(config.CronTask.FileExpireTime)) ctx := mcontext.SetOperationID(ctx, fmt.Sprintf("cron_%d_%d", os.Getpid(), deleteTime.UnixMilli())) @@ -123,7 +126,7 @@ func Start(ctx context.Context, config *CronTaskConfig) error { } log.ZInfo(ctx, "cron deleteoutDatedData success", "deltime", deleteTime, "cont", time.Since(now)) } - if _, err := crontab.AddFunc(config.CronTask.CronExecuteTime, deleteFunc); err != nil { + if _, err := crontab.AddFunc(config.CronTask.CronExecuteTime, deleteObjectFunc); err != nil { return errs.Wrap(err) }