mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-14 05:56:00 +08:00
Error code standardization
This commit is contained in:
@@ -3,9 +3,9 @@ package check
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||
"Open_IM/pkg/proto/friend"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
"errors"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -13,9 +13,24 @@ type FriendChecker struct {
|
||||
zk discoveryRegistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*sdkws.FriendInfo, error) {
|
||||
return nil, errors.New("TODO:GetUserInfo")
|
||||
func NewFriendChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *FriendChecker {
|
||||
return &FriendChecker{
|
||||
zk: zk,
|
||||
}
|
||||
}
|
||||
func (u *FriendChecker) getConn() (*grpc.ClientConn, error) {
|
||||
return u.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName)
|
||||
|
||||
func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (resp *sdkws.FriendInfo, err error) {
|
||||
cc, err := f.getConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r, err := friend.NewFriendClient(cc).GetPaginationFriends(ctx, &friend.GetPaginationFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = r.FriendsInfo[0]
|
||||
return
|
||||
}
|
||||
func (f *FriendChecker) getConn() (*grpc.ClientConn, error) {
|
||||
return f.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user