diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index c24149d43a..2ca0d20431 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -56,11 +56,10 @@ import ( type groupServer struct { pbgroup.UnimplementedGroupServer - db controller.GroupDatabase - notification *NotificationSender - config *Config - webhookClient *webhook.Client - // todo + db controller.GroupDatabase + notification *NotificationSender + config *Config + webhookClient *webhook.Client userClient *rpcli.UserClient msgClient *rpcli.MsgClient conversationClient *rpcli.ConversationClient diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index 1326fe5e68..79db149705 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -530,18 +530,3 @@ func (s *friendServer) UpdateFriends( s.notificationSender.FriendsInfoUpdateNotification(ctx, req.OwnerUserID, req.FriendUserIDs) return resp, nil } - -func (s *friendServer) GetIncrementalFriendsApplyTo(ctx context.Context, req *relation.GetIncrementalFriendsApplyToReq) (*relation.GetIncrementalFriendsApplyToResp, error) { - // TODO implement me - return nil, nil -} - -func (s *friendServer) GetIncrementalFriendsApplyFrom(ctx context.Context, req *relation.GetIncrementalFriendsApplyFromReq) (*relation.GetIncrementalFriendsApplyFromResp, error) { - // TODO implement me - return nil, nil -} - -func (s *friendServer) GetIncrementalBlacks(ctx context.Context, req *relation.GetIncrementalBlacksReq) (*relation.GetIncrementalBlacksResp, error) { - // TODO implement me - return nil, nil -} diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index b03ec3bae5..c5ee3be706 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -60,9 +60,8 @@ type userServer struct { RegisterCenter registry.SvcDiscoveryRegistry config *Config webhookClient *webhook.Client - // todo - groupClient *rpcli.GroupClient - relationClient *rpcli.RelationClient + groupClient *rpcli.GroupClient + relationClient *rpcli.RelationClient } type Config struct { @@ -99,6 +98,14 @@ func Start(ctx context.Context, config *Config, client registry.SvcDiscoveryRegi if err != nil { return err } + groupConn, err := client.GetConn(ctx, config.Discovery.RpcService.Group) + if err != nil { + return err + } + friendConn, err := client.GetConn(ctx, config.Discovery.RpcService.Friend) + if err != nil { + return err + } msgClient := rpcli.NewMsgClient(msgConn) userCache := redis.NewUserCacheRedis(rdb, &config.LocalCacheConfig, userDB, redis.GetRocksCacheOptions()) database := controller.NewUserDatabase(userDB, userCache, mgocli.GetTx()) @@ -111,6 +118,9 @@ func Start(ctx context.Context, config *Config, client registry.SvcDiscoveryRegi userNotificationSender: NewUserNotificationSender(config, msgClient, WithUserFunc(database.FindWithError)), config: config, webhookClient: webhook.NewWebhookClient(config.WebhooksConfig.URL), + + groupClient: rpcli.NewGroupClient(groupConn), + relationClient: rpcli.NewRelationClient(friendConn), } pbuser.RegisterUserServer(server, u) return u.db.InitOnce(context.Background(), users) diff --git a/pkg/rpcclient/grouphash/grouphash.go b/pkg/notification/grouphash/grouphash.go similarity index 100% rename from pkg/rpcclient/grouphash/grouphash.go rename to pkg/notification/grouphash/grouphash.go diff --git a/pkg/rpcclient/msg.go b/pkg/notification/msg.go similarity index 99% rename from pkg/rpcclient/msg.go rename to pkg/notification/msg.go index 253ec35592..0795982c8c 100644 --- a/pkg/rpcclient/msg.go +++ b/pkg/notification/msg.go @@ -17,7 +17,6 @@ package rpcclient import ( "context" "encoding/json" - "github.com/openimsdk/open-im-server/v3/pkg/rpcli" "time" "google.golang.org/protobuf/proto" @@ -133,8 +132,6 @@ type NotificationSender struct { sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) getUserInfo func(ctx context.Context, userID string) (*sdkws.UserInfo, error) queue *memamq.MemoryQueue - // todo - msgClient *rpcli.MsgClient } func WithQueue(queue *memamq.MemoryQueue) NotificationSenderOptions { diff --git a/pkg/rpcclient/notification/common.go b/pkg/notification/notification/common.go similarity index 100% rename from pkg/rpcclient/notification/common.go rename to pkg/notification/notification/common.go diff --git a/pkg/rpcclient/doc.go b/pkg/rpcclient/doc.go deleted file mode 100644 index 66b0aee91d..0000000000 --- a/pkg/rpcclient/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright © 2024 OpenIM. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package rpcclient // import "github.com/openimsdk/open-im-server/v3/pkg/rpcclient" diff --git a/pkg/rpcclient/grouphash/doc.go b/pkg/rpcclient/grouphash/doc.go deleted file mode 100644 index c780701d9a..0000000000 --- a/pkg/rpcclient/grouphash/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright © 2024 OpenIM. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package grouphash // import "github.com/openimsdk/open-im-server/v3/pkg/rpcclient/grouphash" diff --git a/pkg/rpcclient/init.go b/pkg/rpcclient/init.go deleted file mode 100644 index 7fc0906616..0000000000 --- a/pkg/rpcclient/init.go +++ /dev/null @@ -1,60 +0,0 @@ -package rpcclient - -//import ( -// "context" -// -// "github.com/openimsdk/open-im-server/v3/pkg/common/config" -// pbauth "github.com/openimsdk/protocol/auth" -// pbconversation "github.com/openimsdk/protocol/conversation" -// pbgroup "github.com/openimsdk/protocol/group" -// pbmsg "github.com/openimsdk/protocol/msg" -// pbmsggateway "github.com/openimsdk/protocol/msggateway" -// pbpush "github.com/openimsdk/protocol/push" -// pbrelation "github.com/openimsdk/protocol/relation" -// pbthird "github.com/openimsdk/protocol/third" -// pbuser "github.com/openimsdk/protocol/user" -// "github.com/openimsdk/tools/discovery" -// "github.com/openimsdk/tools/system/program" -// "google.golang.org/grpc" -//) -// -//func InitRpcCaller(discov discovery.SvcDiscoveryRegistry, service config.RpcService) error { -// initConn := func(discov discovery.SvcDiscoveryRegistry, name string, initFunc func(conn *grpc.ClientConn)) error { -// conn, err := discov.GetConn(context.Background(), name) -// if err != nil { -// program.ExitWithError(err) -// return err -// } -// initFunc(conn) -// return nil -// } -// if err := initConn(discov, service.Auth, pbauth.InitAuth); err != nil { -// return err -// } -// if err := initConn(discov, service.Conversation, pbconversation.InitConversation); err != nil { -// return err -// } -// if err := initConn(discov, service.Group, pbgroup.InitGroup); err != nil { -// return err -// } -// if err := initConn(discov, service.Msg, pbmsg.InitMsg); err != nil { -// return err -// } -// if err := initConn(discov, service.MessageGateway, pbmsggateway.InitMsgGateway); err != nil { -// return err -// } -// if err := initConn(discov, service.Push, pbpush.InitPushMsgService); err != nil { -// return err -// } -// if err := initConn(discov, service.Friend, pbrelation.InitFriend); err != nil { -// return err -// } -// if err := initConn(discov, service.Third, pbthird.InitThird); err != nil { -// return err -// } -// if err := initConn(discov, service.User, pbuser.InitUser); err != nil { -// return err -// } -// -// return nil -//} diff --git a/pkg/rpcclient/notification/doc.go b/pkg/rpcclient/notification/doc.go deleted file mode 100644 index 8ce57ca4e8..0000000000 --- a/pkg/rpcclient/notification/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright © 2024 OpenIM. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package notification // import "github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification" diff --git a/pkg/rpcclient/user.go b/pkg/rpcclient/user.go deleted file mode 100644 index 8d1b4efcbf..0000000000 --- a/pkg/rpcclient/user.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright © 2023 OpenIM. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package rpcclient - -// -//import ( -// "context" -// "strings" -// -// "github.com/openimsdk/open-im-server/v3/pkg/common/servererrs" -// "github.com/openimsdk/protocol/sdkws" -// "github.com/openimsdk/protocol/user" -// "github.com/openimsdk/tools/utils/datautil" -//) -// -//// GetUsersInfo retrieves information for multiple users based on their user IDs. -//func GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) { -// if len(userIDs) == 0 { -// return []*sdkws.UserInfo{}, nil -// } -// resp, err := user.GetDesignateUsersCaller.Invoke(ctx, &user.GetDesignateUsersReq{ -// UserIDs: userIDs, -// }) -// if err != nil { -// return nil, err -// } -// if ids := datautil.Single(userIDs, datautil.Slice(resp.UsersInfo, func(e *sdkws.UserInfo) string { -// return e.UserID -// })); len(ids) > 0 { -// return nil, servererrs.ErrUserIDNotFound.WrapMsg(strings.Join(ids, ",")) -// } -// return resp.UsersInfo, nil -//} -// -//// GetUserInfo retrieves information for a single user based on the provided user ID. -//func GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) { -// users, err := GetUsersInfo(ctx, []string{userID}) -// if err != nil { -// return nil, err -// } -// return users[0], nil -//} -// -//// GetUsersInfoMap retrieves a map of user information indexed by their user IDs. -//func GetUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) { -// users, err := GetUsersInfo(ctx, userIDs) -// if err != nil { -// return nil, err -// } -// return datautil.SliceToMap(users, func(e *sdkws.UserInfo) string { -// return e.UserID -// }), nil -//} -// -//// GetPublicUserInfos retrieves public information for multiple users based on their user IDs. -//func GetPublicUserInfos( -// ctx context.Context, -// userIDs []string, -//) ([]*sdkws.PublicUserInfo, error) { -// users, err := GetUsersInfo(ctx, userIDs) -// if err != nil { -// return nil, err -// } -// -// return datautil.Slice(users, func(e *sdkws.UserInfo) *sdkws.PublicUserInfo { -// return &sdkws.PublicUserInfo{ -// UserID: e.UserID, -// Nickname: e.Nickname, -// FaceURL: e.FaceURL, -// Ex: e.Ex, -// } -// }), nil -//} -// -//// GetPublicUserInfo retrieves public information for a single user based on the provided user ID. -//func GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) { -// users, err := GetPublicUserInfos(ctx, []string{userID}) -// if err != nil { -// return nil, err -// } -// -// return users[0], nil -//} -// -//// GetPublicUserInfoMap retrieves a map of public user information indexed by their user IDs. -//func GetPublicUserInfoMap( -// ctx context.Context, -// userIDs []string, -//) (map[string]*sdkws.PublicUserInfo, error) { -// users, err := GetPublicUserInfos(ctx, userIDs) -// if err != nil { -// return nil, err -// } -// -// return datautil.SliceToMap(users, func(e *sdkws.PublicUserInfo) string { -// return e.UserID -// }), nil -//}