mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 16:32:12 +08:00 
			
		
		
		
	* fix: GetUserReqApplicationList error when there is a disbanded group chat
* fix: error when querying some information about disbanded group
* fix: GetUserReqApplicationList dismissed group error
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* fix: the original message referenced by the pull message processing is withdrawn
* merge
* cicd: robot automated Change
* sdkws.MsgData
* user
* interface{} -> any
* user
* third
* group
* group
* group
* group
* group
* group
* conversation
* standalone mysql db model
* tx
* s3
* group
* mongo
* group
* group
* group
* group
* group
* group
* refactor: add openim mysql to mongo refactor
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* refactor: add openim mysql to mongo refactor
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* remove mysql
* remove mysql
* friend
* friend
* friend
* friend
* friend
* friend
* group
* convert
* index
* index
* all
* all
* mysql2mongo
* data conversion
* up35
* up35
* feat: add format set
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* fix: fix scripts
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* merge main
* merge main
* Update init-config.sh
* fix: user args check
---------
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
Co-authored-by: withchao <withchao@users.noreply.github.com>
Co-authored-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
Co-authored-by: Xinwei Xiong <3293172751@qq.com>
		
	
			
		
			
				
	
	
		
			83 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright © 2023 OpenIM. All rights reserved.
 | |
| //
 | |
| // Licensed under the Apache License, Version 2.0 (the "License");
 | |
| // you may not use this file except in compliance with the License.
 | |
| // You may obtain a copy of the License at
 | |
| //
 | |
| //     http://www.apache.org/licenses/LICENSE-2.0
 | |
| //
 | |
| // Unless required by applicable law or agreed to in writing, software
 | |
| // distributed under the License is distributed on an "AS IS" BASIS,
 | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| // See the License for the specific language governing permissions and
 | |
| // limitations under the License.
 | |
| 
 | |
| package unrelation
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"fmt"
 | |
| 
 | |
| 	"github.com/OpenIMSDK/tools/log"
 | |
| 	"go.mongodb.org/mongo-driver/bson"
 | |
| 	"go.mongodb.org/mongo-driver/bson/primitive"
 | |
| 
 | |
| 	table "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/unrelation"
 | |
| )
 | |
| 
 | |
| func (m *MsgMongoDriver) ConvertMsgsDocLen(ctx context.Context, conversationIDs []string) {
 | |
| 	for _, conversationID := range conversationIDs {
 | |
| 		regex := primitive.Regex{Pattern: fmt.Sprintf("^%s:", conversationID)}
 | |
| 		cursor, err := m.MsgCollection.Find(ctx, bson.M{"doc_id": regex})
 | |
| 		if err != nil {
 | |
| 			log.ZError(ctx, "convertAll find msg doc failed", err, "conversationID", conversationID)
 | |
| 			continue
 | |
| 		}
 | |
| 		var msgDocs []table.MsgDocModel
 | |
| 		err = cursor.All(ctx, &msgDocs)
 | |
| 		if err != nil {
 | |
| 			log.ZError(ctx, "convertAll cursor all failed", err, "conversationID", conversationID)
 | |
| 			continue
 | |
| 		}
 | |
| 		if len(msgDocs) < 1 {
 | |
| 			continue
 | |
| 		}
 | |
| 		log.ZInfo(ctx, "msg doc convert", "conversationID", conversationID, "len(msgDocs)", len(msgDocs))
 | |
| 		if len(msgDocs[0].Msg) == int(m.model.GetSingleGocMsgNum5000()) {
 | |
| 			if _, err := m.MsgCollection.DeleteMany(ctx, bson.M{"doc_id": regex}); err != nil {
 | |
| 				log.ZError(ctx, "convertAll delete many failed", err, "conversationID", conversationID)
 | |
| 				continue
 | |
| 			}
 | |
| 			var newMsgDocs []any
 | |
| 			for _, msgDoc := range msgDocs {
 | |
| 				if int64(len(msgDoc.Msg)) == m.model.GetSingleGocMsgNum() {
 | |
| 					continue
 | |
| 				}
 | |
| 				var index int64
 | |
| 				for index < int64(len(msgDoc.Msg)) {
 | |
| 					msg := msgDoc.Msg[index]
 | |
| 					if msg != nil && msg.Msg != nil {
 | |
| 						msgDocModel := table.MsgDocModel{DocID: m.model.GetDocID(conversationID, msg.Msg.Seq)}
 | |
| 						end := index + m.model.GetSingleGocMsgNum()
 | |
| 						if int(end) >= len(msgDoc.Msg) {
 | |
| 							msgDocModel.Msg = msgDoc.Msg[index:]
 | |
| 						} else {
 | |
| 							msgDocModel.Msg = msgDoc.Msg[index:end]
 | |
| 						}
 | |
| 						newMsgDocs = append(newMsgDocs, msgDocModel)
 | |
| 						index = end
 | |
| 					} else {
 | |
| 						break
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 			_, err = m.MsgCollection.InsertMany(ctx, newMsgDocs)
 | |
| 			if err != nil {
 | |
| 				log.ZError(ctx, "convertAll insert many failed", err, "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs))
 | |
| 			} else {
 | |
| 				log.ZInfo(ctx, "msg doc convert", "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs))
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |