diff --git a/go.mod b/go.mod index d9bdb8bfe2..95ce0a63e8 100644 --- a/go.mod +++ b/go.mod @@ -14,8 +14,8 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/openimsdk/protocol v0.0.72-alpha.67 - github.com/openimsdk/tools v0.0.50-alpha.58 + github.com/openimsdk/protocol v0.0.72-alpha.68 + github.com/openimsdk/tools v0.0.50-alpha.60 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 github.com/stretchr/testify v1.9.0 @@ -221,9 +221,3 @@ require ( golang.org/x/crypto v0.27.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) - - -replace ( - github.com/openimsdk/protocol => /Users/chao/Desktop/code/protocol - github.com/openimsdk/tools => /Users/chao/Desktop/code/tools -) \ No newline at end of file diff --git a/go.sum b/go.sum index 86ed9ed6e3..c0385481ca 100644 --- a/go.sum +++ b/go.sum @@ -347,10 +347,10 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/openimsdk/gomake v0.0.15-alpha.2 h1:5Q8yl8ezy2yx+q8/ucU/t4kJnDfCzNOrkXcDACCqtyM= github.com/openimsdk/gomake v0.0.15-alpha.2/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI= -github.com/openimsdk/protocol v0.0.72-alpha.67 h1:zlLbVkoT0OYsjO2RCutQuDFllcfNvZfdYchvlR6UIe0= -github.com/openimsdk/protocol v0.0.72-alpha.67/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M= -github.com/openimsdk/tools v0.0.50-alpha.58 h1:hkFL02Bzzp/l5x+tb7kJ9zes7hilh65EQ4qEIthsQX4= -github.com/openimsdk/tools v0.0.50-alpha.58/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0= +github.com/openimsdk/protocol v0.0.72-alpha.68 h1:Ekn6S9Ftt12Xs/p9kJ39RDr2gSwIczz+MmSHQE4lAek= +github.com/openimsdk/protocol v0.0.72-alpha.68/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M= +github.com/openimsdk/tools v0.0.50-alpha.60 h1:dYqYpSdSN5o6CxlEjua2USfwfUiG0tUWFBpqghTjbWE= +github.com/openimsdk/tools v0.0.50-alpha.60/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index ed286d02d5..1326fe5e68 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -126,6 +126,7 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg config: config, webhookClient: webhook.NewWebhookClient(config.WebhooksConfig.URL), queue: memamq.NewMemoryQueue(16, 1024*1024), + userClient: userClient, }) return nil } diff --git a/pkg/rpccache/conversation.go b/pkg/rpccache/conversation.go index f354efa598..70f5acfd10 100644 --- a/pkg/rpccache/conversation.go +++ b/pkg/rpccache/conversation.go @@ -92,7 +92,7 @@ func (c *ConversationLocalCache) GetConversation(ctx context.Context, userID, co var cache cacheProto[pbconversation.Conversation] return cache.Unmarshal(c.local.Get(ctx, cachekey.GetConversationKey(userID, conversationID), func(ctx context.Context) ([]byte, error) { log.ZDebug(ctx, "ConversationLocalCache GetConversation rpc", "userID", userID, "conversationID", conversationID) - return cache.Marshal(c.client.GetConversation(ctx, userID, conversationID)) + return cache.Marshal(c.client.GetConversation(ctx, conversationID, userID)) })) } diff --git a/pkg/rpcli/auth.go b/pkg/rpcli/auth.go index 22a0db1094..17fc6ea286 100644 --- a/pkg/rpcli/auth.go +++ b/pkg/rpcli/auth.go @@ -15,6 +15,9 @@ type AuthClient struct { } func (x *AuthClient) KickTokens(ctx context.Context, tokens []string) error { + if len(tokens) == 0 { + return nil + } return ignoreResp(x.AuthClient.KickTokens(ctx, &auth.KickTokensReq{Tokens: tokens})) } diff --git a/pkg/rpcli/conversation.go b/pkg/rpcli/conversation.go index b1409c923c..ba5b90cb31 100644 --- a/pkg/rpcli/conversation.go +++ b/pkg/rpcli/conversation.go @@ -15,16 +15,25 @@ type ConversationClient struct { } func (x *ConversationClient) SetConversationMaxSeq(ctx context.Context, conversationID string, ownerUserIDs []string, maxSeq int64) error { + if len(ownerUserIDs) == 0 { + return nil + } req := &conversation.SetConversationMaxSeqReq{ConversationID: conversationID, OwnerUserID: ownerUserIDs, MaxSeq: maxSeq} return ignoreResp(x.ConversationClient.SetConversationMaxSeq(ctx, req)) } -func (x *ConversationClient) SetConversations(ctx context.Context, userIDs []string, info *conversation.ConversationReq) error { - req := &conversation.SetConversationsReq{UserIDs: userIDs, Conversation: info} +func (x *ConversationClient) SetConversations(ctx context.Context, ownerUserIDs []string, info *conversation.ConversationReq) error { + if len(ownerUserIDs) == 0 { + return nil + } + req := &conversation.SetConversationsReq{UserIDs: ownerUserIDs, Conversation: info} return ignoreResp(x.ConversationClient.SetConversations(ctx, req)) } func (x *ConversationClient) GetConversationsByConversationIDs(ctx context.Context, conversationIDs []string) ([]*conversation.Conversation, error) { + if len(conversationIDs) == 0 { + return nil, nil + } req := &conversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs} return extractField(ctx, x.ConversationClient.GetConversationsByConversationID, req, (*conversation.GetConversationsByConversationIDResp).GetConversations) } @@ -34,6 +43,9 @@ func (x *ConversationClient) GetConversationsByConversationID(ctx context.Contex } func (x *ConversationClient) SetConversationMinSeq(ctx context.Context, conversationID string, ownerUserIDs []string, minSeq int64) error { + if len(ownerUserIDs) == 0 { + return nil + } req := &conversation.SetConversationMinSeqReq{ConversationID: conversationID, OwnerUserID: ownerUserIDs, MinSeq: minSeq} return ignoreResp(x.ConversationClient.SetConversationMinSeq(ctx, req)) } @@ -44,6 +56,9 @@ func (x *ConversationClient) GetConversation(ctx context.Context, conversationID } func (x *ConversationClient) GetConversations(ctx context.Context, conversationIDs []string, ownerUserID string) ([]*conversation.Conversation, error) { + if len(conversationIDs) == 0 { + return nil, nil + } req := &conversation.GetConversationsReq{ConversationIDs: conversationIDs, OwnerUserID: ownerUserID} return extractField(ctx, x.ConversationClient.GetConversations, req, (*conversation.GetConversationsResp).GetConversations) } @@ -59,6 +74,9 @@ func (x *ConversationClient) GetPinnedConversationIDs(ctx context.Context, owner } func (x *ConversationClient) CreateGroupChatConversations(ctx context.Context, groupID string, userIDs []string) error { + if len(userIDs) == 0 { + return nil + } req := &conversation.CreateGroupChatConversationsReq{GroupID: groupID, UserIDs: userIDs} return ignoreResp(x.ConversationClient.CreateGroupChatConversations(ctx, req)) } @@ -68,6 +86,9 @@ func (x *ConversationClient) CreateSingleChatConversations(ctx context.Context, } func (x *ConversationClient) GetConversationOfflinePushUserIDs(ctx context.Context, conversationID string, userIDs []string) ([]string, error) { + if len(userIDs) == 0 { + return nil, nil + } req := &conversation.GetConversationOfflinePushUserIDsReq{ConversationID: conversationID, UserIDs: userIDs} return extractField(ctx, x.ConversationClient.GetConversationOfflinePushUserIDs, req, (*conversation.GetConversationOfflinePushUserIDsResp).GetUserIDs) } diff --git a/pkg/rpcli/group.go b/pkg/rpcli/group.go index 7965732b39..b51283c5dc 100644 --- a/pkg/rpcli/group.go +++ b/pkg/rpcli/group.go @@ -16,6 +16,9 @@ type GroupClient struct { } func (x *GroupClient) GetGroupsInfo(ctx context.Context, groupIDs []string) ([]*sdkws.GroupInfo, error) { + if len(groupIDs) == 0 { + return nil, nil + } req := &group.GetGroupsInfoReq{GroupIDs: groupIDs} return extractField(ctx, x.GroupClient.GetGroupsInfo, req, (*group.GetGroupsInfoResp).GetGroupInfos) } @@ -30,7 +33,7 @@ func (x *GroupClient) GetGroupInfoCache(ctx context.Context, groupID string) (*s } func (x *GroupClient) GetGroupMemberCache(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { - req := &group.GetGroupMemberCacheReq{GroupID: groupID} + req := &group.GetGroupMemberCacheReq{GroupID: groupID, GroupMemberID: userID} return extractField(ctx, x.GroupClient.GetGroupMemberCache, req, (*group.GetGroupMemberCacheResp).GetMember) } diff --git a/pkg/rpcli/msg.go b/pkg/rpcli/msg.go index cd540bc366..0c44b7c8b6 100644 --- a/pkg/rpcli/msg.go +++ b/pkg/rpcli/msg.go @@ -16,26 +16,41 @@ type MsgClient struct { } func (x *MsgClient) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) { + if len(conversationIDs) == 0 { + return nil, nil + } req := &msg.GetMaxSeqsReq{ConversationIDs: conversationIDs} return extractField(ctx, x.MsgClient.GetMaxSeqs, req, (*msg.SeqsInfoResp).GetMaxSeqs) } func (x *MsgClient) GetMsgByConversationIDs(ctx context.Context, conversationIDs []string, maxSeqs map[string]int64) (map[string]*sdkws.MsgData, error) { + if len(conversationIDs) == 0 || len(maxSeqs) == 0 { + return nil, nil + } req := &msg.GetMsgByConversationIDsReq{ConversationIDs: conversationIDs, MaxSeqs: maxSeqs} return extractField(ctx, x.MsgClient.GetMsgByConversationIDs, req, (*msg.GetMsgByConversationIDsResp).GetMsgDatas) } func (x *MsgClient) GetHasReadSeqs(ctx context.Context, conversationIDs []string, userID string) (map[string]int64, error) { + if len(conversationIDs) == 0 { + return nil, nil + } req := &msg.GetHasReadSeqsReq{ConversationIDs: conversationIDs, UserID: userID} return extractField(ctx, x.MsgClient.GetHasReadSeqs, req, (*msg.SeqsInfoResp).GetMaxSeqs) } func (x *MsgClient) SetUserConversationMaxSeq(ctx context.Context, conversationID string, ownerUserIDs []string, maxSeq int64) error { + if len(ownerUserIDs) == 0 { + return nil + } req := &msg.SetUserConversationMaxSeqReq{ConversationID: conversationID, OwnerUserID: ownerUserIDs, MaxSeq: maxSeq} return ignoreResp(x.MsgClient.SetUserConversationMaxSeq(ctx, req)) } func (x *MsgClient) SetUserConversationMin(ctx context.Context, conversationID string, ownerUserIDs []string, minSeq int64) error { + if len(ownerUserIDs) == 0 { + return nil + } req := &msg.SetUserConversationsMinSeqReq{ConversationID: conversationID, UserIDs: ownerUserIDs, Seq: minSeq} return ignoreResp(x.MsgClient.SetUserConversationsMinSeq(ctx, req)) } @@ -51,16 +66,25 @@ func (x *MsgClient) GetConversationMaxSeq(ctx context.Context, conversationID st } func (x *MsgClient) GetActiveConversation(ctx context.Context, conversationIDs []string) ([]*msg.ActiveConversation, error) { + if len(conversationIDs) == 0 { + return nil, nil + } req := &msg.GetActiveConversationReq{ConversationIDs: conversationIDs} return extractField(ctx, x.MsgClient.GetActiveConversation, req, (*msg.GetActiveConversationResp).GetConversations) } func (x *MsgClient) GetSeqMessage(ctx context.Context, userID string, conversations []*msg.ConversationSeqs) (map[string]*sdkws.PullMsgs, error) { + if len(conversations) == 0 { + return nil, nil + } req := &msg.GetSeqMessageReq{UserID: userID, Conversations: conversations} return extractField(ctx, x.MsgClient.GetSeqMessage, req, (*msg.GetSeqMessageResp).GetMsgs) } func (x *MsgClient) SetUserConversationsMinSeq(ctx context.Context, conversationID string, userIDs []string, seq int64) error { + if len(userIDs) == 0 { + return nil + } req := &msg.SetUserConversationsMinSeqReq{ConversationID: conversationID, UserIDs: userIDs, Seq: seq} return ignoreResp(x.MsgClient.SetUserConversationsMinSeq(ctx, req)) } diff --git a/pkg/rpcli/relation.go b/pkg/rpcli/relation.go index 8abdbc5914..dce0e71656 100644 --- a/pkg/rpcli/relation.go +++ b/pkg/rpcli/relation.go @@ -15,6 +15,9 @@ type RelationClient struct { } func (x *RelationClient) GetFriendsInfo(ctx context.Context, ownerUserID string, friendUserIDs []string) ([]*relation.FriendInfoOnly, error) { + if len(friendUserIDs) == 0 { + return nil, nil + } req := &relation.GetFriendInfoReq{OwnerUserID: ownerUserID, FriendUserIDs: friendUserIDs} return extractField(ctx, x.FriendClient.GetFriendInfo, req, (*relation.GetFriendInfoResp).GetFriendInfos) } diff --git a/pkg/rpcli/user.go b/pkg/rpcli/user.go index 839729861e..357640345b 100644 --- a/pkg/rpcli/user.go +++ b/pkg/rpcli/user.go @@ -18,6 +18,9 @@ type UserClient struct { } func (x *UserClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) { + if len(userIDs) == 0 { + return nil, nil + } req := &user.GetDesignateUsersReq{UserIDs: userIDs} return extractField(ctx, x.UserClient.GetDesignateUsers, req, (*user.GetDesignateUsersResp).GetUsersInfo) } @@ -27,6 +30,9 @@ func (x *UserClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.Use } func (x *UserClient) CheckUser(ctx context.Context, userIDs []string) error { + if len(userIDs) == 0 { + return nil + } users, err := x.GetUsersInfo(ctx, userIDs) if err != nil { return err @@ -73,14 +79,14 @@ func (x *UserClient) GetUserOnlinePlatform(ctx context.Context, userID string) ( } func (x *UserClient) SetUserOnlineStatus(ctx context.Context, req *user.SetUserOnlineStatusReq) error { + if len(req.Status) == 0 { + return nil + } return ignoreResp(x.UserClient.SetUserOnlineStatus(ctx, req)) } func (x *UserClient) GetNotificationByID(ctx context.Context, userID string) error { - _, err := x.UserClient.GetNotificationAccount(ctx, &user.GetNotificationAccountReq{ - UserID: userID, - }) - return err + return ignoreResp(x.UserClient.GetNotificationAccount(ctx, &user.GetNotificationAccountReq{UserID: userID})) } func (x *UserClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumber int32) ([]string, error) {