mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-21 20:32:32 +08:00
feat: Implement webhook in createConversation (#3228)
* update test method args. * feat: implement createConversations webhook function. * improve webhookCreateConversations Implement * implement createconversation webhook. * remove unused paramaters. (cherry picked from commit b969827b9af9120b28f267b7f600e3b97c928e59)
This commit is contained in:
parent
505ce8aad1
commit
1ef55cda05
@ -7,11 +7,11 @@ beforeSendSingleMsg:
|
|||||||
# If not set, all contentType messages will through this filter.
|
# If not set, all contentType messages will through this filter.
|
||||||
deniedTypes: []
|
deniedTypes: []
|
||||||
beforeUpdateUserInfoEx:
|
beforeUpdateUserInfoEx:
|
||||||
enable: false
|
enable: false
|
||||||
timeout: 5
|
timeout: 5
|
||||||
failedContinue: true
|
failedContinue: true
|
||||||
afterUpdateUserInfoEx:
|
afterUpdateUserInfoEx:
|
||||||
enable: false
|
enable: false
|
||||||
timeout: 5
|
timeout: 5
|
||||||
afterSendSingleMsg:
|
afterSendSingleMsg:
|
||||||
enable: false
|
enable: false
|
||||||
@ -181,3 +181,19 @@ afterImportFriends:
|
|||||||
afterRemoveBlack:
|
afterRemoveBlack:
|
||||||
enable: false
|
enable: false
|
||||||
timeout: 5
|
timeout: 5
|
||||||
|
beforeCreateSingleChatConversations:
|
||||||
|
enable: false
|
||||||
|
timeout: 5
|
||||||
|
failedContinue: false
|
||||||
|
afterCreateSingleChatConversations:
|
||||||
|
enable: false
|
||||||
|
timeout: 5
|
||||||
|
failedContinue: false
|
||||||
|
beforeCreateGroupChatConversations:
|
||||||
|
enable: false
|
||||||
|
timeout: 5
|
||||||
|
failedContinue: false
|
||||||
|
afterCreateGroupChatConversations:
|
||||||
|
enable: false
|
||||||
|
timeout: 5
|
||||||
|
failedContinue: false
|
||||||
|
@ -19,12 +19,9 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
|
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||||
@ -43,6 +40,7 @@ import (
|
|||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type conversationServer struct {
|
type conversationServer struct {
|
||||||
|
@ -46,7 +46,7 @@ func TestName(t *testing.T) {
|
|||||||
|
|
||||||
srv := &cronServer{
|
srv := &cronServer{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
config: &CronTaskConfig{
|
config: &Config{
|
||||||
CronTask: config.CronTask{
|
CronTask: config.CronTask{
|
||||||
RetainChatRecords: 1,
|
RetainChatRecords: 1,
|
||||||
FileExpireTime: 1,
|
FileExpireTime: 1,
|
||||||
|
@ -15,51 +15,55 @@
|
|||||||
package callbackstruct
|
package callbackstruct
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CallbackBeforeInviteJoinGroupCommand = "callbackBeforeInviteJoinGroupCommand"
|
CallbackBeforeInviteJoinGroupCommand = "callbackBeforeInviteJoinGroupCommand"
|
||||||
CallbackAfterJoinGroupCommand = "callbackAfterJoinGroupCommand"
|
CallbackAfterJoinGroupCommand = "callbackAfterJoinGroupCommand"
|
||||||
CallbackAfterSetGroupInfoCommand = "callbackAfterSetGroupInfoCommand"
|
CallbackAfterSetGroupInfoCommand = "callbackAfterSetGroupInfoCommand"
|
||||||
CallbackAfterSetGroupInfoExCommand = "callbackAfterSetGroupInfoExCommand"
|
CallbackAfterSetGroupInfoExCommand = "callbackAfterSetGroupInfoExCommand"
|
||||||
CallbackBeforeSetGroupInfoCommand = "callbackBeforeSetGroupInfoCommand"
|
CallbackBeforeSetGroupInfoCommand = "callbackBeforeSetGroupInfoCommand"
|
||||||
CallbackBeforeSetGroupInfoExCommand = "callbackBeforeSetGroupInfoExCommand"
|
CallbackBeforeSetGroupInfoExCommand = "callbackBeforeSetGroupInfoExCommand"
|
||||||
CallbackAfterRevokeMsgCommand = "callbackBeforeAfterMsgCommand"
|
CallbackAfterRevokeMsgCommand = "callbackBeforeAfterMsgCommand"
|
||||||
CallbackBeforeAddBlackCommand = "callbackBeforeAddBlackCommand"
|
CallbackBeforeAddBlackCommand = "callbackBeforeAddBlackCommand"
|
||||||
CallbackAfterAddFriendCommand = "callbackAfterAddFriendCommand"
|
CallbackAfterAddFriendCommand = "callbackAfterAddFriendCommand"
|
||||||
CallbackBeforeAddFriendAgreeCommand = "callbackBeforeAddFriendAgreeCommand"
|
CallbackBeforeAddFriendAgreeCommand = "callbackBeforeAddFriendAgreeCommand"
|
||||||
CallbackAfterAddFriendAgreeCommand = "callbackAfterAddFriendAgreeCommand"
|
CallbackAfterAddFriendAgreeCommand = "callbackAfterAddFriendAgreeCommand"
|
||||||
CallbackAfterDeleteFriendCommand = "callbackAfterDeleteFriendCommand"
|
CallbackAfterDeleteFriendCommand = "callbackAfterDeleteFriendCommand"
|
||||||
CallbackBeforeImportFriendsCommand = "callbackBeforeImportFriendsCommand"
|
CallbackBeforeImportFriendsCommand = "callbackBeforeImportFriendsCommand"
|
||||||
CallbackAfterImportFriendsCommand = "callbackAfterImportFriendsCommand"
|
CallbackAfterImportFriendsCommand = "callbackAfterImportFriendsCommand"
|
||||||
CallbackAfterRemoveBlackCommand = "callbackAfterRemoveBlackCommand"
|
CallbackAfterRemoveBlackCommand = "callbackAfterRemoveBlackCommand"
|
||||||
CallbackAfterQuitGroupCommand = "callbackAfterQuitGroupCommand"
|
CallbackAfterQuitGroupCommand = "callbackAfterQuitGroupCommand"
|
||||||
CallbackAfterKickGroupCommand = "callbackAfterKickGroupCommand"
|
CallbackAfterKickGroupCommand = "callbackAfterKickGroupCommand"
|
||||||
CallbackAfterDisMissGroupCommand = "callbackAfterDisMissGroupCommand"
|
CallbackAfterDisMissGroupCommand = "callbackAfterDisMissGroupCommand"
|
||||||
CallbackBeforeJoinGroupCommand = "callbackBeforeJoinGroupCommand"
|
CallbackBeforeJoinGroupCommand = "callbackBeforeJoinGroupCommand"
|
||||||
CallbackAfterGroupMsgReadCommand = "callbackAfterGroupMsgReadCommand"
|
CallbackAfterGroupMsgReadCommand = "callbackAfterGroupMsgReadCommand"
|
||||||
CallbackBeforeMsgModifyCommand = "callbackBeforeMsgModifyCommand"
|
CallbackBeforeMsgModifyCommand = "callbackBeforeMsgModifyCommand"
|
||||||
CallbackAfterUpdateUserInfoCommand = "callbackAfterUpdateUserInfoCommand"
|
CallbackAfterUpdateUserInfoCommand = "callbackAfterUpdateUserInfoCommand"
|
||||||
CallbackAfterUpdateUserInfoExCommand = "callbackAfterUpdateUserInfoExCommand"
|
CallbackAfterUpdateUserInfoExCommand = "callbackAfterUpdateUserInfoExCommand"
|
||||||
CallbackBeforeUpdateUserInfoExCommand = "callbackBeforeUpdateUserInfoExCommand"
|
CallbackBeforeUpdateUserInfoExCommand = "callbackBeforeUpdateUserInfoExCommand"
|
||||||
CallbackBeforeUserRegisterCommand = "callbackBeforeUserRegisterCommand"
|
CallbackBeforeUserRegisterCommand = "callbackBeforeUserRegisterCommand"
|
||||||
CallbackAfterUserRegisterCommand = "callbackAfterUserRegisterCommand"
|
CallbackAfterUserRegisterCommand = "callbackAfterUserRegisterCommand"
|
||||||
CallbackAfterTransferGroupOwnerCommand = "callbackAfterTransferGroupOwnerCommand"
|
CallbackAfterTransferGroupOwnerCommand = "callbackAfterTransferGroupOwnerCommand"
|
||||||
CallbackBeforeSetFriendRemarkCommand = "callbackBeforeSetFriendRemarkCommand"
|
CallbackBeforeSetFriendRemarkCommand = "callbackBeforeSetFriendRemarkCommand"
|
||||||
CallbackAfterSetFriendRemarkCommand = "callbackAfterSetFriendRemarkCommand"
|
CallbackAfterSetFriendRemarkCommand = "callbackAfterSetFriendRemarkCommand"
|
||||||
CallbackAfterSingleMsgReadCommand = "callbackAfterSingleMsgReadCommand"
|
CallbackAfterSingleMsgReadCommand = "callbackAfterSingleMsgReadCommand"
|
||||||
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
||||||
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
||||||
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
||||||
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
||||||
CallbackAfterUserOnlineCommand = "callbackAfterUserOnlineCommand"
|
CallbackAfterUserOnlineCommand = "callbackAfterUserOnlineCommand"
|
||||||
CallbackAfterUserOfflineCommand = "callbackAfterUserOfflineCommand"
|
CallbackAfterUserOfflineCommand = "callbackAfterUserOfflineCommand"
|
||||||
CallbackAfterUserKickOffCommand = "callbackAfterUserKickOffCommand"
|
CallbackAfterUserKickOffCommand = "callbackAfterUserKickOffCommand"
|
||||||
CallbackBeforeOfflinePushCommand = "callbackBeforeOfflinePushCommand"
|
CallbackBeforeOfflinePushCommand = "callbackBeforeOfflinePushCommand"
|
||||||
CallbackBeforeOnlinePushCommand = "callbackBeforeOnlinePushCommand"
|
CallbackBeforeOnlinePushCommand = "callbackBeforeOnlinePushCommand"
|
||||||
CallbackBeforeGroupOnlinePushCommand = "callbackBeforeGroupOnlinePushCommand"
|
CallbackBeforeGroupOnlinePushCommand = "callbackBeforeGroupOnlinePushCommand"
|
||||||
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
|
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
|
||||||
CallbackBeforeUpdateUserInfoCommand = "callbackBeforeUpdateUserInfoCommand"
|
CallbackBeforeUpdateUserInfoCommand = "callbackBeforeUpdateUserInfoCommand"
|
||||||
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
|
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
|
||||||
CallbackAfterCreateGroupCommand = "callbackAfterCreateGroupCommand"
|
CallbackAfterCreateGroupCommand = "callbackAfterCreateGroupCommand"
|
||||||
CallbackBeforeMembersJoinGroupCommand = "callbackBeforeMembersJoinGroupCommand"
|
CallbackBeforeMembersJoinGroupCommand = "callbackBeforeMembersJoinGroupCommand"
|
||||||
CallbackBeforeSetGroupMemberInfoCommand = "callbackBeforeSetGroupMemberInfoCommand"
|
CallbackBeforeSetGroupMemberInfoCommand = "callbackBeforeSetGroupMemberInfoCommand"
|
||||||
CallbackAfterSetGroupMemberInfoCommand = "callbackAfterSetGroupMemberInfoCommand"
|
CallbackAfterSetGroupMemberInfoCommand = "callbackAfterSetGroupMemberInfoCommand"
|
||||||
|
CallbackBeforeCreateSingleChatConversationsCommand = "callbackBeforeCreateSingleChatConversationsCommand"
|
||||||
|
CallbackAfterCreateSingleChatConversationsCommand = "callbackAfterCreateSingleChatConversationsCommand"
|
||||||
|
CallbackBeforeCreateGroupChatConversationsCommand = "callbackBeforeCreateGroupChatConversationsCommand"
|
||||||
|
CallbackAfterCreateGroupChatConversationsCommand = "callbackAfterCreateGroupChatConversationsCommand"
|
||||||
)
|
)
|
||||||
|
91
pkg/callbackstruct/conversation.go
Normal file
91
pkg/callbackstruct/conversation.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package callbackstruct
|
||||||
|
|
||||||
|
type CallbackBeforeCreateSingleChatConversationsReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OwnerUserID string `json:"owner_user_id"`
|
||||||
|
ConversationID string `json:"conversation_id"`
|
||||||
|
ConversationType int32 `json:"conversation_type"`
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
RecvMsgOpt int32 `json:"recv_msg_opt"`
|
||||||
|
IsPinned bool `json:"is_pinned"`
|
||||||
|
IsPrivateChat bool `json:"is_private_chat"`
|
||||||
|
BurnDuration int32 `json:"burn_duration"`
|
||||||
|
GroupAtType int32 `json:"group_at_type"`
|
||||||
|
AttachedInfo string `json:"attached_info"`
|
||||||
|
Ex string `json:"ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackBeforeCreateSingleChatConversationsResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
RecvMsgOpt *int32 `json:"recv_msg_opt"`
|
||||||
|
IsPinned *bool `json:"is_pinned"`
|
||||||
|
IsPrivateChat *bool `json:"is_private_chat"`
|
||||||
|
BurnDuration *int32 `json:"burn_duration"`
|
||||||
|
GroupAtType *int32 `json:"group_at_type"`
|
||||||
|
AttachedInfo *string `json:"attached_info"`
|
||||||
|
Ex *string `json:"ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterCreateSingleChatConversationsReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OwnerUserID string `json:"owner_user_id"`
|
||||||
|
ConversationID string `json:"conversation_id"`
|
||||||
|
ConversationType int32 `json:"conversation_type"`
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
RecvMsgOpt int32 `json:"recv_msg_opt"`
|
||||||
|
IsPinned bool `json:"is_pinned"`
|
||||||
|
IsPrivateChat bool `json:"is_private_chat"`
|
||||||
|
BurnDuration int32 `json:"burn_duration"`
|
||||||
|
GroupAtType int32 `json:"group_at_type"`
|
||||||
|
AttachedInfo string `json:"attached_info"`
|
||||||
|
Ex string `json:"ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterCreateSingleChatConversationsResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackBeforeCreateGroupChatConversationsReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OwnerUserID string `json:"owner_user_id"`
|
||||||
|
ConversationID string `json:"conversation_id"`
|
||||||
|
ConversationType int32 `json:"conversation_type"`
|
||||||
|
GroupID string `json:"group_id"`
|
||||||
|
RecvMsgOpt int32 `json:"recv_msg_opt"`
|
||||||
|
IsPinned bool `json:"is_pinned"`
|
||||||
|
IsPrivateChat bool `json:"is_private_chat"`
|
||||||
|
BurnDuration int32 `json:"burn_duration"`
|
||||||
|
GroupAtType int32 `json:"group_at_type"`
|
||||||
|
AttachedInfo string `json:"attached_info"`
|
||||||
|
Ex string `json:"ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackBeforeCreateGroupChatConversationsResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
RecvMsgOpt *int32 `json:"recv_msg_opt"`
|
||||||
|
IsPinned *bool `json:"is_pinned"`
|
||||||
|
IsPrivateChat *bool `json:"is_private_chat"`
|
||||||
|
BurnDuration *int32 `json:"burn_duration"`
|
||||||
|
GroupAtType *int32 `json:"group_at_type"`
|
||||||
|
AttachedInfo *string `json:"attached_info"`
|
||||||
|
Ex *string `json:"ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterCreateGroupChatConversationsReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OwnerUserID string `json:"owner_user_id"`
|
||||||
|
ConversationID string `json:"conversation_id"`
|
||||||
|
ConversationType int32 `json:"conversation_type"`
|
||||||
|
GroupID string `json:"group_id"`
|
||||||
|
RecvMsgOpt int32 `json:"recv_msg_opt"`
|
||||||
|
IsPinned bool `json:"is_pinned"`
|
||||||
|
IsPrivateChat bool `json:"is_private_chat"`
|
||||||
|
BurnDuration int32 `json:"burn_duration"`
|
||||||
|
GroupAtType int32 `json:"group_at_type"`
|
||||||
|
AttachedInfo string `json:"attached_info"`
|
||||||
|
Ex string `json:"ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterCreateGroupChatConversationsResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
@ -41,6 +41,7 @@ func NewConversationRpcCmd() *ConversationRpcCmd {
|
|||||||
config.MongodbConfigFileName: &conversationConfig.MongodbConfig,
|
config.MongodbConfigFileName: &conversationConfig.MongodbConfig,
|
||||||
config.ShareFileName: &conversationConfig.Share,
|
config.ShareFileName: &conversationConfig.Share,
|
||||||
config.NotificationFileName: &conversationConfig.NotificationConfig,
|
config.NotificationFileName: &conversationConfig.NotificationConfig,
|
||||||
|
config.WebhooksConfigFileName: &conversationConfig.WebhooksConfig,
|
||||||
config.LocalCacheConfigFileName: &conversationConfig.LocalCacheConfig,
|
config.LocalCacheConfigFileName: &conversationConfig.LocalCacheConfig,
|
||||||
config.DiscoveryConfigFilename: &conversationConfig.Discovery,
|
config.DiscoveryConfigFilename: &conversationConfig.Discovery,
|
||||||
}
|
}
|
||||||
@ -67,6 +68,7 @@ func (a *ConversationRpcCmd) runE() error {
|
|||||||
a.conversationConfig.NotificationConfig.GetConfigFileName(),
|
a.conversationConfig.NotificationConfig.GetConfigFileName(),
|
||||||
a.conversationConfig.Share.GetConfigFileName(),
|
a.conversationConfig.Share.GetConfigFileName(),
|
||||||
a.conversationConfig.LocalCacheConfig.GetConfigFileName(),
|
a.conversationConfig.LocalCacheConfig.GetConfigFileName(),
|
||||||
|
a.conversationConfig.WebhooksConfig.GetConfigFileName(),
|
||||||
a.conversationConfig.Discovery.GetConfigFileName(),
|
a.conversationConfig.Discovery.GetConfigFileName(),
|
||||||
}, nil,
|
}, nil,
|
||||||
conversation.Start)
|
conversation.Start)
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
"github.com/openimsdk/tools/db/pagination"
|
"github.com/openimsdk/tools/db/pagination"
|
||||||
"github.com/openimsdk/tools/db/tx"
|
"github.com/openimsdk/tools/db/tx"
|
||||||
@ -48,7 +47,7 @@ type ConversationDatabase interface {
|
|||||||
// transactional.
|
// transactional.
|
||||||
SetUsersConversationFieldTx(ctx context.Context, userIDs []string, conversation *relationtb.Conversation, fieldMap map[string]any) error
|
SetUsersConversationFieldTx(ctx context.Context, userIDs []string, conversation *relationtb.Conversation, fieldMap map[string]any) error
|
||||||
// CreateGroupChatConversation creates a group chat conversation for the specified group ID and user IDs.
|
// CreateGroupChatConversation creates a group chat conversation for the specified group ID and user IDs.
|
||||||
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error
|
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string, conversations *relationtb.Conversation) error
|
||||||
// GetConversationIDs retrieves conversation IDs for a given user.
|
// GetConversationIDs retrieves conversation IDs for a given user.
|
||||||
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
||||||
// GetUserConversationIDsHash gets the hash of conversation IDs for a given user.
|
// GetUserConversationIDsHash gets the hash of conversation IDs for a given user.
|
||||||
@ -298,10 +297,10 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs
|
|||||||
// return c.cache.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
|
// return c.cache.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error {
|
func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string, conversation *relationtb.Conversation) error {
|
||||||
return c.tx.Transaction(ctx, func(ctx context.Context) error {
|
return c.tx.Transaction(ctx, func(ctx context.Context) error {
|
||||||
cache := c.cache.CloneConversationCache()
|
cache := c.cache.CloneConversationCache()
|
||||||
conversationID := msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, groupID)
|
conversationID := conversation.ConversationID
|
||||||
existConversationUserIDs, err := c.conversationDB.FindUserID(ctx, userIDs, []string{conversationID})
|
existConversationUserIDs, err := c.conversationDB.FindUserID(ctx, userIDs, []string{conversationID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -309,7 +308,15 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context,
|
|||||||
notExistUserIDs := stringutil.DifferenceString(userIDs, existConversationUserIDs)
|
notExistUserIDs := stringutil.DifferenceString(userIDs, existConversationUserIDs)
|
||||||
var conversations []*relationtb.Conversation
|
var conversations []*relationtb.Conversation
|
||||||
for _, v := range notExistUserIDs {
|
for _, v := range notExistUserIDs {
|
||||||
conversation := relationtb.Conversation{ConversationType: constant.ReadGroupChatType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID}
|
conversation := relationtb.Conversation{
|
||||||
|
ConversationType: conversation.ConversationType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID,
|
||||||
|
// the parameters have default value
|
||||||
|
RecvMsgOpt: conversation.RecvMsgOpt, IsPinned: conversation.IsPinned, IsPrivateChat: conversation.IsPrivateChat,
|
||||||
|
BurnDuration: conversation.BurnDuration, GroupAtType: conversation.GroupAtType, AttachedInfo: conversation.AttachedInfo,
|
||||||
|
Ex: conversation.Ex, MaxSeq: conversation.MaxSeq, MinSeq: conversation.MinSeq, CreateTime: conversation.CreateTime,
|
||||||
|
MsgDestructTime: conversation.MsgDestructTime, IsMsgDestruct: conversation.IsMsgDestruct, LatestMsgDestructTime: conversation.LatestMsgDestructTime,
|
||||||
|
}
|
||||||
|
|
||||||
conversations = append(conversations, &conversation)
|
conversations = append(conversations, &conversation)
|
||||||
cache = cache.DelConversations(v, conversationID).DelConversationNotReceiveMessageUserIDs(conversationID)
|
cache = cache.DelConversations(v, conversationID).DelConversationNotReceiveMessageUserIDs(conversationID)
|
||||||
}
|
}
|
||||||
@ -320,7 +327,7 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = c.conversationDB.UpdateByMap(ctx, existConversationUserIDs, conversationID, map[string]any{"max_seq": 0})
|
_, err = c.conversationDB.UpdateByMap(ctx, existConversationUserIDs, conversationID, map[string]any{"max_seq": conversation.MaxSeq})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user