parent
df9bbeb313
commit
e17f0c95aa
@ -0,0 +1,56 @@
|
|||||||
|
package conversation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/util/hashutil"
|
||||||
|
"github.com/openimsdk/protocol/conversation"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *conversationServer) GetFullOwnerConversationIDs(ctx context.Context, req *conversation.GetFullOwnerConversationIDsReq) (*conversation.GetFullOwnerConversationIDsResp, error) {
|
||||||
|
vl, err := c.conversationDatabase.FindMaxConversationUserVersionCache(ctx, req.UserID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
conversationIDs, err := c.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
idHash := hashutil.IdHash(conversationIDs)
|
||||||
|
if req.IdHash == idHash {
|
||||||
|
conversationIDs = nil
|
||||||
|
}
|
||||||
|
return &conversation.GetFullOwnerConversationIDsResp{
|
||||||
|
Version: idHash,
|
||||||
|
VersionID: vl.ID.Hex(),
|
||||||
|
Equal: req.IdHash == idHash,
|
||||||
|
ConversationIDs: conversationIDs,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *conversationServer) GetIncrementalConversation(ctx context.Context, req *conversation.GetIncrementalConversationReq) (*conversation.GetIncrementalConversationResp, error) {
|
||||||
|
opt := incrversion.Option[*conversation.Conversation, conversation.GetIncrementalConversationResp]{
|
||||||
|
Ctx: ctx,
|
||||||
|
VersionKey: req.UserID,
|
||||||
|
VersionID: req.VersionID,
|
||||||
|
VersionNumber: req.Version,
|
||||||
|
Version: c.conversationDatabase.FindConversationUserVersion,
|
||||||
|
CacheMaxVersion: c.conversationDatabase.FindMaxConversationUserVersionCache,
|
||||||
|
Find: func(ctx context.Context, conversationIDs []string) ([]*conversation.Conversation, error) {
|
||||||
|
return c.getConversations(ctx, req.UserID, conversationIDs)
|
||||||
|
},
|
||||||
|
ID: func(elem *conversation.Conversation) string { return elem.GroupID },
|
||||||
|
Resp: func(version *model.VersionLog, delIDs []string, insertList, updateList []*conversation.Conversation, full bool) *conversation.GetIncrementalConversationResp {
|
||||||
|
return &conversation.GetIncrementalConversationResp{
|
||||||
|
VersionID: version.ID.Hex(),
|
||||||
|
Version: uint64(version.Version),
|
||||||
|
Full: full,
|
||||||
|
Delete: delIDs,
|
||||||
|
Insert: insertList,
|
||||||
|
Update: updateList,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return opt.Build()
|
||||||
|
}
|
@ -1,17 +1,18 @@
|
|||||||
package database
|
package database
|
||||||
|
|
||||||
const (
|
const (
|
||||||
BlackName = "black"
|
BlackName = "black"
|
||||||
ConversationName = "conversation"
|
ConversationName = "conversation"
|
||||||
FriendName = "friend"
|
FriendName = "friend"
|
||||||
FriendVersionName = "friend_version"
|
FriendVersionName = "friend_version"
|
||||||
FriendRequestName = "friend_request"
|
FriendRequestName = "friend_request"
|
||||||
GroupName = "group"
|
GroupName = "group"
|
||||||
GroupMemberName = "group_member"
|
GroupMemberName = "group_member"
|
||||||
GroupMemberVersionName = "group_member_version"
|
GroupMemberVersionName = "group_member_version"
|
||||||
GroupJoinVersionName = "group_join_version"
|
GroupJoinVersionName = "group_join_version"
|
||||||
GroupRequestName = "group_request"
|
ConversationVersionName = "conversation_version"
|
||||||
LogName = "log"
|
GroupRequestName = "group_request"
|
||||||
ObjectName = "s3"
|
LogName = "log"
|
||||||
UserName = "user"
|
ObjectName = "s3"
|
||||||
|
UserName = "user"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in new issue