From eca4629c5dde38d6da2b2889cc0395da6160fbf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Sch=C3=A4fer?= Date: Sun, 22 Oct 2023 20:44:58 +0200 Subject: [PATCH 1/2] feat(user-svc): implement ReadPublicProfile --- services/user-svc/internal/user/user.go | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/services/user-svc/internal/user/user.go b/services/user-svc/internal/user/user.go index d73ac1cb2..82d71002c 100644 --- a/services/user-svc/internal/user/user.go +++ b/services/user-svc/internal/user/user.go @@ -73,6 +73,32 @@ func (s ServiceServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest return &pb.CreateUserResponse{Id: user.ID.String()}, nil } +func (s ServiceServer) ReadPublicProfile(ctx context.Context, req *pb.ReadPublicProfileRequest) (*pb.ReadPublicProfileResponse, error) { + log := zlog.Ctx(ctx) + userRepository := repositories.UserRepo(ctx) + + userID, err := uuid.Parse(req.Id) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + user, err := userRepository.GetUserById(userID) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + log.Debug(). + Str("userID", userID.String()). + Msg("serving public user profile") + + return &pb.ReadPublicProfileResponse{ + Id: user.ID.String(), + Name: user.Name, + Nickname: user.Nickname, + AvatarUrl: user.Avatar, + }, nil +} + func HandleUserUpdatedEvent(ctx context.Context, evt *daprcmn.TopicEvent) (retry bool, err error) { log := zlog.Ctx(ctx) userRepository := repositories.UserRepo(ctx) From 681e6eb4988a1617f9f04caab4eb738b65dd2de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Sch=C3=A4fer?= Date: Sun, 22 Oct 2023 21:18:46 +0200 Subject: [PATCH 2/2] fix: remove debug line --- services/user-svc/internal/user/user.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/services/user-svc/internal/user/user.go b/services/user-svc/internal/user/user.go index 82d71002c..426e9f89c 100644 --- a/services/user-svc/internal/user/user.go +++ b/services/user-svc/internal/user/user.go @@ -74,7 +74,6 @@ func (s ServiceServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest } func (s ServiceServer) ReadPublicProfile(ctx context.Context, req *pb.ReadPublicProfileRequest) (*pb.ReadPublicProfileResponse, error) { - log := zlog.Ctx(ctx) userRepository := repositories.UserRepo(ctx) userID, err := uuid.Parse(req.Id) @@ -87,10 +86,6 @@ func (s ServiceServer) ReadPublicProfile(ctx context.Context, req *pb.ReadPublic return nil, status.Error(codes.Internal, err.Error()) } - log.Debug(). - Str("userID", userID.String()). - Msg("serving public user profile") - return &pb.ReadPublicProfileResponse{ Id: user.ID.String(), Name: user.Name,