mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 11:06:43 +08:00
Merge remote-tracking branch 'origin/v3dev' into v3dev
This commit is contained in:
commit
b494c73328
@ -114,7 +114,6 @@ func (c *conversationServer) SetRecvMsgOpt(ctx context.Context, req *pbConversat
|
|||||||
return &pbConversation.SetRecvMsgOptResp{}, nil
|
return &pbConversation.SetRecvMsgOptResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated
|
|
||||||
func (c *conversationServer) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) {
|
func (c *conversationServer) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) {
|
||||||
resp := &pbConversation.ModifyConversationFieldResp{}
|
resp := &pbConversation.ModifyConversationFieldResp{}
|
||||||
var err error
|
var err error
|
||||||
@ -199,15 +198,15 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
|
|||||||
var conversations []*tableRelation.ConversationModel
|
var conversations []*tableRelation.ConversationModel
|
||||||
for _, ownerUserID := range req.UserIDs {
|
for _, ownerUserID := range req.UserIDs {
|
||||||
conversation2 := conversation
|
conversation2 := conversation
|
||||||
conversation.OwnerUserID = ownerUserID
|
conversation2.OwnerUserID = ownerUserID
|
||||||
conversation.IsPrivateChat = req.Conversation.IsPrivateChat.Value
|
conversation2.IsPrivateChat = req.Conversation.IsPrivateChat.Value
|
||||||
conversations = append(conversations, &conversation2)
|
conversations = append(conversations, &conversation2)
|
||||||
}
|
}
|
||||||
if err := c.conversationDatabase.SyncPeerUserPrivateConversationTx(ctx, conversations); err != nil {
|
if err := c.conversationDatabase.SyncPeerUserPrivateConversationTx(ctx, conversations); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, ownerUserID := range req.UserIDs {
|
for _, userID := range req.UserIDs {
|
||||||
c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, ownerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat.Value)
|
c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, userID, req.Conversation.UserID, req.Conversation.IsPrivateChat.Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Conversation.BurnDuration != nil {
|
if req.Conversation.BurnDuration != nil {
|
||||||
|
@ -2,6 +2,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
@ -73,12 +74,14 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context,
|
|||||||
NotUserIDs := utils.DifferenceString(haveUserIDs, userIDs)
|
NotUserIDs := utils.DifferenceString(haveUserIDs, userIDs)
|
||||||
log.ZDebug(ctx, "SetUsersConversationFiledTx", "NotUserIDs", NotUserIDs, "haveUserIDs", haveUserIDs, "userIDs", userIDs)
|
log.ZDebug(ctx, "SetUsersConversationFiledTx", "NotUserIDs", NotUserIDs, "haveUserIDs", haveUserIDs, "userIDs", userIDs)
|
||||||
var conversations []*relationTb.ConversationModel
|
var conversations []*relationTb.ConversationModel
|
||||||
|
now := time.Now()
|
||||||
for _, v := range NotUserIDs {
|
for _, v := range NotUserIDs {
|
||||||
temp := new(relationTb.ConversationModel)
|
temp := new(relationTb.ConversationModel)
|
||||||
if err := utils.CopyStructFields(temp, conversation); err != nil {
|
if err := utils.CopyStructFields(temp, conversation); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
temp.OwnerUserID = v
|
temp.OwnerUserID = v
|
||||||
|
temp.CreateTime = now
|
||||||
conversations = append(conversations, temp)
|
conversations = append(conversations, temp)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -123,26 +126,28 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Con
|
|||||||
conversationTx := c.conversationDB.NewTx(tx)
|
conversationTx := c.conversationDB.NewTx(tx)
|
||||||
for _, conversation := range conversations {
|
for _, conversation := range conversations {
|
||||||
for _, v := range [][2]string{{conversation.OwnerUserID, conversation.UserID}, {conversation.UserID, conversation.OwnerUserID}} {
|
for _, v := range [][2]string{{conversation.OwnerUserID, conversation.UserID}, {conversation.UserID, conversation.OwnerUserID}} {
|
||||||
haveUserIDs, err := conversationTx.FindUserID(ctx, []string{v[0]}, []string{conversation.ConversationID})
|
ownerUserID := v[0]
|
||||||
|
userID := v[1]
|
||||||
|
haveUserIDs, err := conversationTx.FindUserID(ctx, []string{ownerUserID}, []string{conversation.ConversationID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(haveUserIDs) > 0 {
|
if len(haveUserIDs) > 0 {
|
||||||
_, err := conversationTx.UpdateByMap(ctx, []string{v[0]}, conversation.ConversationID, map[string]interface{}{"is_private_chat": conversation.IsPrivateChat})
|
_, err := conversationTx.UpdateByMap(ctx, []string{ownerUserID}, conversation.ConversationID, map[string]interface{}{"is_private_chat": conversation.IsPrivateChat})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cache = cache.DelUsersConversation(conversation.ConversationID, v[0])
|
cache = cache.DelUsersConversation(conversation.ConversationID, ownerUserID)
|
||||||
} else {
|
} else {
|
||||||
newConversation := *conversation
|
newConversation := *conversation
|
||||||
newConversation.OwnerUserID = v[0]
|
newConversation.OwnerUserID = ownerUserID
|
||||||
newConversation.UserID = v[1]
|
newConversation.UserID = userID
|
||||||
newConversation.ConversationID = conversation.ConversationID
|
newConversation.ConversationID = conversation.ConversationID
|
||||||
newConversation.IsPrivateChat = conversation.IsPrivateChat
|
newConversation.IsPrivateChat = conversation.IsPrivateChat
|
||||||
if err := conversationTx.Create(ctx, []*relationTb.ConversationModel{&newConversation}); err != nil {
|
if err := conversationTx.Create(ctx, []*relationTb.ConversationModel{&newConversation}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cache = cache.DelConversationIDs(v[0]).DelUserConversationIDsHash(v[0])
|
cache = cache.DelConversationIDs(ownerUserID).DelUserConversationIDsHash(ownerUserID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package relation
|
package relation
|
||||||
|
|
||||||
import "context"
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
conversationModelTableName = "conversations"
|
conversationModelTableName = "conversations"
|
||||||
@ -21,6 +24,7 @@ type ConversationModel struct {
|
|||||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||||
MaxSeq int64 `gorm:"column:max_seq" json:"maxSeq"`
|
MaxSeq int64 `gorm:"column:max_seq" json:"maxSeq"`
|
||||||
MinSeq int64 `gorm:"column:min_seq" json:"minSeq"`
|
MinSeq int64 `gorm:"column:min_seq" json:"minSeq"`
|
||||||
|
CreateTime time.Time `gorm:"column:create_time;index:create_time;autoCreateTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ConversationModel) TableName() string {
|
func (ConversationModel) TableName() string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user