mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-01 00:42:13 +08:00 
			
		
		
		
	* new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * MsgDestructTime * fix bug: msg destruct sql * fix bug: msg destruct * fix bug: msg destruct * fix bug: msg destruct sql * fix bug: msg destruct sql * fix bug: msg destruct sql * fix bug: msg destruct sql * debug: print stack * debug: print stack * debug: print stack * fix bug: msg destruct sql Signed-off-by: wangchuxiao <wangchuxiao97@outlook.com> * fix bug: msg notification self 2 self push twice * fix bug: heartbeat get self notification * fix bug: init grpc conn in one process * fix bug: grpc conn Signed-off-by: wangchuxiao <wangchuxiao97@outlook.com> * fix bug: zk client recreate node when reconn * fix bug: set friend mark args error * fix bug: rpc client intercepter called twice Signed-off-by: wangchuxiao <wangchuxiao97@outlook.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * test: document msg num set 100 * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * merge code * merge code * fix bug: repeat add friend not effect * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix bug: refused friend * fix bug: fix_add_friend * fix bug: fix_add_friend * fix bug: fix_add_friend * fix bug: fix_add_friend --------- Signed-off-by: wangchuxiao <wangchuxiao97@outlook.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: wangchuxiao-dev <wangchuxiao-dev@users.noreply.github.com>
		
			
				
	
	
		
			69 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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/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 []interface{}
 | |
| 			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))
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |