mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-23 18:00:32 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
commit
c672e5b702
@ -271,11 +271,7 @@ func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) CreateGroupChatConversations(ctx context.Context, req *pbConversation.CreateGroupChatConversationsReq) (*pbConversation.CreateGroupChatConversationsResp, error) {
|
func (c *conversationServer) CreateGroupChatConversations(ctx context.Context, req *pbConversation.CreateGroupChatConversationsReq) (*pbConversation.CreateGroupChatConversationsResp, error) {
|
||||||
maxSeq, err := c.msgRpcClient.GetConversationMaxSeq(ctx, utils.GenGroupConversationID(req.GroupID))
|
err := c.conversationDatabase.CreateGroupChatConversation(ctx, req.GroupID, req.UserIDs)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
err = c.conversationDatabase.CreateGroupChatConversation(ctx, req.GroupID, req.UserIDs, maxSeq)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -869,7 +869,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
|||||||
|
|
||||||
func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
|
func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
|
||||||
conevrsationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
|
conevrsationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
|
||||||
maxSeq, err := s.msgRpcClient.GetConversationMaxSeq(ctx, utils.GenConversationUniqueKeyForGroup(groupID))
|
maxSeq, err := s.msgRpcClient.GetConversationMaxSeq(ctx, conevrsationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
@ -18,6 +18,7 @@ func (m *msgServer) PullMessageBySeqs(ctx context.Context, req *sdkws.PullMessag
|
|||||||
conversation, err := m.Conversation.GetConversation(ctx, req.UserID, seq.ConversationID)
|
conversation, err := m.Conversation.GetConversation(ctx, req.UserID, seq.ConversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "GetConversation error", err, "conversationID", seq.ConversationID)
|
log.ZError(ctx, "GetConversation error", err, "conversationID", seq.ConversationID)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
minSeq, maxSeq, msgs, err := m.MsgDatabase.GetMsgBySeqsRange(ctx, req.UserID, seq.ConversationID, seq.Begin, seq.End, seq.Num, conversation.MaxSeq)
|
minSeq, maxSeq, msgs, err := m.MsgDatabase.GetMsgBySeqsRange(ctx, req.UserID, seq.ConversationID, seq.Begin, seq.End, seq.Num, conversation.MaxSeq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -91,13 +91,13 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if groupMemberInfo.RoleLevel > constant.GroupOrdinaryUsers {
|
if groupMemberInfo.RoleLevel == constant.GroupOwner {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
if groupMemberInfo.MuteEndTime >= time.Now().Unix() {
|
if groupMemberInfo.MuteEndTime >= time.Now().Unix() {
|
||||||
return errs.ErrMutedInGroup.Wrap()
|
return errs.ErrMutedInGroup.Wrap()
|
||||||
}
|
}
|
||||||
if groupInfo.Status == constant.GroupStatusMuted {
|
if groupInfo.Status == constant.GroupStatusMuted && groupMemberInfo.RoleLevel != constant.GroupAdmin {
|
||||||
return errs.ErrMutedGroup.Wrap()
|
return errs.ErrMutedGroup.Wrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ type ConversationDatabase interface {
|
|||||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
||||||
//SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
|
//SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
|
||||||
SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error
|
SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error
|
||||||
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string, maxSeq int64) error
|
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error
|
||||||
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
||||||
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
|
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
|
||||||
GetAllConversationIDs(ctx context.Context) ([]string, error)
|
GetAllConversationIDs(ctx context.Context) ([]string, error)
|
||||||
@ -213,7 +213,7 @@ func (c *conversationDatabase) FindRecvMsgNotNotifyUserIDs(ctx context.Context,
|
|||||||
return c.cache.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
|
return c.cache.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string, maxSeq int64) error {
|
func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error {
|
||||||
cache := c.cache.NewCache()
|
cache := c.cache.NewCache()
|
||||||
conversationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
|
conversationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
@ -224,7 +224,7 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context,
|
|||||||
notExistUserIDs := utils.DifferenceString(userIDs, existConversationUserIDs)
|
notExistUserIDs := utils.DifferenceString(userIDs, existConversationUserIDs)
|
||||||
var conversations []*relationTb.ConversationModel
|
var conversations []*relationTb.ConversationModel
|
||||||
for _, v := range notExistUserIDs {
|
for _, v := range notExistUserIDs {
|
||||||
conversation := relationTb.ConversationModel{ConversationType: constant.SuperGroupChatType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID, MaxSeq: maxSeq}
|
conversation := relationTb.ConversationModel{ConversationType: constant.SuperGroupChatType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID}
|
||||||
conversations = append(conversations, &conversation)
|
conversations = append(conversations, &conversation)
|
||||||
}
|
}
|
||||||
cache = cache.DelConversationIDs(notExistUserIDs...).DelUserConversationIDsHash(notExistUserIDs...)
|
cache = cache.DelConversationIDs(notExistUserIDs...).DelUserConversationIDsHash(notExistUserIDs...)
|
||||||
@ -234,7 +234,7 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = c.conversationDB.UpdateByMap(ctx, existConversationUserIDs, conversationID, map[string]interface{}{"max_seq": maxSeq})
|
_, err = c.conversationDB.UpdateByMap(ctx, existConversationUserIDs, conversationID, map[string]interface{}{"max_seq": 0})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -455,9 +455,11 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
|
|||||||
if err != nil && errs.Unwrap(err) != redis.Nil {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
return 0, 0, nil, err
|
return 0, 0, nil, err
|
||||||
}
|
}
|
||||||
|
if userMaxSeq != 0 {
|
||||||
if userMaxSeq < maxSeq {
|
if userMaxSeq < maxSeq {
|
||||||
maxSeq = userMaxSeq
|
maxSeq = userMaxSeq
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if begin < minSeq {
|
if begin < minSeq {
|
||||||
begin = minSeq
|
begin = minSeq
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user