mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-28 22:58:10 +08:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
6a3c894bbd
@ -293,49 +293,48 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
unequal := len(m)
|
unequal := len(m)
|
||||||
|
|
||||||
if req.Conversation.RecvMsgOpt != nil {
|
if req.Conversation.RecvMsgOpt != nil {
|
||||||
if req.Conversation.RecvMsgOpt.Value != conversationMap[userID].RecvMsgOpt {
|
if req.Conversation.RecvMsgOpt.Value == conversationMap[userID].RecvMsgOpt {
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Conversation.AttachedInfo != nil {
|
if req.Conversation.AttachedInfo != nil {
|
||||||
if req.Conversation.AttachedInfo.Value != conversationMap[userID].AttachedInfo {
|
if req.Conversation.AttachedInfo.Value == conversationMap[userID].AttachedInfo {
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Conversation.Ex != nil {
|
if req.Conversation.Ex != nil {
|
||||||
if req.Conversation.Ex.Value != conversationMap[userID].Ex {
|
if req.Conversation.Ex.Value == conversationMap[userID].Ex {
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Conversation.IsPinned != nil {
|
if req.Conversation.IsPinned != nil {
|
||||||
m["is_pinned"] = req.Conversation.IsPinned.Value
|
if req.Conversation.IsPinned.Value == conversationMap[userID].IsPinned {
|
||||||
if req.Conversation.IsPinned.Value != conversationMap[userID].IsPinned {
|
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Conversation.GroupAtType != nil {
|
if req.Conversation.GroupAtType != nil {
|
||||||
if req.Conversation.GroupAtType.Value != conversationMap[userID].GroupAtType {
|
if req.Conversation.GroupAtType.Value == conversationMap[userID].GroupAtType {
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Conversation.MsgDestructTime != nil {
|
if req.Conversation.MsgDestructTime != nil {
|
||||||
if req.Conversation.MsgDestructTime.Value != conversationMap[userID].MsgDestructTime {
|
if req.Conversation.MsgDestructTime.Value == conversationMap[userID].MsgDestructTime {
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Conversation.IsMsgDestruct != nil {
|
if req.Conversation.IsMsgDestruct != nil {
|
||||||
if req.Conversation.IsMsgDestruct.Value != conversationMap[userID].IsMsgDestruct {
|
if req.Conversation.IsMsgDestruct.Value == conversationMap[userID].IsMsgDestruct {
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Conversation.BurnDuration != nil {
|
if req.Conversation.BurnDuration != nil {
|
||||||
if req.Conversation.BurnDuration.Value != conversationMap[userID].BurnDuration {
|
if req.Conversation.BurnDuration.Value == conversationMap[userID].BurnDuration {
|
||||||
unequal--
|
unequal--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +362,7 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
req.Conversation.IsPrivateChat.Value, req.Conversation.ConversationID)
|
req.Conversation.IsPrivateChat.Value, req.Conversation.ConversationID)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(m) != 0 {
|
if len(m) != 0 && len(needUpdateUsersList) != 0 {
|
||||||
if err := c.conversationDatabase.SetUsersConversationFieldTx(ctx, needUpdateUsersList, &conversation, m); err != nil {
|
if err := c.conversationDatabase.SetUsersConversationFieldTx(ctx, needUpdateUsersList, &conversation, m); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,6 @@ import (
|
|||||||
pbconversation "github.com/openimsdk/protocol/conversation"
|
pbconversation "github.com/openimsdk/protocol/conversation"
|
||||||
"github.com/openimsdk/protocol/msg"
|
"github.com/openimsdk/protocol/msg"
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/third"
|
|
||||||
"github.com/openimsdk/tools/mcontext"
|
"github.com/openimsdk/tools/mcontext"
|
||||||
"github.com/openimsdk/tools/mw"
|
"github.com/openimsdk/tools/mw"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -59,10 +58,10 @@ func Start(ctx context.Context, config *CronTaskConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
thirdConn, err := client.GetConn(ctx, config.Share.RpcRegisterName.Third)
|
// thirdConn, err := client.GetConn(ctx, config.Share.RpcRegisterName.Third)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
conversationConn, err := client.GetConn(ctx, config.Share.RpcRegisterName.Conversation)
|
conversationConn, err := client.GetConn(ctx, config.Share.RpcRegisterName.Conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -71,7 +70,7 @@ func Start(ctx context.Context, config *CronTaskConfig) error {
|
|||||||
|
|
||||||
msgClient := msg.NewMsgClient(msgConn)
|
msgClient := msg.NewMsgClient(msgConn)
|
||||||
conversationClient := pbconversation.NewConversationClient(conversationConn)
|
conversationClient := pbconversation.NewConversationClient(conversationConn)
|
||||||
thirdClient := third.NewThirdClient(thirdConn)
|
// thirdClient := third.NewThirdClient(thirdConn)
|
||||||
|
|
||||||
crontab := cron.New()
|
crontab := cron.New()
|
||||||
|
|
||||||
@ -115,21 +114,21 @@ func Start(ctx context.Context, config *CronTaskConfig) error {
|
|||||||
return errs.Wrap(err)
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// scheduled delete outdated file Objects and their datas in specific time.
|
// // scheduled delete outdated file Objects and their datas in specific time.
|
||||||
deleteObjectFunc := func() {
|
// deleteObjectFunc := func() {
|
||||||
now := time.Now()
|
// now := time.Now()
|
||||||
deleteTime := now.Add(-time.Hour * 24 * time.Duration(config.CronTask.FileExpireTime))
|
// deleteTime := now.Add(-time.Hour * 24 * time.Duration(config.CronTask.FileExpireTime))
|
||||||
ctx := mcontext.SetOperationID(ctx, fmt.Sprintf("cron_%d_%d", os.Getpid(), deleteTime.UnixMilli()))
|
// ctx := mcontext.SetOperationID(ctx, fmt.Sprintf("cron_%d_%d", os.Getpid(), deleteTime.UnixMilli()))
|
||||||
log.ZInfo(ctx, "deleteoutDatedData ", "deletetime", deleteTime, "timestamp", deleteTime.UnixMilli())
|
// log.ZInfo(ctx, "deleteoutDatedData ", "deletetime", deleteTime, "timestamp", deleteTime.UnixMilli())
|
||||||
if _, err := thirdClient.DeleteOutdatedData(ctx, &third.DeleteOutdatedDataReq{ExpireTime: deleteTime.UnixMilli()}); err != nil {
|
// if _, err := thirdClient.DeleteOutdatedData(ctx, &third.DeleteOutdatedDataReq{ExpireTime: deleteTime.UnixMilli()}); err != nil {
|
||||||
log.ZError(ctx, "cron deleteoutDatedData failed", err, "deleteTime", deleteTime, "cont", time.Since(now))
|
// log.ZError(ctx, "cron deleteoutDatedData failed", err, "deleteTime", deleteTime, "cont", time.Since(now))
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
log.ZInfo(ctx, "cron deleteoutDatedData success", "deltime", deleteTime, "cont", time.Since(now))
|
// log.ZInfo(ctx, "cron deleteoutDatedData success", "deltime", deleteTime, "cont", time.Since(now))
|
||||||
}
|
// }
|
||||||
if _, err := crontab.AddFunc(config.CronTask.CronExecuteTime, deleteObjectFunc); err != nil {
|
// if _, err := crontab.AddFunc(config.CronTask.CronExecuteTime, deleteObjectFunc); err != nil {
|
||||||
return errs.Wrap(err)
|
// return errs.Wrap(err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
log.ZInfo(ctx, "start cron task", "CronExecuteTime", config.CronTask.CronExecuteTime)
|
log.ZInfo(ctx, "start cron task", "CronExecuteTime", config.CronTask.CronExecuteTime)
|
||||||
crontab.Start()
|
crontab.Start()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user