Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 5c557c9

Browse files
authored
Merge pull request #66 from LF-Engineering/handle-conflict
handle conflicts on add identity
2 parents b3ed531 + e7ddb3f commit 5c557c9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

affiliation/identity.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ func (a *Affiliation) AddIdentity(identity *Identity) bool {
9595

9696
endpoint := a.AffBaseURL + "/affiliation/" + url.PathEscape(a.ProjectSlug) + "/add_identity/" + url.PathEscape(identity.Source)
9797
statusCode, res, err := a.httpClientProvider.Request(strings.TrimSpace(endpoint), "POST", headers, nil, queryParams)
98-
if statusCode != http.StatusOK {
98+
switch statusCode {
99+
case http.StatusOK, http.StatusConflict:
100+
return true
101+
default:
99102
if err != nil {
100103
log.Println("AddIdentity: Could not insert the identity: ", err)
101104
}
@@ -109,7 +112,7 @@ func (a *Affiliation) AddIdentity(identity *Identity) bool {
109112
time.Sleep(5 * time.Minute)
110113
return a.AddIdentity(identity)
111114
}
112-
return true
115+
return false
113116
}
114117

115118
// GetIdentity ...

0 commit comments

Comments
 (0)