mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-26 21:22:16 +08:00 
			
		
		
		
	* pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * upgrading pkg tools * fix * fix * optimize log output * feat: support GetLastMessage * feat: support GetLastMessage * feat: s3 switch * feat: s3 switch * fix: GetUsersOnline * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: seq conversion failed without exiting * fix: DeleteDoc crash * fix: fill send time * fix: fill send time * fix: crash caused by withdrawing messages from users who have left the group * fix: user msg timestamp * seq read config * seq read config * fix: the source message of the reference is withdrawn, and the referenced message is deleted * feat: optimize the default notification.yml * fix: shouldPushOffline * fix: the sorting is wrong after canceling the administrator in group settings * feat: Sending messages supports returning fields modified by webhook * feat: Sending messages supports returning fields modified by webhook * feat: Sending messages supports returning fields modified by webhook * fix: oss specifies content-type when uploading * fix: the version number contains a line break * fix: the version number contains a line break * feat: GetConversationsHasReadAndMaxSeq support pinned * feat: GetConversationsHasReadAndMaxSeq support pinned * feat: GetConversationsHasReadAndMaxSeq support pinned * fix: transferring the group owner to a muted member, incremental version error * feat: unified conversion code * feat: update gomake * feat: grpc mw * fix: permission verification * fix: optimizing the code * fix: optimize grpc option and fix some interface permission checks
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package msg
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"strings"
 | |
| 
 | |
| 	"github.com/openimsdk/open-im-server/v3/pkg/authverify"
 | |
| 	"github.com/openimsdk/protocol/msg"
 | |
| 	"github.com/openimsdk/tools/log"
 | |
| )
 | |
| 
 | |
| // DestructMsgs hard delete in Database.
 | |
| func (m *msgServer) DestructMsgs(ctx context.Context, req *msg.DestructMsgsReq) (*msg.DestructMsgsResp, error) {
 | |
| 	if err := authverify.CheckAdmin(ctx); err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	docs, err := m.MsgDatabase.GetRandBeforeMsg(ctx, req.Timestamp, int(req.Limit))
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	for i, doc := range docs {
 | |
| 		if err := m.MsgDatabase.DeleteDoc(ctx, doc.DocID); err != nil {
 | |
| 			return nil, err
 | |
| 		}
 | |
| 		log.ZDebug(ctx, "DestructMsgs delete doc", "index", i, "docID", doc.DocID)
 | |
| 		index := strings.LastIndex(doc.DocID, ":")
 | |
| 		if index < 0 {
 | |
| 			continue
 | |
| 		}
 | |
| 		var minSeq int64
 | |
| 		for _, model := range doc.Msg {
 | |
| 			if model.Msg == nil {
 | |
| 				continue
 | |
| 			}
 | |
| 			if model.Msg.Seq > minSeq {
 | |
| 				minSeq = model.Msg.Seq
 | |
| 			}
 | |
| 		}
 | |
| 		if minSeq <= 0 {
 | |
| 			continue
 | |
| 		}
 | |
| 		conversationID := doc.DocID[:index]
 | |
| 		if conversationID == "" {
 | |
| 			continue
 | |
| 		}
 | |
| 		minSeq++
 | |
| 		if err := m.MsgDatabase.SetMinSeq(ctx, conversationID, minSeq); err != nil {
 | |
| 			return nil, err
 | |
| 		}
 | |
| 		log.ZDebug(ctx, "DestructMsgs delete doc set min seq", "index", i, "docID", doc.DocID, "conversationID", conversationID, "setMinSeq", minSeq)
 | |
| 	}
 | |
| 	return &msg.DestructMsgsResp{Count: int32(len(docs))}, nil
 | |
| }
 | |
| 
 | |
| func (m *msgServer) GetLastMessageSeqByTime(ctx context.Context, req *msg.GetLastMessageSeqByTimeReq) (*msg.GetLastMessageSeqByTimeResp, error) {
 | |
| 	seq, err := m.MsgDatabase.GetLastMessageSeqByTime(ctx, req.ConversationID, req.Time)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return &msg.GetLastMessageSeqByTimeResp{Seq: seq}, nil
 | |
| }
 |