mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 01:55:58 +08:00
feat: add a function for business info change to update related conve… (#3225)
* feat: add a function for business info change to update related conversation's ex info. * feat: add a function for business info change to update related conversation's ex info. * feat: add a function for business info change to update related conversation's ex info. * feat: add a function for business info change to update related conversation's ex info.
This commit is contained in:
@@ -46,6 +46,9 @@ type ConversationDatabase interface {
|
||||
// SetUsersConversationFieldTx updates a specific field for multiple users' conversations, creating new conversations if they do not exist, or updates them otherwise. This operation is
|
||||
// transactional.
|
||||
SetUsersConversationFieldTx(ctx context.Context, userIDs []string, conversation *relationtb.Conversation, fieldMap map[string]any) error
|
||||
// UpdateUserConversations updates all conversations related to a specified user.
|
||||
// This function does NOT update the user's own conversations but rather the conversations where this user is involved (e.g., other users' conversations referencing this user).
|
||||
UpdateUserConversations(ctx context.Context, userID string, args map[string]any) error
|
||||
// CreateGroupChatConversation creates a group chat conversation for the specified group ID and user IDs.
|
||||
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string, conversations *relationtb.Conversation) error
|
||||
// GetConversationIDs retrieves conversation IDs for a given user.
|
||||
@@ -145,6 +148,18 @@ func (c *conversationDatabase) SetUsersConversationFieldTx(ctx context.Context,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) UpdateUserConversations(ctx context.Context, userID string, args map[string]any) error {
|
||||
conversations, err := c.conversationDB.UpdateUserConversations(ctx, userID, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cache := c.cache.CloneConversationCache()
|
||||
for _, conversation := range conversations {
|
||||
cache = cache.DelUsersConversation(conversation.ConversationID, conversation.OwnerUserID).DelConversationVersionUserIDs(conversation.OwnerUserID)
|
||||
}
|
||||
return cache.ChainExecDel(ctx)
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) UpdateUsersConversationField(ctx context.Context, userIDs []string, conversationID string, args map[string]any) error {
|
||||
_, err := c.conversationDB.UpdateByMap(ctx, userIDs, conversationID, args)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type StreamMsgDatabase interface {
|
||||
CreateStreamMsg(ctx context.Context, model *model.StreamMsg) error
|
||||
AppendStreamMsg(ctx context.Context, clientMsgID string, startIndex int, packets []string, end bool, deadlineTime time.Time) error
|
||||
GetStreamMsg(ctx context.Context, clientMsgID string) (*model.StreamMsg, error)
|
||||
}
|
||||
|
||||
func NewStreamMsgDatabase(db database.StreamMsg) StreamMsgDatabase {
|
||||
return &streamMsgDatabase{db: db}
|
||||
}
|
||||
|
||||
type streamMsgDatabase struct {
|
||||
db database.StreamMsg
|
||||
}
|
||||
|
||||
func (m *streamMsgDatabase) CreateStreamMsg(ctx context.Context, model *model.StreamMsg) error {
|
||||
return m.db.CreateStreamMsg(ctx, model)
|
||||
}
|
||||
|
||||
func (m *streamMsgDatabase) AppendStreamMsg(ctx context.Context, clientMsgID string, startIndex int, packets []string, end bool, deadlineTime time.Time) error {
|
||||
return m.db.AppendStreamMsg(ctx, clientMsgID, startIndex, packets, end, deadlineTime)
|
||||
}
|
||||
|
||||
func (m *streamMsgDatabase) GetStreamMsg(ctx context.Context, clientMsgID string) (*model.StreamMsg, error) {
|
||||
return m.db.GetStreamMsg(ctx, clientMsgID)
|
||||
}
|
||||
Reference in New Issue
Block a user