Error code standardization

This commit is contained in:
skiffer-git 2023-02-14 11:49:42 +08:00
parent 8435508f35
commit 461fd5f1ff
4 changed files with 18 additions and 9 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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
}