mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
hasRead
This commit is contained in:
parent
d714e16333
commit
5cd0f8f1ec
@ -101,6 +101,7 @@ func (m *msgServer) DeleteMsgPhysical(ctx context.Context, req *msg.DeleteMsgPhy
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []string, userID string, deleteSyncOpt *msg.DeleteSyncOpt) error {
|
func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []string, userID string, deleteSyncOpt *msg.DeleteSyncOpt) error {
|
||||||
|
defer log.ZDebug(ctx, "clearConversation return line")
|
||||||
conversations, err := m.Conversation.GetConversationsByConversationID(ctx, conversationIDs)
|
conversations, err := m.Conversation.GetConversationsByConversationID(ctx, conversationIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -135,5 +136,8 @@ func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []str
|
|||||||
m.notificationSender.NotificationWithSesstionType(ctx, userID, m.conversationAndGetRecvID(conversation, userID), constant.ClearConversationNotification, conversation.ConversationType, tips)
|
m.notificationSender.NotificationWithSesstionType(ctx, userID, m.conversationAndGetRecvID(conversation, userID), constant.ClearConversationNotification, conversation.ConversationType, tips)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := m.MsgDatabase.UserSetHasReadSeqs(ctx, userID, maxSeqs); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
8
pkg/common/db/cache/msg.go
vendored
8
pkg/common/db/cache/msg.go
vendored
@ -63,6 +63,8 @@ type SeqCache interface {
|
|||||||
SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error
|
SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error
|
||||||
// k: user, v: seq
|
// k: user, v: seq
|
||||||
SetHasReadSeqs(ctx context.Context, conversationID string, hasReadSeqs map[string]int64) error
|
SetHasReadSeqs(ctx context.Context, conversationID string, hasReadSeqs map[string]int64) error
|
||||||
|
// k: conversation, v :seq
|
||||||
|
UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error
|
||||||
GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error)
|
GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error)
|
||||||
GetHasReadSeq(ctx context.Context, userID string, conversationID string) (int64, error)
|
GetHasReadSeq(ctx context.Context, userID string, conversationID string) (int64, error)
|
||||||
}
|
}
|
||||||
@ -245,6 +247,12 @@ func (c *msgCache) SetHasReadSeqs(ctx context.Context, conversationID string, ha
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *msgCache) UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error {
|
||||||
|
return c.setSeqs(ctx, hasReadSeqs, func(conversationID string) string {
|
||||||
|
return c.getHasReadSeqKey(conversationID, userID)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (c *msgCache) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) {
|
func (c *msgCache) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) {
|
||||||
return c.getSeqs(ctx, conversationIDs, func(conversationID string) string {
|
return c.getSeqs(ctx, conversationIDs, func(conversationID string) string {
|
||||||
return c.getHasReadSeqKey(conversationID, userID)
|
return c.getHasReadSeqKey(conversationID, userID)
|
||||||
|
@ -69,6 +69,7 @@ type CommonMsgDatabase interface {
|
|||||||
SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error
|
SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error
|
||||||
GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error)
|
GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error)
|
||||||
GetHasReadSeq(ctx context.Context, userID string, conversationID string) (int64, error)
|
GetHasReadSeq(ctx context.Context, userID string, conversationID string) (int64, error)
|
||||||
|
UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error
|
||||||
|
|
||||||
GetMongoMaxAndMinSeq(ctx context.Context, conversationID string) (maxSeq, minSeq int64, err error)
|
GetMongoMaxAndMinSeq(ctx context.Context, conversationID string) (maxSeq, minSeq int64, err error)
|
||||||
GetConversationMinMaxSeqInMongoAndCache(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
|
GetConversationMinMaxSeqInMongoAndCache(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
|
||||||
@ -807,6 +808,10 @@ func (db *commonMsgDatabase) SetUserConversationsMinSeqs(ctx context.Context, us
|
|||||||
return db.cache.SetUserConversationsMinSeqs(ctx, userID, seqs)
|
return db.cache.SetUserConversationsMinSeqs(ctx, userID, seqs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *commonMsgDatabase) UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error {
|
||||||
|
return db.cache.UserSetHasReadSeqs(ctx, userID, hasReadSeqs)
|
||||||
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error {
|
func (db *commonMsgDatabase) SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error {
|
||||||
return db.cache.SetHasReadSeq(ctx, userID, conversationID, hasReadSeq)
|
return db.cache.SetHasReadSeq(ctx, userID, conversationID, hasReadSeq)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user