Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions affiliation/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ type AffIdentity struct {
IsBot *int64 `json:"is_bot"`
MultiOrgNames []string `json:"multi_org_names"`
}

// ProfileByUsernameResponse ...
type ProfileByUsernameResponse struct {
Profiles []ProfileResponse `json:"profiles"`
}
19 changes: 11 additions & 8 deletions affiliation/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,29 @@ func (a *Affiliation) GetProfileByUsername(username string, projectSlug string)
return nil, errors.New("User not found")
}

var profile UniqueIdentityFullProfile
err = json.Unmarshal(res, &profile)
var profiles ProfileByUsernameResponse
err = json.Unmarshal(res, &profiles)
if err != nil {
return nil, err
}

profile := profiles.Profiles[0]

var identity AffIdentity
profileIdentity := profile.Identities[0]

identity.UUID = profileIdentity.UUID
identity.UUID = &profileIdentity.UUID

if profileIdentity.Name != nil {
identity.Name = *profileIdentity.Name
if profileIdentity.Name != "" {
identity.Name = profileIdentity.Name
} else {
identity.Name = unknown
}

identity.Username = username

if profileIdentity.Email != nil {
identity.Email = *profileIdentity.Email
if profileIdentity.Email != "" {
identity.Email = profileIdentity.Email
}

identity.ID = &profileIdentity.ID
Expand Down Expand Up @@ -360,7 +363,7 @@ func (a *Affiliation) GetProfileByUsername(username string, projectSlug string)
}

// Get Most Recent Org Name where user has multiple enrollments
func (a *Affiliation) getUserOrg(enrollments []*Enrollments) *string {
func (a *Affiliation) getUserOrg(enrollments []Enrollment) *string {
var result string
var lowest, startTime int64
now := time.Now()
Expand Down