Skip to content

Commit

Permalink
feat(user-svc): implement ReadPublicProfile (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSchaefer authored Oct 22, 2023
1 parent e9c0177 commit 3d20029
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions services/user-svc/internal/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ 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) {
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())
}

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)
Expand Down

0 comments on commit 3d20029

Please sign in to comment.