diff --git a/internal/common/check/access.go b/internal/common/check/access.go index 71254b903..bdd42c8aa 100644 --- a/internal/common/check/access.go +++ b/internal/common/check/access.go @@ -5,11 +5,10 @@ import ( "context" ) -func Access(ctx context.Context, ownerUserID string) (err error) { - _, err = GetUsersInfo(ctx, ownerUserID) +func (u *UserCheck) Access(ctx context.Context, ownerUserID string) (err error) { + _, err = u.GetUsersInfo(ctx, ownerUserID) if err != nil { return err } return tokenverify.CheckAccessV3(ctx, ownerUserID) - } diff --git a/internal/common/check/friend.go b/internal/common/check/friend.go index c48a42931..1cc6f0389 100644 --- a/internal/common/check/friend.go +++ b/internal/common/check/friend.go @@ -1,11 +1,21 @@ package check import ( + "Open_IM/pkg/common/config" + discoveryRegistry "Open_IM/pkg/discoveryregistry" sdkws "Open_IM/pkg/proto/sdkws" "context" "errors" + "google.golang.org/grpc" ) -func GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*sdkws.FriendInfo, error) { +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 (u *FriendChecker) getConn() (*grpc.ClientConn, error) { + return u.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName) +} diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go index 098bdcf56..29894f806 100644 --- a/internal/common/notification/c.go +++ b/internal/common/notification/c.go @@ -13,9 +13,10 @@ import ( ) type Check struct { - user *check.UserCheck - group *check.GroupChecker - msg *check.MsgCheck + user *check.UserCheck + group *check.GroupChecker + msg *check.MsgCheck + friend *check.FriendChecker } type NotificationMsg struct { diff --git a/internal/common/notification/friend.go b/internal/common/notification/friend.go index 7a521c329..e4d2568cf 100644 --- a/internal/common/notification/friend.go +++ b/internal/common/notification/friend.go @@ -1,7 +1,6 @@ package notification import ( - "Open_IM/internal/common/check" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" pbFriend "Open_IM/pkg/proto/friend" @@ -112,7 +111,7 @@ func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUser friendAddedTips.OpUser.Nickname = user[0].Nickname friendAddedTips.OpUser.FaceURL = user[0].FaceURL - friend, err := check.GetFriendsInfo(ctx, fromUserID, toUserID) + friend, err := c.friend.GetFriendsInfo(ctx, fromUserID, toUserID) if err != nil { return }