This commit is contained in:
Wenkai Yin 2017-05-10 13:11:09 +08:00
parent 6cf545f304
commit 01066c72b5

View File

@ -119,27 +119,29 @@ func (p *ProjectAPI) Post() {
return
}
user, err := dao.GetUser(models.User{
UserID: p.userID,
})
if err != nil {
log.Errorf("failed to get user by ID %d: %v", p.userID, err)
p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
go func() {
user, err := dao.GetUser(models.User{
UserID: p.userID,
})
if err != nil {
log.Errorf("failed to get user by ID %d: %v", p.userID, err)
p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
accessLog := models.AccessLog{
Username: user.Username,
ProjectID: projectID,
RepoName: project.Name + "/",
RepoTag: "N/A",
GUID: "N/A",
Operation: "create",
OpTime: time.Now(),
}
if err = dao.AddAccessLog(accessLog); err != nil {
log.Errorf("failed to add access log: %v", err)
p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
accessLog := models.AccessLog{
Username: user.Username,
ProjectID: projectID,
RepoName: project.Name + "/",
RepoTag: "N/A",
GUID: "N/A",
Operation: "create",
OpTime: time.Now(),
}
if err = dao.AddAccessLog(accessLog); err != nil {
log.Errorf("failed to add access log: %v", err)
p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
}()
p.Redirect(http.StatusCreated, strconv.FormatInt(projectID, 10))
}