package web_api import ( "context" "strconv" "git.itzana.me/strafesnet/maps-service/pkg/api" ) // BatchUsernames handles batch fetching of usernames func (svc *Service) BatchUsernames(ctx context.Context, req *api.BatchUsernamesReq) (*api.BatchUsernamesOK, error) { if len(req.UserIds) == 0 { return &api.BatchUsernamesOK{ Usernames: api.NewOptBatchUsernamesOKUsernames(map[string]string{}), }, nil } // Fetch usernames from service usernames, err := svc.inner.GetUsernames(ctx, req.UserIds) if err != nil { return nil, err } // Convert map[uint64]string to map[string]string for JSON result := make(map[string]string, len(usernames)) for userID, username := range usernames { result[strconv.FormatUint(userID, 10)] = username } return &api.BatchUsernamesOK{ Usernames: api.NewOptBatchUsernamesOKUsernames(result), }, nil }