Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(user-svc): implement ReadPublicProfile #484

Merged
merged 2 commits into from
Oct 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 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,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)
Expand Down
Loading