mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-10 21:19:52 +08:00
fix: solve createTime
not set in setConversation and Create Conversation. (#3447)
This commit is contained in:
parent
bd56bd23b8
commit
5e813ef079
@ -31,7 +31,6 @@ import (
|
|||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
|
||||||
dbModel "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
dbModel "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/webhook"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/webhook"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
||||||
@ -244,11 +243,14 @@ func (c *conversationServer) getConversations(ctx context.Context, ownerUserID s
|
|||||||
return convert.ConversationsDB2Pb(conversations), nil
|
return convert.ConversationsDB2Pb(conversations), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
func (c *conversationServer) SetConversation(ctx context.Context, req *pbconversation.SetConversationReq) (*pbconversation.SetConversationResp, error) {
|
func (c *conversationServer) SetConversation(ctx context.Context, req *pbconversation.SetConversationReq) (*pbconversation.SetConversationResp, error) {
|
||||||
if err := authverify.CheckAccess(ctx, req.GetConversation().GetUserID()); err != nil {
|
if err := authverify.CheckAccess(ctx, req.GetConversation().GetUserID()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var conversation dbModel.Conversation
|
var conversation dbModel.Conversation
|
||||||
|
conversation.CreateTime = time.Now()
|
||||||
|
|
||||||
if err := datautil.CopyStructFields(&conversation, req.Conversation); err != nil {
|
if err := datautil.CopyStructFields(&conversation, req.Conversation); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -300,6 +302,7 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
conversation.ConversationType = req.Conversation.ConversationType
|
conversation.ConversationType = req.Conversation.ConversationType
|
||||||
conversation.UserID = req.Conversation.UserID
|
conversation.UserID = req.Conversation.UserID
|
||||||
conversation.GroupID = req.Conversation.GroupID
|
conversation.GroupID = req.Conversation.GroupID
|
||||||
|
conversation.CreateTime = time.Now()
|
||||||
|
|
||||||
m, conversation, err := UpdateConversationsMap(ctx, req)
|
m, conversation, err := UpdateConversationsMap(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -365,6 +368,8 @@ func (c *conversationServer) UpdateConversationsByUser(ctx context.Context, req
|
|||||||
// create conversation without notification for msg redis transfer.
|
// create conversation without notification for msg redis transfer.
|
||||||
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbconversation.CreateSingleChatConversationsReq) (*pbconversation.CreateSingleChatConversationsResp, error) {
|
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbconversation.CreateSingleChatConversationsReq) (*pbconversation.CreateSingleChatConversationsResp, error) {
|
||||||
var conversation dbModel.Conversation
|
var conversation dbModel.Conversation
|
||||||
|
conversation.CreateTime = time.Now()
|
||||||
|
|
||||||
switch req.ConversationType {
|
switch req.ConversationType {
|
||||||
case constant.SingleChatType:
|
case constant.SingleChatType:
|
||||||
// sendUser create
|
// sendUser create
|
||||||
@ -372,6 +377,7 @@ func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
|
|||||||
conversation.ConversationType = req.ConversationType
|
conversation.ConversationType = req.ConversationType
|
||||||
conversation.OwnerUserID = req.SendID
|
conversation.OwnerUserID = req.SendID
|
||||||
conversation.UserID = req.RecvID
|
conversation.UserID = req.RecvID
|
||||||
|
|
||||||
if err := c.webhookBeforeCreateSingleChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateSingleChatConversations, &conversation); err != nil && err != servererrs.ErrCallbackContinue {
|
if err := c.webhookBeforeCreateSingleChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateSingleChatConversations, &conversation); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -387,6 +393,7 @@ func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
|
|||||||
conversation2 := conversation
|
conversation2 := conversation
|
||||||
conversation2.OwnerUserID = req.RecvID
|
conversation2.OwnerUserID = req.RecvID
|
||||||
conversation2.UserID = req.SendID
|
conversation2.UserID = req.SendID
|
||||||
|
|
||||||
if err := c.webhookBeforeCreateSingleChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateSingleChatConversations, &conversation); err != nil && err != servererrs.ErrCallbackContinue {
|
if err := c.webhookBeforeCreateSingleChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateSingleChatConversations, &conversation); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -402,6 +409,7 @@ func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
|
|||||||
conversation.ConversationType = req.ConversationType
|
conversation.ConversationType = req.ConversationType
|
||||||
conversation.OwnerUserID = req.RecvID
|
conversation.OwnerUserID = req.RecvID
|
||||||
conversation.UserID = req.SendID
|
conversation.UserID = req.SendID
|
||||||
|
|
||||||
if err := c.webhookBeforeCreateSingleChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateSingleChatConversations, &conversation); err != nil && err != servererrs.ErrCallbackContinue {
|
if err := c.webhookBeforeCreateSingleChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateSingleChatConversations, &conversation); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -423,6 +431,7 @@ func (c *conversationServer) CreateGroupChatConversations(ctx context.Context, r
|
|||||||
conversation.ConversationID = msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, req.GroupID)
|
conversation.ConversationID = msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, req.GroupID)
|
||||||
conversation.GroupID = req.GroupID
|
conversation.GroupID = req.GroupID
|
||||||
conversation.ConversationType = constant.ReadGroupChatType
|
conversation.ConversationType = constant.ReadGroupChatType
|
||||||
|
conversation.CreateTime = time.Now()
|
||||||
|
|
||||||
if err := c.webhookBeforeCreateGroupChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateGroupChatConversations, &conversation); err != nil {
|
if err := c.webhookBeforeCreateGroupChatConversations(ctx, &c.config.WebhooksConfig.BeforeCreateGroupChatConversations, &conversation); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -708,7 +717,7 @@ func (c *conversationServer) GetConversationsNeedClearMsg(ctx context.Context, _
|
|||||||
|
|
||||||
maxPage := (num + batchNum - 1) / batchNum
|
maxPage := (num + batchNum - 1) / batchNum
|
||||||
|
|
||||||
temp := make([]*model.Conversation, 0, maxPage*batchNum)
|
temp := make([]*dbModel.Conversation, 0, maxPage*batchNum)
|
||||||
|
|
||||||
for pageNumber := 0; pageNumber < int(maxPage); pageNumber++ {
|
for pageNumber := 0; pageNumber < int(maxPage); pageNumber++ {
|
||||||
pagination := &sdkws.RequestPagination{
|
pagination := &sdkws.RequestPagination{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user