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

Commit 0669981

Browse files
committed
check if identity exists before sleep
1 parent 998f7e7 commit 0669981

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

affiliation/identity.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import (
77
"log"
88
"net/http"
99
"net/url"
10+
"regexp"
1011
"strings"
1112
"time"
1213
)
1314

1415
var (
15-
unknown = "Unknown"
16+
unknown = "Unknown"
17+
emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
1618
)
1719

1820
// Affiliations interface
@@ -109,9 +111,13 @@ func (a *Affiliation) AddIdentity(identity *Identity) bool {
109111
log.Println("AddIdentity: failed to add identity: ", errMsg)
110112
}
111113

112-
time.Sleep(2 * time.Minute)
113-
return a.AddIdentity(identity)
114+
// check if identity has been added to db
115+
if checkIdentity := a.GetIdentity(identity.UUID); checkIdentity != nil {
116+
return true
117+
}
114118
}
119+
time.Sleep(2 * time.Minute)
120+
return a.AddIdentity(identity)
115121
}
116122

117123
// GetIdentity ...

0 commit comments

Comments
 (0)