mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 21:22:16 +08:00
revert seq logic.
This commit is contained in:
parent
643ca022cc
commit
47916087a4
@ -436,37 +436,20 @@ func (c *conversationServer) CreateGroupChatConversations(ctx context.Context, r
|
|||||||
return &pbconversation.CreateGroupChatConversationsResp{}, nil
|
return &pbconversation.CreateGroupChatConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (c *conversationServer) SetConversationMaxSeq(ctx context.Context, req *pbconversation.SetConversationMaxSeqReq) (*pbconversation.SetConversationMaxSeqResp, error) {
|
|
||||||
// if err := c.conversationDatabase.UpdateUsersConversationField(ctx, req.OwnerUserID, req.ConversationID,
|
|
||||||
// map[string]any{"max_seq": req.MaxSeq}); err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return &pbconversation.SetConversationMaxSeqResp{}, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (c *conversationServer) SetConversationMaxSeq(ctx context.Context, req *pbconversation.SetConversationMaxSeqReq) (*pbconversation.SetConversationMaxSeqResp, error) {
|
func (c *conversationServer) SetConversationMaxSeq(ctx context.Context, req *pbconversation.SetConversationMaxSeqReq) (*pbconversation.SetConversationMaxSeqResp, error) {
|
||||||
|
if err := c.conversationDatabase.UpdateUsersConversationField(ctx, req.OwnerUserID, req.ConversationID,
|
||||||
if err := c.conversationDatabase.SetUserConversationMaxSeq(ctx, req.ConversationID, req.OwnerUserID[0], req.MaxSeq); err != nil {
|
map[string]any{"max_seq": req.MaxSeq}); err != nil {
|
||||||
return nil, errs.Wrap(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pbconversation.SetConversationMaxSeqResp{}, nil
|
return &pbconversation.SetConversationMaxSeqResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (c *conversationServer) SetConversationMinSeq(ctx context.Context, req *pbconversation.SetConversationMinSeqReq) (*pbconversation.SetConversationMinSeqResp, error) {
|
|
||||||
// if err := c.conversationDatabase.UpdateUsersConversationField(ctx, req.OwnerUserID, req.ConversationID,
|
|
||||||
// map[string]any{"min_seq": req.MinSeq}); err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// return &pbconversation.SetConversationMinSeqResp{}, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (c *conversationServer) SetConversationMinSeq(ctx context.Context, req *pbconversation.SetConversationMinSeqReq) (*pbconversation.SetConversationMinSeqResp, error) {
|
func (c *conversationServer) SetConversationMinSeq(ctx context.Context, req *pbconversation.SetConversationMinSeqReq) (*pbconversation.SetConversationMinSeqResp, error) {
|
||||||
if err := c.conversationDatabase.SetUserConversationMinSeq(ctx, req.ConversationID, req.OwnerUserID[0], req.MinSeq); err != nil {
|
if err := c.conversationDatabase.UpdateUsersConversationField(ctx, req.OwnerUserID, req.ConversationID,
|
||||||
return nil, errs.Wrap(err)
|
map[string]any{"min_seq": req.MinSeq}); err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pbconversation.SetConversationMinSeqResp{}, nil
|
return &pbconversation.SetConversationMinSeqResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,15 +74,6 @@ type ConversationDatabase interface {
|
|||||||
GetNotNotifyConversationIDs(ctx context.Context, userID string) ([]string, error)
|
GetNotNotifyConversationIDs(ctx context.Context, userID string) ([]string, error)
|
||||||
// GetPinnedConversationIDs gets pinned conversationIDs by userID
|
// GetPinnedConversationIDs gets pinned conversationIDs by userID
|
||||||
GetPinnedConversationIDs(ctx context.Context, userID string) ([]string, error)
|
GetPinnedConversationIDs(ctx context.Context, userID string) ([]string, error)
|
||||||
|
|
||||||
// GetUserConversationMinSeq is get user specific conversation min seq
|
|
||||||
GetUserConversationMinSeq(ctx context.Context, conversationID, userID string) (int64, error)
|
|
||||||
// SetUserConversationMinSeq is set user specific conversation min seq
|
|
||||||
SetUserConversationMinSeq(ctx context.Context, conversationID, userID string, seq int64) error
|
|
||||||
// GetUserConversationMaxSeq is get user specific conversation max seq
|
|
||||||
GetUserConversationMaxSeq(ctx context.Context, conversationID, userID string) (int64, error)
|
|
||||||
// SetUserConversationMaxSeq is set user specific conversation max seq
|
|
||||||
SetUserConversationMaxSeq(ctx context.Context, conversationID, userID string, seq int64) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConversationDatabase(conversation database.Conversation, cache cache.ConversationCache, tx tx.Tx) ConversationDatabase {
|
func NewConversationDatabase(conversation database.Conversation, cache cache.ConversationCache, tx tx.Tx) ConversationDatabase {
|
||||||
@ -188,7 +179,7 @@ func (c *conversationDatabase) CreateConversation(ctx context.Context, conversat
|
|||||||
if conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
if conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
notNotifyUserIDs = append(notNotifyUserIDs, conversation.OwnerUserID)
|
notNotifyUserIDs = append(notNotifyUserIDs, conversation.OwnerUserID)
|
||||||
}
|
}
|
||||||
if conversation.IsPinned == true {
|
if conversation.IsPinned {
|
||||||
pinnedUserIDs = append(pinnedUserIDs, conversation.OwnerUserID)
|
pinnedUserIDs = append(pinnedUserIDs, conversation.OwnerUserID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,28 +401,3 @@ func (c *conversationDatabase) GetPinnedConversationIDs(ctx context.Context, use
|
|||||||
}
|
}
|
||||||
return conversationIDs, nil
|
return conversationIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetUserConversationMinSeq(ctx context.Context, conversationID, userID string) (int64, error) {
|
|
||||||
seq, err := c.conversationDB.GetUserConversationMinSeq(ctx, conversationID, userID)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return seq, nil
|
|
||||||
}
|
|
||||||
func (c *conversationDatabase) SetUserConversationMinSeq(ctx context.Context, conversationID, userID string, seq int64) error {
|
|
||||||
return c.conversationDB.SetUserConversationMinSeq(ctx, conversationID, userID, seq)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *conversationDatabase) GetUserConversationMaxSeq(ctx context.Context, conversationID, userID string) (int64, error) {
|
|
||||||
seq, err := c.conversationDB.GetUserConversationMaxSeq(ctx, conversationID, userID)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return seq, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *conversationDatabase) SetUserConversationMaxSeq(ctx context.Context, conversationID, userID string, seq int64) error {
|
|
||||||
return c.conversationDB.SetUserConversationMaxSeq(ctx, conversationID, userID, seq)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -42,9 +42,4 @@ type Conversation interface {
|
|||||||
GetConversationIDsNeedDestruct(ctx context.Context) ([]*model.Conversation, error)
|
GetConversationIDsNeedDestruct(ctx context.Context) ([]*model.Conversation, error)
|
||||||
GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error)
|
GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error)
|
||||||
FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*model.VersionLog, error)
|
FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*model.VersionLog, error)
|
||||||
|
|
||||||
GetUserConversationMinSeq(ctx context.Context, conversationID, userID string) (int64, error)
|
|
||||||
SetUserConversationMinSeq(ctx context.Context, conversationID, userID string, seq int64) error
|
|
||||||
GetUserConversationMaxSeq(ctx context.Context, conversationID, userID string) (int64, error)
|
|
||||||
SetUserConversationMaxSeq(ctx context.Context, conversationID, userID string, seq int64) error
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package mgo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||||
@ -229,49 +228,3 @@ func (c *ConversationMgo) GetConversationNotReceiveMessageUserIDs(ctx context.Co
|
|||||||
func (c *ConversationMgo) FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*model.VersionLog, error) {
|
func (c *ConversationMgo) FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*model.VersionLog, error) {
|
||||||
return c.version.FindChangeLog(ctx, userID, version, limit)
|
return c.version.FindChangeLog(ctx, userID, version, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConversationMgo) setSeq(ctx context.Context, conversationID string, userID string, seq int64, field string) error {
|
|
||||||
filter := map[string]any{
|
|
||||||
"owner_user_id": userID,
|
|
||||||
"conversation_id": conversationID,
|
|
||||||
}
|
|
||||||
update := map[string]any{
|
|
||||||
"$set": bson.M{
|
|
||||||
field: seq,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return mongoutil.UpdateOne(ctx, s.coll, filter, update, false, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ConversationMgo) getSeq(ctx context.Context, conversationID string, userID string, failed string) (int64, error) {
|
|
||||||
filter := map[string]any{
|
|
||||||
"owner_user_id": userID,
|
|
||||||
"conversation_id": conversationID,
|
|
||||||
}
|
|
||||||
|
|
||||||
opt := options.FindOne().SetProjection(bson.M{"_id": 0, failed: 1})
|
|
||||||
seq, err := mongoutil.FindOne[int64](ctx, s.coll, filter, opt)
|
|
||||||
if err == nil {
|
|
||||||
return seq, nil
|
|
||||||
} else if errors.Is(err, mongo.ErrNoDocuments) {
|
|
||||||
return 0, nil
|
|
||||||
} else {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ConversationMgo) GetUserConversationMinSeq(ctx context.Context, conversationID string, userID string) (int64, error) {
|
|
||||||
return s.getSeq(ctx, conversationID, userID, "min_seq")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ConversationMgo) SetUserConversationMinSeq(ctx context.Context, conversationID string, userID string, seq int64) error {
|
|
||||||
return s.setSeq(ctx, conversationID, userID, seq, "min_seq")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ConversationMgo) GetUserConversationMaxSeq(ctx context.Context, conversationID string, userID string) (int64, error) {
|
|
||||||
return s.getSeq(ctx, conversationID, userID, "max_seq")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ConversationMgo) SetUserConversationMaxSeq(ctx context.Context, conversationID string, userID string, seq int64) error {
|
|
||||||
return s.setSeq(ctx, conversationID, userID, seq, "max_seq")
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user