Commit 5bdcda5c authored by zauberstuhl's avatar zauberstuhl

Aspect dispatch contact before creating DB entry

parent 5b6116bf
...@@ -158,14 +158,8 @@ func (a ApiAspect) CreatePerson() revel.Result { ...@@ -158,14 +158,8 @@ func (a ApiAspect) CreatePerson() revel.Result {
PersonID: personID, PersonID: personID,
} }
err := membership.Create()
if err != nil {
a.Log.Error(TAG, "db", err, "api", ERR_SERVER)
return a.ApiError(http.StatusInternalServerError, ERR_SERVER)
}
var person models.Person var person models.Person
err = person.FindByID(personID) err := person.FindByID(personID)
if err != nil { if err != nil {
a.Log.Error(TAG, "db", err, "api", ERR_NOT_FOUND) a.Log.Error(TAG, "db", err, "api", ERR_NOT_FOUND)
return a.ApiError(http.StatusNotFound, ERR_NOT_FOUND) return a.ApiError(http.StatusNotFound, ERR_NOT_FOUND)
...@@ -182,6 +176,11 @@ func (a ApiAspect) CreatePerson() revel.Result { ...@@ -182,6 +176,11 @@ func (a ApiAspect) CreatePerson() revel.Result {
} }
go dispatcher.Run() go dispatcher.Run()
err = membership.Create()
if err != nil {
a.Log.Error(TAG, "db", err, "api", ERR_SERVER)
return a.ApiError(http.StatusInternalServerError, ERR_SERVER)
}
return a.RenderJSON(membership) return a.RenderJSON(membership)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment